ViewPhotoAlbum: move some logic into new prepareHeaderBox method

This commit is contained in:
Aaron van Geffen 2024-01-14 20:22:23 +01:00
parent 64d1aadbdd
commit 08cdbfe7b6

View File

@ -26,23 +26,7 @@ class ViewPhotoAlbum extends HTMLController
$tag = Tag::fromSlug($_GET['tag']); $tag = Tag::fromSlug($_GET['tag']);
$id_tag = $tag->id_tag; $id_tag = $tag->id_tag;
$title = $tag->tag; $title = $tag->tag;
$description = !empty($tag->description) ? $tag->description : ''; $header_box = $this->getHeaderBox($tag);
// Can we go up a level?
if ($tag->id_parent != 0)
{
$ptag = Tag::fromId($tag->id_parent);
$back_link = BASEURL . '/' . (!empty($ptag->slug) ? $ptag->slug . '/' : '');
$back_link_title = 'Back to "' . $ptag->tag . '"';
}
elseif ($tag->kind === 'Person')
{
$back_link = BASEURL . '/people/';
$back_link_title = 'Back to "People"';
$is_person = true;
}
$header_box = new AlbumHeaderBox($title, $description, $back_link, $back_link_title);
} }
// View the album root. // View the album root.
else else
@ -198,6 +182,26 @@ class ViewPhotoAlbum extends HTMLController
return $buttons; return $buttons;
} }
private function getHeaderBox(Tag $tag)
{
// Can we go up a level?
if ($tag->id_parent != 0)
{
$ptag = Tag::fromId($tag->id_parent);
$back_link = BASEURL . '/' . (!empty($ptag->slug) ? $ptag->slug . '/' : '');
$back_link_title = 'Back to "' . $ptag->tag . '"';
}
elseif ($tag->kind === 'Person')
{
$back_link = BASEURL . '/people/';
$back_link_title = 'Back to "People"';
$is_person = true;
}
$description = !empty($tag->description) ? $tag->description : '';
return new AlbumHeaderBox($tag->tag, $description, $back_link, $back_link_title);
}
public function __destruct() public function __destruct()
{ {
if (isset($this->iterator)) if (isset($this->iterator))