diff options
| author | Tim Almdal <tnalmdal@shaw.ca> | 2011-08-11 22:11:24 -0700 |
|---|---|---|
| committer | Tim Almdal <tnalmdal@shaw.ca> | 2011-08-11 22:11:24 -0700 |
| commit | c92d34a86b0515363f790056293cea2b0a738782 (patch) | |
| tree | 9d5b794e434d26ef7ee50281b3ebee716e3327a5 /modules/search/controllers/search.php | |
| parent | a5b1972bbe9676479886ca94bb23f09407a87561 (diff) | |
| parent | 933a34986dbca248f388e8aa3c3aea4a6d71a94b (diff) | |
Merge branch 'displayContext' into display_context_compressed
Conflicts:
modules/gallery/controllers/movies.php
modules/gallery/controllers/photos.php
modules/tag/controllers/tag.php
Diffstat (limited to 'modules/search/controllers/search.php')
| -rw-r--r-- | modules/search/controllers/search.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index 5db63ab0..1d5a55bf 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -21,6 +21,18 @@ class Search_Controller extends Controller { public function index() { $page_size = module::get_var("gallery", "page_size", 9); $q = Input::instance()->get("q"); + $q_with_more_terms = search::add_query_terms($q); + $show = Input::instance()->get("show"); + + if ($show) { + $child = ORM::factory("item", $show); + $index = search::get_position($child, $q_with_more_terms); + if ($index) { + $page = ceil($index / $page_size); + url::redirect( url::abs_site("search?q=" . urlencode($q) . ($page == 1 ? "" : "&page=$page"))); + } + } + $page = Input::instance()->get("page", 1); // Make sure that the page references a valid offset @@ -30,11 +42,18 @@ class Search_Controller extends Controller { $offset = ($page - 1) * $page_size; - $q_with_more_terms = search::add_query_terms($q); list ($count, $result) = search::search($q_with_more_terms, $page_size, $offset); + $title = t("Search: %q", array("q" => $q_with_more_terms)); + $max_pages = max(ceil($count / $page_size), 1); + Display_Context::factory("search") + ->set(array("title" => $title, + "query_terms" => $q_with_more_terms, + "q" => $q)) + ->save(); + $template = new Theme_View("page.html", "collection", "search"); $root = item::root(); $template->set_global( |
