forked from Public/pics
ViewPhotoAlbum: move some logic into new prepareHeaderBox method
This commit is contained in:
parent
64d1aadbdd
commit
08cdbfe7b6
@ -26,23 +26,7 @@ class ViewPhotoAlbum extends HTMLController
|
||||
$tag = Tag::fromSlug($_GET['tag']);
|
||||
$id_tag = $tag->id_tag;
|
||||
$title = $tag->tag;
|
||||
$description = !empty($tag->description) ? $tag->description : '';
|
||||
|
||||
// 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);
|
||||
$header_box = $this->getHeaderBox($tag);
|
||||
}
|
||||
// View the album root.
|
||||
else
|
||||
@ -198,6 +182,26 @@ class ViewPhotoAlbum extends HTMLController
|
||||
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()
|
||||
{
|
||||
if (isset($this->iterator))
|
||||
|
Loading…
Reference in New Issue
Block a user