summaryrefslogtreecommitdiff
path: root/modules/search
diff options
context:
space:
mode:
authorNathan Kinkade <nath@nkinka.de>2013-02-14 14:28:46 +0000
committerNathan Kinkade <nath@nkinka.de>2013-02-14 14:28:46 +0000
commit711651f727e093cc7357a6bbff6bd992fd6dfd80 (patch)
tree2dadc1c06acf1ab3d42d3ed5415568535db54416 /modules/search
parent0047af90bf4db08b22838e6ded22a7fa70cee98a (diff)
parente5ed05004f005bdccdbf68e199ae2324ad97e895 (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/search')
-rw-r--r--modules/search/controllers/search.php27
-rw-r--r--modules/search/helpers/search.php12
-rw-r--r--modules/search/helpers/search_event.php2
-rw-r--r--modules/search/helpers/search_installer.php3
-rw-r--r--modules/search/helpers/search_task.php2
-rw-r--r--modules/search/helpers/search_theme.php2
-rw-r--r--modules/search/models/search_record.php2
-rw-r--r--modules/search/module.info6
8 files changed, 31 insertions, 25 deletions
diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php
index 52eb973c..25ccd81c 100644
--- a/modules/search/controllers/search.php
+++ b/modules/search/controllers/search.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -54,8 +54,6 @@ class Search_Controller extends Controller {
list ($count, $result) =
search::search_within_album($q_with_more_terms, $album, $page_size, $offset);
- $title = t("Search: %q", array("q" => $q_with_more_terms));
-
$max_pages = max(ceil($count / $page_size), 1);
$template = new Theme_View("page.html", "collection", "search");
@@ -77,28 +75,27 @@ class Search_Controller extends Controller {
print $template;
- item::set_display_context_callback(
- "Search_Controller::get_display_context", $album->id, $title, $q_with_more_terms, $q);
+ item::set_display_context_callback("Search_Controller::get_display_context", $album, $q);
}
- static function get_display_context($item, $album_id, $title, $query_terms, $q) {
- $album = ORM::factory("item", $album_id);
- $position = search::get_position_within_album($item, $query_terms, $album);
+ static function get_display_context($item, $album, $q) {
+ $q_with_more_terms = search::add_query_terms($q);
+ $position = search::get_position_within_album($item, $q_with_more_terms, $album);
if ($position > 1) {
list ($count, $result_data) =
- search::search_within_album($query_terms, $album, 3, $position - 2);
+ search::search_within_album($q_with_more_terms, $album, 3, $position - 2);
list ($previous_item, $ignore, $next_item) = $result_data;
} else {
$previous_item = null;
list ($count, $result_data) =
- search::search_within_album($query_terms, $album, 1, $position);
+ search::search_within_album($q_with_more_terms, $album, 1, $position);
list ($next_item) = $result_data;
}
$search_url = url::abs_site("search" .
"?q=" . urlencode($q) .
- "&album=" . urlencode($album_id) .
+ "&album=" . urlencode($album->id) .
"&show={$item->id}");
$root = item::root();
@@ -106,9 +103,15 @@ class Search_Controller extends Controller {
"previous_item" => $previous_item,
"next_item" => $next_item,
"sibling_count" => $count,
+ "siblings_callback" => array("Search_Controller::get_siblings", array($q, $album)),
"breadcrumbs" => array(
- Breadcrumb::instance($root->title, "/", $root->id)->set_first(),
+ Breadcrumb::instance($root->title, $root->url())->set_first(),
Breadcrumb::instance(t("Search: %q", array("q" => $q)), $search_url),
Breadcrumb::instance($item->title, $item->url())->set_last()));
}
+
+ static function get_siblings($q, $album, $limit=1000, $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 32b36e73..b21e59dd 100644
--- a/modules/search/helpers/search.php
+++ b/modules/search/helpers/search.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -132,11 +132,12 @@ 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));
+ $query = self::_build_query_base($q, $album, array("{items}.id = " . $item->id)) .
+ "ORDER BY `score` DESC ";
$db = Database::instance();
// Truncate the score by two decimal places as this resolves the issues
- // that arise due to in exact numeric conversions.
+ // that arise due to inexact numeric conversions.
$current = $db->query($query)->current();
if (!$current) {
// We can't find this result in our result set - perhaps we've fallen out of context? Clear
@@ -149,7 +150,10 @@ class search_Core {
$score = substr($score, 0, strlen($score) - 2);
}
- $data = $db->query(self::_build_query_base($q, $album) . " HAVING `score` >= " . $score);
+ // 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 ");
$data->seek($data->count() - 1);
while ($data->get("id") != $item->id && $data->prev()->valid()) {
diff --git a/modules/search/helpers/search_event.php b/modules/search/helpers/search_event.php
index 055cef62..a20935b1 100644
--- a/modules/search/helpers/search_event.php
+++ b/modules/search/helpers/search_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/search/helpers/search_installer.php b/modules/search/helpers/search_installer.php
index 288b706c..c9e8f26c 100644
--- a/modules/search/helpers/search_installer.php
+++ b/modules/search/helpers/search_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +30,6 @@ class search_installer {
FULLTEXT INDEX (`data`))
ENGINE=MyISAM
DEFAULT CHARSET=utf8;");
- module::set_version("search", 1);
}
static function activate() {
diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php
index 2abe78c9..18348a22 100644
--- a/modules/search/helpers/search_task.php
+++ b/modules/search/helpers/search_task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/search/helpers/search_theme.php b/modules/search/helpers/search_theme.php
index eb6c4cd3..e8735d11 100644
--- a/modules/search/helpers/search_theme.php
+++ b/modules/search/helpers/search_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/search/models/search_record.php b/modules/search/models/search_record.php
index 79614afa..be68e72e 100644
--- a/modules/search/models/search_record.php
+++ b/modules/search/models/search_record.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/search/module.info b/modules/search/module.info
index 1389798d..f1bb1fab 100644
--- a/modules/search/module.info
+++ b/modules/search/module.info
@@ -2,6 +2,6 @@ name = "Search"
description = "Allows users to search their Gallery"
version = 1
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:search"
-discuss_url = "http://gallery.menalto.com/forum_module_search"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:search"
+discuss_url = "http://galleryproject.org/forum_module_search"