ViewPhoto: use class state to store Image object
This commit is contained in:
parent
bc08e867f0
commit
55c33c024e
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
class ViewPhoto extends HTMLController
|
class ViewPhoto extends HTMLController
|
||||||
{
|
{
|
||||||
|
private Image $photo;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Ensure we're logged in at this point.
|
// Ensure we're logged in at this point.
|
||||||
@ -19,22 +21,24 @@ class ViewPhoto extends HTMLController
|
|||||||
if (empty($photo))
|
if (empty($photo))
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
|
|
||||||
|
$this->photo = $photo->getImage();
|
||||||
|
|
||||||
Session::resetSessionToken();
|
Session::resetSessionToken();
|
||||||
|
|
||||||
parent::__construct($photo->getTitle() . ' - ' . SITE_TITLE);
|
parent::__construct($this->photo->getTitle() . ' - ' . SITE_TITLE);
|
||||||
|
|
||||||
if (!empty($_POST))
|
if (!empty($_POST))
|
||||||
$this->handleTagging($photo->getImage());
|
$this->handleTagging();
|
||||||
else
|
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 data?
|
||||||
$exif = EXIF::fromFile($photo->getFullPath());
|
$exif = EXIF::fromFile($this->photo->getFullPath());
|
||||||
if ($exif)
|
if ($exif)
|
||||||
$page->setExif($exif);
|
$page->setExif($exif);
|
||||||
|
|
||||||
@ -44,10 +48,10 @@ class ViewPhoto extends HTMLController
|
|||||||
$page->setTag($tag);
|
$page->setTag($tag);
|
||||||
|
|
||||||
$this->page->adopt($page);
|
$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');
|
header('Content-Type: text/json; charset=utf-8');
|
||||||
|
|
||||||
@ -61,7 +65,7 @@ class ViewPhoto extends HTMLController
|
|||||||
// We are!
|
// We are!
|
||||||
if (!isset($_POST['delete']))
|
if (!isset($_POST['delete']))
|
||||||
{
|
{
|
||||||
$photo->linkTags([(int) $_POST['id_tag']]);
|
$this->photo->linkTags([(int) $_POST['id_tag']]);
|
||||||
echo json_encode(['success' => true]);
|
echo json_encode(['success' => true]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user