2016-09-03 21:32:55 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* ViewPhoto.php
|
|
|
|
* Contains the view photo controller
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2016, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
class ViewPhoto extends HTMLController
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
2016-09-04 16:17:02 +02:00
|
|
|
// Ensure we're logged in at this point.
|
|
|
|
if (!Registry::get('user')->isLoggedIn())
|
|
|
|
throw new NotAllowedException();
|
|
|
|
|
2016-09-03 21:32:55 +02:00
|
|
|
$photo = Asset::fromSlug($_GET['slug']);
|
|
|
|
if (empty($photo))
|
|
|
|
throw new NotFoundException();
|
|
|
|
|
|
|
|
parent::__construct($photo->getTitle() . ' - ' . SITE_TITLE);
|
|
|
|
$page = new PhotoPage($photo->getImage());
|
|
|
|
|
|
|
|
// Exif data?
|
|
|
|
$exif = EXIF::fromFile($photo->getFullPath());
|
|
|
|
if ($exif)
|
|
|
|
$page->setExif($exif);
|
|
|
|
|
2016-09-04 16:00:39 +02:00
|
|
|
// 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);
|
|
|
|
|
2016-09-03 21:32:55 +02:00
|
|
|
$this->page->adopt($page);
|
|
|
|
$this->page->setCanonicalUrl($photo->getPageUrl());
|
|
|
|
|
|
|
|
// Add an edit button to the admin bar.
|
|
|
|
if (Registry::get('user')->isAdmin())
|
|
|
|
$this->admin_bar->appendItem(BASEURL . '/editasset/?id=' . $photo->getId(), 'Edit this photo');
|
|
|
|
}
|
|
|
|
}
|