Rework meta data display on photo page #45
@ -8,6 +8,8 @@
|
||||
|
||||
class ViewPhoto extends HTMLController
|
||||
{
|
||||
private Image $photo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Ensure we're logged in at this point.
|
||||
@ -19,22 +21,24 @@ class ViewPhoto extends HTMLController
|
||||
if (empty($photo))
|
||||
throw new NotFoundException();
|
||||
|
||||
$this->photo = $photo->getImage();
|
||||
|
||||
Session::resetSessionToken();
|
||||
|
||||
parent::__construct($photo->getTitle() . ' - ' . SITE_TITLE);
|
||||
parent::__construct($this->photo->getTitle() . ' - ' . SITE_TITLE);
|
||||
|
||||
if (!empty($_POST))
|
||||
$this->handleTagging($photo->getImage());
|
||||
$this->handleTagging();
|
||||
else
|
||||
$this->handleViewPhoto($photo);
|
||||
$this->handleViewPhoto();
|
||||
}
|
||||
|
||||
private function handleViewPhoto(Asset $photo)
|
||||
private function handleViewPhoto()
|
||||
{
|
||||
$page = new PhotoPage($photo->getImage());
|
||||
$page = new PhotoPage($this->photo);
|
||||
|
||||
// Exif data?
|
||||
$exif = EXIF::fromFile($photo->getFullPath());
|
||||
$exif = EXIF::fromFile($this->photo->getFullPath());
|
||||
if ($exif)
|
||||
$page->setExif($exif);
|
||||
|
||||
@ -44,10 +48,10 @@ class ViewPhoto extends HTMLController
|
||||
$page->setTag($tag);
|
||||
|
||||
$this->page->adopt($page);
|
||||
$this->page->setCanonicalUrl($photo->getPageUrl());
|
||||
$this->page->setCanonicalUrl($this->photo->getPageUrl());
|
||||
}
|
||||
|
||||
private function handleTagging(Image $photo)
|
||||
private function handleTagging()
|
||||
{
|
||||
header('Content-Type: text/json; charset=utf-8');
|
||||
|
||||
@ -61,7 +65,7 @@ class ViewPhoto extends HTMLController
|
||||
// We are!
|
||||
if (!isset($_POST['delete']))
|
||||
{
|
||||
$photo->linkTags([(int) $_POST['id_tag']]);
|
||||
$this->photo->linkTags([(int) $_POST['id_tag']]);
|
||||
echo json_encode(['success' => true]);
|
||||
exit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user