From cd8663b81d9ded11a408df5a31212223a6ae554b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 14 Nov 2009 16:31:56 -0800 Subject: Fix pagination so that it does not require any domain specific logic to support tags and search. Instead, just modify the page param to the current page. --- modules/gallery/libraries/Theme_View.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 19dc0829..5b7378b6 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -153,15 +153,14 @@ class Theme_View_Core extends Gallery_View { $v->max_pages = $this->max_pages; $v->total = $this->children_count; - $model = $this->page_type == "album" ? $this->item : $this->tag; if ($this->page != 1) { - $v->first_page_url = $model->url(); - $v->previous_page_url = $model->url("page=" . ($this->page - 1)); + $v->first_page_url = url::merge(array("page" => 1)); + $v->first_page_url = url::merge(array("page" => $this->page - 1)); } if ($this->page != $this->max_pages) { - $v->next_page_url = $model->url("page=" . ($this->page + 1)); - $v->last_page_url = $model->url("page={$this->max_pages}"); + $v->next_page_url = url::merge(array("page" => $this->page + 1)); + $v->last_page_url = url::merge(array("page" => $this->max_pages)); } $v->first_visible_position = ($this->page - 1) * $this->page_size + 1; -- cgit v1.2.3 From d368894d371549450dab994e72c2435690ee3af0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 14 Nov 2009 16:32:32 -0800 Subject: Add in proper template variables to support pagination. --- modules/search/controllers/search.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules') diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index 08128ae8..cf9e271f 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -30,7 +30,12 @@ class Search_Controller extends Controller { } list ($count, $result) = search::search($q, $page_size, $offset); + + $max_pages = max(ceil($count / $page_size), 1); + $template = new Theme_View("page.html", "search"); + $template->set_global("page", $page); + $template->set_global("max_pages", $max_pages); $template->set_global("page_size", $page_size); $template->set_global("children_count", $count); -- cgit v1.2.3 From aa1ddba15517d99e4e34d9454fe4853339b17f58 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 14 Nov 2009 16:36:25 -0800 Subject: Oops. Fix a typo that the forced page_type to always be "tag" --- modules/gallery/libraries/Theme_View.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 5b7378b6..b5546a43 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -148,7 +148,7 @@ class Theme_View_Core extends Gallery_View { $v->next_page_url = null; $v->last_page_url = null; - if ($this->page_type == "album" || $this->page_type = "tag") { + if ($this->page_type == "album" || $this->page_type == "tag") { $v->page = $this->page; $v->max_pages = $this->max_pages; $v->total = $this->children_count; -- cgit v1.2.3