ViewPhoto: take filter into account for prev/next links

This commit is contained in:
2024-01-15 00:43:02 +01:00
parent f33a7e397c
commit d8c3e76df6
4 changed files with 56 additions and 15 deletions

View File

@@ -46,6 +46,19 @@ class ViewPhoto extends HTMLController
if (isset($tag))
$page->setTag($tag);
// Keeping tabs on a filter?
if (isset($_GET['by']))
{
// Let's first verify that the filter is valid
$contributors = array_filter($tag->getContributorList(), fn($el) => $el['slug'] === $_GET['by']);
if (count($contributors) !== 1)
throw new UnexpectedValueException('Invalid filter for this album or tag.');
// Alright, let's run with it then
$filter = reset($contributors);
$page->setActiveFilter($filter['slug']);
}
$this->page->adopt($page);
$this->page->setCanonicalUrl($this->photo->getPageUrl());
}

View File

@@ -94,8 +94,15 @@ class ViewPhotoAlbum extends HTMLController
{
$index = new PhotosIndex($mosaic, Registry::get('user')->isAdmin());
$this->page->adopt($index);
if ($id_tag > 1)
$index->setUrlSuffix('?in=' . $id_tag);
$url_params = [];
if (isset($tag) && $tag->id_parent != 0)
$url_params['in'] = $tag->id_tag;
if (!empty($active_filter))
$url_params['by'] = $active_filter;
if (!empty($url_params))
$index->setUrlSuffix('?' . http_build_query($url_params));
}
// Make a page index as needed, while we're at it.