Implement navigation for photo pages.

This commit is contained in:
2016-09-04 16:00:39 +02:00
parent 67a182671f
commit c11c5c2677
5 changed files with 109 additions and 6 deletions

View File

@@ -22,6 +22,20 @@ class ViewPhoto extends HTMLController
if ($exif)
$page->setExif($exif);
// What tag are we browsing?
$tag = isset($_GET['in']) ? Tag::fromId($_GET['in']) : null;
$id_tag = isset($tag) ? $tag->id_tag : null;
// Find previous photo in set.
$previous_url = $photo->getUrlForPreviousInSet($id_tag);
if ($previous_url)
$page->setPreviousPhotoUrl($previous_url);
// ... and the next photo, too.
$next_url = $photo->getUrlForNextInSet($id_tag);
if ($next_url)
$page->setNextPhotoUrl($next_url);
$this->page->adopt($page);
$this->page->setCanonicalUrl($photo->getPageUrl());

View File

@@ -79,7 +79,12 @@ class ViewPhotoAlbum extends HTMLController
// Load a photo mosaic for the current tag.
list($mosaic, $total_count) = $this->getPhotoMosaic($id_tag, $page);
if (isset($mosaic))
$this->page->adopt(new PhotosIndex($mosaic, Registry::get('user')->isAdmin()));
{
$index = new PhotosIndex($mosaic, Registry::get('user')->isAdmin());
$this->page->adopt($index);
if ($id_tag > 1)
$index->setUrlSuffix('?in=' . $id_tag);
}
// Make a page index as needed, while we're at it.
if ($total_count > self::PER_PAGE)