2016-09-03 21:32:55 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* PhotoPage.php
|
|
|
|
* Contains the photo page template.
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2016, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
class PhotoPage extends SubTemplate
|
|
|
|
{
|
|
|
|
private $photo;
|
|
|
|
private $exif;
|
2016-09-04 16:00:39 +02:00
|
|
|
private $previous_photo_url = '';
|
|
|
|
private $next_photo_url = '';
|
2016-09-03 21:32:55 +02:00
|
|
|
|
|
|
|
public function __construct(Image $photo)
|
|
|
|
{
|
|
|
|
$this->photo = $photo;
|
|
|
|
}
|
|
|
|
|
2016-09-04 16:00:39 +02:00
|
|
|
public function setPreviousPhotoUrl($url)
|
|
|
|
{
|
|
|
|
$this->previous_photo_url = $url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNextPhotoUrl($url)
|
|
|
|
{
|
|
|
|
$this->next_photo_url = $url;
|
|
|
|
}
|
|
|
|
|
2016-09-03 21:32:55 +02:00
|
|
|
protected function html_content()
|
|
|
|
{
|
|
|
|
$this->photoNav();
|
|
|
|
$this->photo();
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<div id="sub_photo">
|
|
|
|
<h2 class="entry-title">', $this->photo->getTitle(), '</h2>';
|
|
|
|
|
|
|
|
$this->taggedPeople();
|
2016-09-04 11:23:08 +02:00
|
|
|
$this->linkNewTags();
|
2016-09-03 21:32:55 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
$this->photoMeta();
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<script type="text/javascript" src="', BASEURL, '/js/photonav.js"></script>';
|
|
|
|
}
|
|
|
|
|
|
|
|
private function photo()
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div id="photo_frame">
|
|
|
|
<a href="', $this->photo->getUrl(), '">';
|
|
|
|
|
|
|
|
if ($this->photo->isPortrait())
|
|
|
|
echo '
|
|
|
|
<img src="', $this->photo->getThumbnailUrl(null, 960), '" alt="">';
|
|
|
|
else
|
|
|
|
echo '
|
|
|
|
<img src="', $this->photo->getThumbnailUrl(1280, null), '" alt="">';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</a>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
private function photoNav()
|
|
|
|
{
|
2016-09-04 16:00:39 +02:00
|
|
|
if ($this->previous_photo_url)
|
2016-09-03 21:32:55 +02:00
|
|
|
echo '
|
2016-09-04 16:00:39 +02:00
|
|
|
<a href="', $this->previous_photo_url, '" id="previous_photo"><em>Previous photo</em></a>';
|
2016-09-03 21:32:55 +02:00
|
|
|
else
|
|
|
|
echo '
|
|
|
|
<span id="previous_photo"><em>Previous photo</em></span>';
|
|
|
|
|
2016-09-04 16:00:39 +02:00
|
|
|
if ($this->next_photo_url)
|
2016-09-03 21:32:55 +02:00
|
|
|
echo '
|
2016-09-04 16:00:39 +02:00
|
|
|
<a href="', $this->next_photo_url, '" id="next_photo"><em>Next photo</em></a>';
|
2016-09-03 21:32:55 +02:00
|
|
|
else
|
|
|
|
echo '
|
|
|
|
<span id="next_photo"><em>Next photo</em></span>';
|
|
|
|
}
|
|
|
|
|
|
|
|
private function photoMeta()
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div id="photo_exif_box">
|
|
|
|
<h3>EXIF</h3>
|
|
|
|
<dl class="photo_meta">';
|
|
|
|
|
|
|
|
if (!empty($this->exif->created_timestamp))
|
|
|
|
echo '
|
|
|
|
<dt>Date Taken</dt>
|
|
|
|
<dd>', date("j M Y, H:i:s", $this->exif->created_timestamp), '</dd>';
|
|
|
|
|
2016-09-04 21:34:08 +02:00
|
|
|
echo '
|
|
|
|
<dt>Uploaded by</dt>
|
|
|
|
<dd>', $this->photo->getAuthor()->getfullName(), '</dd>';
|
|
|
|
|
2016-09-03 21:32:55 +02:00
|
|
|
if (!empty($this->exif->camera))
|
|
|
|
echo '
|
2016-09-04 21:34:08 +02:00
|
|
|
<dt>Camera Model</dt>
|
2016-09-03 21:32:55 +02:00
|
|
|
<dd>', $this->exif->camera, '</dd>';
|
|
|
|
|
|
|
|
if (!empty($this->exif->shutter_speed))
|
|
|
|
echo '
|
|
|
|
<dt>Shutter Speed</dt>
|
|
|
|
<dd>', $this->exif->shutterSpeedFraction(), '</dd>';
|
|
|
|
|
|
|
|
if (!empty($this->exif->aperture))
|
|
|
|
echo '
|
|
|
|
<dt>Aperture</dt>
|
|
|
|
<dd>f/', number_format($this->exif->aperture, 1), '</dd>';
|
|
|
|
|
|
|
|
if (!empty($this->exif->focal_length))
|
|
|
|
echo '
|
|
|
|
<dt>Focal Length</dt>
|
|
|
|
<dd>', $this->exif->focal_length, ' mm</dd>';
|
|
|
|
|
|
|
|
if (!empty($this->exif->iso))
|
|
|
|
echo '
|
|
|
|
<dt>ISO Speed</dt>
|
|
|
|
<dd>', $this->exif->iso, '</dd>';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</dl>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
private function taggedPeople()
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<h3>Tags</h3>
|
|
|
|
<ul>';
|
|
|
|
|
|
|
|
foreach ($this->photo->getTags() as $tag)
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<li>
|
|
|
|
<a rel="tag" title="View all posts tagged ', $tag->tag, '" href="', $tag->getUrl(), '" class="entry-tag">', $tag->tag, '</a>
|
|
|
|
</li>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</ul>';
|
|
|
|
}
|
|
|
|
|
2016-09-04 11:23:08 +02:00
|
|
|
private function linkNewTags()
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div>
|
|
|
|
<h3>Link tags</h3>
|
|
|
|
<ul id="tag_list">
|
|
|
|
<li id="new_tag_container"><input type="text" id="new_tag" placeholder="Type to link a new tag"></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<script type="text/javascript" src="', BASEURL, '/js/ajax.js"></script>
|
|
|
|
<script type="text/javascript" src="', BASEURL, '/js/autosuggest.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
setTimeout(function() {
|
|
|
|
var tag_autosuggest = new TagAutoSuggest({
|
|
|
|
inputElement: "new_tag",
|
|
|
|
listElement: "tag_list",
|
|
|
|
baseUrl: "', BASEURL, '",
|
|
|
|
appendCallback: function(item) {
|
|
|
|
if (document.getElementById("linked_tag_" + item.id_tag)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var newCheck = document.createElement("input");
|
|
|
|
newCheck.type = "checkbox";
|
|
|
|
newCheck.name = "tag[" + item.id_tag + "]";
|
|
|
|
newCheck.id = "linked_tag_" + item.id_tag;
|
|
|
|
newCheck.title = "Uncheck to delete";
|
|
|
|
newCheck.checked = "checked";
|
|
|
|
|
|
|
|
var newNode = document.createElement("li");
|
|
|
|
newNode.appendChild(newCheck);
|
|
|
|
|
|
|
|
var newLabel = document.createTextNode(item.label);
|
|
|
|
newNode.appendChild(newLabel);
|
|
|
|
|
|
|
|
var list = document.getElementById("tag_list");
|
|
|
|
var input = document.getElementById("new_tag_container");
|
|
|
|
list.insertBefore(newNode, input);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, 100);
|
|
|
|
</script>';
|
|
|
|
}
|
|
|
|
|
2016-09-03 21:32:55 +02:00
|
|
|
public function setExif(EXIF $exif)
|
|
|
|
{
|
|
|
|
$this->exif = $exif;
|
|
|
|
}
|
|
|
|
}
|