diff options
Diffstat (limited to 'modules/search')
-rw-r--r-- | modules/search/controllers/search.php | 8 | ||||
-rw-r--r-- | modules/search/helpers/search.php | 15 | ||||
-rw-r--r-- | modules/search/views/search.html.php | 6 | ||||
-rw-r--r-- | modules/search/views/search_link.html.php | 19 |
4 files changed, 30 insertions, 18 deletions
diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index 25ccd81c..753d9b69 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -110,7 +110,13 @@ class Search_Controller extends Controller { Breadcrumb::instance($item->title, $item->url())->set_last())); } - static function get_siblings($q, $album, $limit=1000, $offset=1) { + static function get_siblings($q, $album, $limit, $offset) { + if (!isset($limit)) { + $limit = 100; + } + if (!isset($offset)) { + $offset = 1; + } $result = search::search_within_album(search::add_query_terms($q), $album, $limit, $offset); return $result[1]; } diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index b21e59dd..c84b70bb 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -42,8 +42,8 @@ class search_Core { $db = Database::instance(); $query = self::_build_query_base($q, $album) . - "ORDER BY `score` DESC " . - "LIMIT $limit OFFSET " . (int)$offset; + " ORDER BY `score` DESC" . + " LIMIT $limit OFFSET " . (int)$offset; $data = $db->query($query); $count = $db->query("SELECT FOUND_ROWS() as c")->current()->c; @@ -68,7 +68,7 @@ class search_Core { $album_sql = ""; } else { $album_sql = - " AND {items}.left_ptr > " .$db->escape($album->left_ptr) . + " AND {items}.left_ptr > " . $db->escape($album->left_ptr) . " AND {items}.right_ptr <= " . $db->escape($album->right_ptr); } @@ -76,11 +76,10 @@ class search_Core { "SELECT SQL_CALC_FOUND_ROWS {items}.*, " . " MATCH({search_records}.`data`) AGAINST ('$q') AS `score` " . "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " . - "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " . + "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE)" . $album_sql . (empty($where) ? "" : " AND " . join(" AND ", $where)) . - $access_sql . - " "; + $access_sql; } /** @@ -133,7 +132,7 @@ class search_Core { static function get_position_within_album($item, $q, $album) { $page_size = module::get_var("gallery", "page_size", 9); $query = self::_build_query_base($q, $album, array("{items}.id = " . $item->id)) . - "ORDER BY `score` DESC "; + " ORDER BY `score` DESC"; $db = Database::instance(); // Truncate the score by two decimal places as this resolves the issues @@ -153,7 +152,7 @@ class search_Core { // Redo the query but only look for results greater than or equal to our current location // then seek backwards until we find our item. $data = $db->query(self::_build_query_base($q, $album) . " HAVING `score` >= " . $score . - "ORDER BY `score` DESC "); + " ORDER BY `score` DESC"); $data->seek($data->count() - 1); while ($data->get("id") != $item->id && $data->prev()->valid()) { diff --git a/modules/search/views/search.html.php b/modules/search/views/search.html.php index f1906744..a42c31dd 100644 --- a/modules/search/views/search.html.php +++ b/modules/search/views/search.html.php @@ -7,7 +7,11 @@ </legend> <ul> <li> - <label for="q"><?= t("Search the gallery") ?></label> + <? if ($album->id == item::root()->id): ?> + <label for="q"><?= t("Search the gallery") ?></label> + <? else: ?> + <label for="q"><?= t("Search this album") ?></label> + <? endif; ?> <input name="album" type="hidden" value="<?= html::clean_attribute($album->id) ?>" /> <input name="q" id="q" type="text" value="<?= html::clean_attribute($q) ?>" class="text" /> </li> diff --git a/modules/search/views/search_link.html.php b/modules/search/views/search_link.html.php index be3305b7..4f9abc1a 100644 --- a/modules/search/views/search_link.html.php +++ b/modules/search/views/search_link.html.php @@ -1,19 +1,22 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <form action="<?= url::site("search") ?>" id="g-quick-search-form" class="g-short-form"> + <? if (isset($item)): ?> + <? $album_id = $item->is_album() ? $item->id : $item->parent_id; ?> + <? else: ?> + <? $album_id = item::root()->id; ?> + <? endif; ?> <ul> <li> - <label for="g-search"><?= t("Search the gallery") ?></label> + <? if ($album_id == item::root()->id): ?> + <label for="g-search"><?= t("Search the gallery") ?></label> + <? else: ?> + <label for="g-search"><?= t("Search this album") ?></label> + <? endif; ?> + <input type="hidden" name="album" value="<?= $album_id ?>" /> <input type="text" name="q" id="g-search" class="text" /> </li> <li> <input type="submit" value="<?= t("Go")->for_html_attr() ?>" class="submit" /> </li> </ul> - <? if (isset($item) && $item instanceof Item_Model_Core): ?> - <? if ($item->is_album()): ?> - <input type="hidden" name="album" value="<?= $item->id ?>" /> - <? else: ?> - <input type="hidden" name="album" value="<?= $item->parent_id ?>" /> - <? endif; ?> - <? endif; ?> </form> |