From 72a6a8abafb90321ecd4e2101eac03f86c7c07dd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 14 Feb 2013 14:40:34 -0500 Subject: Follow-on to 9dbe2e15ad9db3b2be53e46bc5f67d382fb4089d for #1999. Fix an issue where siblings() by itself throws an error. The problem is that Theme_View::siblings() passes a null offset and limit to the callback which gets passed down to search::search_within_album, which creates its query in raw SQL and doesn't check for a null offset/limit. We want a reasonable limit on the size of the set here (and 1000 is probably wayyy too high so lower that to 100) so amend get_siblings to stop using default parameters and actually check the inputs. Author: Bharat Mediratta Date: Sat Feb 9 14:53:34 2013 -0500 Extend siblings callbacks to take a $limit and an $offset for navigating large sibling sets. Useful for the thumbnav module since we don't want to iterate a thousand siblings to find the one we care about. Fixes #1999. --- modules/search/controllers/search.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'modules/search') 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]; } -- cgit v1.2.3 From 58c137c98183377c8bacaad83c9b32caa9925fa2 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Mon, 18 Feb 2013 18:55:03 +0100 Subject: #2007 - Change search box text when only looking in the current album. - search.html.php - updated to use new labels. - search_link.html.php - updated to use new labels. Moved code that determines current album to top, then used it for both the new label and the hidden album input. Resulting form code looks more symmetric to search.html.php. --- modules/search/views/search.html.php | 6 +++++- modules/search/views/search_link.html.php | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'modules/search') 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 @@
  • - + id == item::root()->id): ?> + + + +
  • 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 @@
    " id="g-quick-search-form" class="g-short-form"> + + is_album() ? $item->id : $item->parent_id; ?> + + id; ?> +
    • - + id): ?> + + + + +
    • for_html_attr() ?>" class="submit" />
    - - is_album()): ?> - - - - -
    -- cgit v1.2.3 From e719a6316a1bd73dcd6335457517bf46f593532c Mon Sep 17 00:00:00 2001 From: shadlaws Date: Thu, 14 Mar 2013 15:44:00 +0100 Subject: #2062 - Fix extra/missing spaces in search query. - Every to-be-concatenated string now begins with 1 space and ends with 0 spaces. --- modules/search/helpers/search.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'modules/search') 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()) { -- cgit v1.2.3