summaryrefslogtreecommitdiff
path: root/core/controllers
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2008-11-29 17:08:42 +0000
committerTim Almdal <tnalmdal@shaw.ca>2008-11-29 17:08:42 +0000
commit70de32ebb48df84080f180e41703bb0064093ba1 (patch)
tree4cd6981bc5d5662c9dfdf6849e7c14d2c9b9bcf9 /core/controllers
parent9b9bdce821e4f0dcbd5fec64c8447663a83cd820 (diff)
Insure that the page and offset refere to valid items
Diffstat (limited to 'core/controllers')
-rw-r--r--core/controllers/albums.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/controllers/albums.php b/core/controllers/albums.php
index 50317979..ec5466a6 100644
--- a/core/controllers/albums.php
+++ b/core/controllers/albums.php
@@ -33,8 +33,14 @@ class Albums_Controller extends Items_Controller {
$template->set_global('page_size', $page_size);
$template->set_global('item', $item);
- $template->set_global('children', $item->children($page_size, ($page - 1) * $page_size));
- $template->set_global('children_count', $item->children_count());
+
+ // Make sure that the page references a valid offset
+ $children_count = $item->children_count();
+ while (($offset = ($page - 1) * $page_size) > $children_count && $page != 1) {
+ $page--;
+ }
+ $template->set_global('children', $item->children($page_size, $offset));
+ $template->set_global('children_count', $children_count);
$template->set_global('parents', $item->parents());
$template->content = new View("album.html");