summaryrefslogtreecommitdiff
path: root/modules/tag/controllers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-11-14 16:17:19 -0800
committerBharat Mediratta <bharat@menalto.com>2009-11-14 16:17:19 -0800
commit846f365db9d3c1b61ed4bd68316bd5e7b80e56ec (patch)
tree8dde35e3e121c0e48f1dd67432b01e44e7b2bdcc /modules/tag/controllers
parent9fd6a6f9058a89e60f83c6f2e89ae9e994c9e53a (diff)
Normalize tags a bit.
- Create Tag_Model::url() to mimic Item_Model::url() - Use the same pagination logic as we do for viewing items
Diffstat (limited to 'modules/tag/controllers')
-rw-r--r--modules/tag/controllers/tags.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index 1bd6b3cc..c3b14fcc 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -25,13 +25,18 @@ class Tags_Controller extends REST_Controller {
$page = (int) $this->input->get("page", "1");
$children_count = $tag->items_count();
$offset = ($page-1) * $page_size;
+ $max_pages = max(ceil($children_count / $page_size), 1);
// Make sure that the page references a valid offset
- if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) {
- Kohana::show_404();
+ if ($page < 1) {
+ url::redirect($album->abs_url());
+ } else if ($page > $max_pages) {
+ url::redirect($album->abs_url("page=$max_pages"));
}
$template = new Theme_View("page.html", "tag");
+ $template->set_global("page", $page);
+ $template->set_global("max_pages", $max_pages);
$template->set_global("page_size", $page_size);
$template->set_global("tag", $tag);
$template->set_global("children", $tag->items($page_size, $offset));