forked from Public/pics
PhotoPage: make prev/next photo logic more direct
This commit is contained in:
@@ -10,24 +10,13 @@ class PhotoPage extends Template
|
||||
{
|
||||
protected $photo;
|
||||
private $exif;
|
||||
private $previous_photo_url = '';
|
||||
private $next_photo_url = '';
|
||||
private $tag;
|
||||
|
||||
public function __construct(Image $photo)
|
||||
{
|
||||
$this->photo = $photo;
|
||||
}
|
||||
|
||||
public function setPreviousPhotoUrl($url)
|
||||
{
|
||||
$this->previous_photo_url = $url;
|
||||
}
|
||||
|
||||
public function setNextPhotoUrl($url)
|
||||
{
|
||||
$this->next_photo_url = $url;
|
||||
}
|
||||
|
||||
public function html_main()
|
||||
{
|
||||
$this->photoNav();
|
||||
@@ -86,18 +75,23 @@ class PhotoPage extends Template
|
||||
</a>';
|
||||
}
|
||||
|
||||
public function setTag(Tag $tag)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
}
|
||||
|
||||
private function photoNav()
|
||||
{
|
||||
if ($this->previous_photo_url)
|
||||
if ($previousUrl = $this->photo->getUrlForPreviousInSet($this->tag))
|
||||
echo '
|
||||
<a href="', $this->previous_photo_url, '#photo_frame" id="previous_photo"><i class="bi bi-arrow-left"></i></a>';
|
||||
<a href="', $previousUrl, '#photo_frame" id="previous_photo"><i class="bi bi-arrow-left"></i></a>';
|
||||
else
|
||||
echo '
|
||||
<span id="previous_photo"><i class="bi bi-arrow-left"></i></span>';
|
||||
|
||||
if ($this->next_photo_url)
|
||||
if ($nextUrl = $this->photo->getUrlForNextInSet($this->tag))
|
||||
echo '
|
||||
<a href="', $this->next_photo_url, '#photo_frame" id="next_photo"><i class="bi bi-arrow-right"></i></a>';
|
||||
<a href="', $nextUrl, '#photo_frame" id="next_photo"><i class="bi bi-arrow-right"></i></a>';
|
||||
else
|
||||
echo '
|
||||
<span id="next_photo"><i class="bi bi-arrow-right"></i></span>';
|
||||
|
||||
Reference in New Issue
Block a user