summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/controllers')
-rw-r--r--modules/gallery/controllers/albums.php24
-rw-r--r--modules/gallery/controllers/movies.php10
-rw-r--r--modules/gallery/controllers/photos.php10
3 files changed, 28 insertions, 16 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 9bf7b9bf..8aa3bb35 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -60,9 +60,6 @@ class Albums_Controller extends Items_Controller {
url::redirect($album->abs_url("page=$max_pages"));
}
- Display_Context::factory("item")
- ->save();
-
$template = new Theme_View("page.html", "collection", "album");
$template->set_global(
array("page" => $page,
@@ -75,10 +72,29 @@ class Albums_Controller extends Items_Controller {
"breadcrumbs" => Breadcrumb::array_from_item_parents($album),
"children_count" => $children_count));
$template->content = new View("album.html");
-
$album->increment_view_count();
print $template;
+ item::set_display_context_callback("Albums_Controller::get_display_context");
+ }
+
+ static function get_display_context($item) {
+ $where = array(array("type", "!=", "album"));
+ $position = item::get_position($item, $where);
+ if ($position > 1) {
+ list ($previous_item, $ignore, $next_item) =
+ $item->parent()->viewable()->children(3, $position - 2, $where);
+ } else {
+ $previous_item = null;
+ list ($next_item) = $item->parent()->viewable()->children(1, $position, $where);
+ }
+
+ return array("position" => $position,
+ "previous_item" => $previous_item,
+ "next_item" => $next_item,
+ "sibling_count" => $item->parent()->viewable()->children_count($where),
+ "parents" => $item->parents()->as_array(),
+ "breadcrumbs" => Breadcrumb::array_from_item_parents($item));
}
public function create($parent_id) {
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index bbf89f17..76263dc0 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -28,12 +28,10 @@ class Movies_Controller extends Items_Controller {
access::required("view", $movie);
$template = new Theme_View("page.html", "item", "movie");
- $template->set_global(
- array_merge(array("item" => $movie,
- "children" => array(),
- "children_count" => 0),
- Display_Context::factory()->display_context($movie)));
-
+ $template->set_global(array("item" => $movie,
+ "children" => array(),
+ "children_count" => 0));
+ $template->set_global(item::get_display_context($movie));
$template->content = new View("movie.html");
$movie->increment_view_count();
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 49bb5a25..7e78b205 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -28,12 +28,10 @@ class Photos_Controller extends Items_Controller {
access::required("view", $photo);
$template = new Theme_View("page.html", "item", "photo");
- $template->set_global(
- array_merge(array("item" => $photo,
- "children" => array(),
- "children_count" => 0),
- Display_Context::factory()->display_context($photo)));
-
+ $template->set_global(array("item" => $photo,
+ "children" => array(),
+ "children_count" => 0));
+ $template->set_global(item::get_display_context($photo));
$template->content = new View("photo.html");
$photo->increment_view_count();