diff options
-rw-r--r-- | core/controllers/photos.php | 23 | ||||
-rw-r--r-- | themes/default/views/pager.html.php | 2 | ||||
-rw-r--r-- | themes/default/views/photo.html.php | 11 |
3 files changed, 35 insertions, 1 deletions
diff --git a/core/controllers/photos.php b/core/controllers/photos.php index bb2a8510..82f9b779 100644 --- a/core/controllers/photos.php +++ b/core/controllers/photos.php @@ -25,11 +25,34 @@ class Photos_Controller extends Items_Controller { public function _show($photo) { access::required("view", $photo); + // We sort by id ascending so for now, find sibling info by doing id based queries. + $next_item = ORM::factory("item") + ->viewable() + ->where("parent_id", $photo->parent_id) + ->where("id >", $photo->id) + ->orderby("id", "ASC") + ->find(); + $previous_item = ORM::factory("item") + ->viewable() + ->where("parent_id", $photo->parent_id) + ->where("id <", $photo->id) + ->orderby("id", "DESC") + ->find(); + $position = ORM::factory("item") + ->viewable() + ->where("parent_id", $photo->parent_id) + ->where("id <=", $photo->id) + ->count_all(); + $template = new Theme_View("page.html", "photo"); $template->set_global("item", $photo); $template->set_global("children", array()); $template->set_global("children_count", $photo->children_count()); $template->set_global("parents", $photo->parents()); + $template->set_global("next_item", $next_item); + $template->set_global("previous_item", $previous_item); + $template->set_global("sibling_count", $photo->parent()->children_count()); + $template->set_global("position", $position); $template->content = new View("photo.html"); diff --git a/themes/default/views/pager.html.php b/themes/default/views/pager.html.php index 76cb35cd..b9dbc2e8 100644 --- a/themes/default/views/pager.html.php +++ b/themes/default/views/pager.html.php @@ -1,7 +1,7 @@ <? defined("SYSPATH") or die("No direct script access."); ?> <? // See http://docs.kohanaphp.com/libraries/pagination ?> <ul id="gPager"> - <li><?= sprintf(_("Items %d - %d of %d"), $current_first_item, $current_last_item, $total_items) ?></li> + <li><?= sprintf(_("Photos %d - %d of %d"), $current_first_item, $current_last_item, $total_items) ?></li> <? if ($first_page): ?> <li class="first"><a href="<?= str_replace('{page}', 1, $url) ?>"><?= _("first") ?></a></li> <? else: ?> diff --git a/themes/default/views/photo.html.php b/themes/default/views/photo.html.php index 7cfe542a..88047381 100644 --- a/themes/default/views/photo.html.php +++ b/themes/default/views/photo.html.php @@ -12,3 +12,14 @@ <?= $theme->photo_bottom() ?> </div> + +<? if ($position > 1): ?> +<a href="<?= url::site("{$previous_item->type}s/$previous_item->id") ?>"><?= _("previous") ?></a> +<? endif ?> +<?= sprintf(_("Viewing photo %d of %d"), $position, $sibling_count) ?> + +<? if ($position < $sibling_count): ?> +<a href="<?= url::site("{$next_item->type}s/$next_item->id") ?>"><?= _("next") ?></a> +<? endif ?> + + |