diff options
| author | Chad Kieffer <ckieffer@gmail.com> | 2009-06-06 00:35:39 -0600 |
|---|---|---|
| committer | Chad Kieffer <ckieffer@gmail.com> | 2009-06-06 00:35:39 -0600 |
| commit | 7cdcb5179f6d5414c9224fb65b7b36ab69ba52da (patch) | |
| tree | ffc78236234505ca953870dc68ffb76fe0cae872 /modules/gallery/controllers | |
| parent | c5425f42a4a13f7f585ffe45c070a865cdef6077 (diff) | |
| parent | 329bd8caa126040ba7abaf28e8f76e0b6739ceff (diff) | |
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules/gallery/controllers')
| -rw-r--r-- | modules/gallery/controllers/photos.php | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 2de51bc7..f5be5d59 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -25,32 +25,22 @@ 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(); + $position = $photo->parent()->get_position($photo->id); + if ($position > 1) { + list ($previous_item, $ignore, $next_item) = + $photo->parent()->children(3, $position - 2); + } else { + $previous_item = null; + list ($next_item) = $photo->parent()->children(1, $position); + } $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->loaded ? $next_item : null); - $template->set_global("previous_item", $previous_item->loaded ? $previous_item : null); + $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); |
