2016-09-01 23:13:23 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* PhotosIndex.php
|
|
|
|
* Contains the project index template.
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2023-03-11 13:37:59 +01:00
|
|
|
class PhotosIndex extends Template
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
protected $mosaic;
|
|
|
|
protected $show_edit_buttons;
|
2022-12-25 13:50:33 +01:00
|
|
|
protected $show_headers;
|
2016-09-01 23:13:23 +02:00
|
|
|
protected $show_labels;
|
|
|
|
protected $previous_header = '';
|
2016-09-04 16:00:39 +02:00
|
|
|
protected $url_suffix;
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-12-23 16:22:48 +01:00
|
|
|
const PANORAMA_WIDTH = 1256;
|
2016-09-01 23:13:23 +02:00
|
|
|
const PANORAMA_HEIGHT = null;
|
|
|
|
|
2023-12-23 16:22:48 +01:00
|
|
|
const PORTRAIT_WIDTH = 387;
|
|
|
|
const PORTRAIT_HEIGHT = 628;
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-12-23 16:22:48 +01:00
|
|
|
const LANDSCAPE_WIDTH = 822;
|
|
|
|
const LANDSCAPE_HEIGHT = 628;
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-12-23 16:22:48 +01:00
|
|
|
const DUO_WIDTH = 604;
|
|
|
|
const DUO_HEIGHT = 403;
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
const SINGLE_WIDTH = 618;
|
|
|
|
const SINGLE_HEIGHT = 412;
|
|
|
|
|
2023-12-23 16:22:48 +01:00
|
|
|
const TILE_WIDTH = 387;
|
|
|
|
const TILE_HEIGHT = 290;
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2017-11-09 15:55:23 +01:00
|
|
|
public function __construct(PhotoMosaic $mosaic, $show_edit_buttons = false, $show_labels = false, $show_headers = true)
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
$this->mosaic = $mosaic;
|
|
|
|
$this->show_edit_buttons = $show_edit_buttons;
|
|
|
|
$this->show_headers = $show_headers;
|
|
|
|
$this->show_labels = $show_labels;
|
|
|
|
}
|
|
|
|
|
2023-03-11 13:37:59 +01:00
|
|
|
public function html_main()
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
echo '
|
2023-04-01 14:29:14 +02:00
|
|
|
<div class="container photo-index">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-12-02 00:24:47 +01:00
|
|
|
$i = 0;
|
|
|
|
while ($row = $this->mosaic->getRow())
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
2023-12-02 00:24:47 +01:00
|
|
|
[$photos, $what] = $row;
|
2016-09-01 23:13:23 +02:00
|
|
|
$this->header($photos);
|
2023-12-02 00:24:47 +01:00
|
|
|
$this->$what($photos, ($i++) % 2);
|
2016-09-01 23:13:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2016-09-03 21:33:48 +02:00
|
|
|
</div>
|
|
|
|
<script type="text/javascript" src="', BASEURL, '/js/albumnav.js"></script>';
|
2016-09-01 23:13:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function header($photos)
|
|
|
|
{
|
|
|
|
if (!$this->show_headers)
|
|
|
|
return;
|
|
|
|
|
|
|
|
$date = $photos[0]->getDateCaptured();
|
|
|
|
if (!$date)
|
|
|
|
return;
|
|
|
|
|
|
|
|
$header = $date->format('F Y');
|
|
|
|
if ($header === $this->previous_header)
|
|
|
|
return;
|
|
|
|
|
|
|
|
$name = str_replace(' ', '', strtolower($header));
|
|
|
|
echo '
|
2023-04-01 14:29:14 +02:00
|
|
|
<h4 class="tiled-header" id="', $name, '">
|
|
|
|
<a href="#', $name, '">', $header, '</a>
|
|
|
|
</h4>';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
$this->previous_header = $header;
|
|
|
|
}
|
|
|
|
|
2019-09-29 14:12:30 +02:00
|
|
|
protected function photo(Image $image, $className, $width, $height, $crop = true, $fit = true)
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
2023-11-10 21:57:23 +01:00
|
|
|
// Prefer thumbnail aspect ratio if available, otherwise use image aspect ratio.
|
|
|
|
$aspectRatio = isset($width, $height) ? $width / $height : $image->ratio();
|
|
|
|
|
2019-09-29 14:12:30 +02:00
|
|
|
echo '
|
2023-11-10 21:57:23 +01:00
|
|
|
<div class="polaroid ', $className, '" style="aspect-ratio: ', $aspectRatio, '">';
|
2019-09-29 14:12:30 +02:00
|
|
|
|
2016-09-01 23:13:23 +02:00
|
|
|
if ($this->show_edit_buttons)
|
|
|
|
echo '
|
|
|
|
<a class="edit" href="', BASEURL, '/editasset/?id=', $image->getId(), '">Edit</a>';
|
|
|
|
|
|
|
|
echo '
|
2023-11-10 21:57:23 +01:00
|
|
|
<a href="', $image->getPageUrl(), $this->url_suffix, '#photo_frame">';
|
2022-07-08 23:53:28 +02:00
|
|
|
|
|
|
|
|
2023-11-10 21:57:23 +01:00
|
|
|
foreach (['normal-photo', 'blur-photo'] as $className)
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<img src="', $image->getThumbnailUrl($width, $height, $crop, $fit), '"';
|
2023-04-01 14:29:14 +02:00
|
|
|
|
2023-11-10 21:57:23 +01:00
|
|
|
// Can we offer double-density thumbs?
|
|
|
|
if ($image->width() >= $width * 2 && $image->height() >= $height * 2)
|
|
|
|
echo ' srcset="', $image->getThumbnailUrl($width * 2, $height * 2, $crop, $fit), ' 2x"';
|
|
|
|
else
|
|
|
|
echo ' srcset="', $image->getThumbnailUrl($image->width(), $image->height(), true), ' 2x"';
|
|
|
|
|
|
|
|
echo ' alt="" title="', $image->getTitle(), '" class="', $className, '" style="aspect-ratio: ', $aspectRatio, '">';
|
|
|
|
}
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
if ($this->show_labels)
|
|
|
|
echo '
|
|
|
|
<h4>', $image->getTitle(), '</h4>';
|
|
|
|
|
|
|
|
echo '
|
2019-09-29 14:12:30 +02:00
|
|
|
|
|
|
|
</a>
|
|
|
|
</div>';
|
2016-09-01 23:13:23 +02:00
|
|
|
}
|
|
|
|
|
2023-04-01 14:53:40 +02:00
|
|
|
protected function panorama(array $photos, $altLayout)
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
foreach ($photos as $image)
|
2023-04-01 14:29:14 +02:00
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div class="row mb-5 tile-panorama">
|
|
|
|
<div class="col">';
|
|
|
|
|
2019-09-29 14:12:30 +02:00
|
|
|
$this->photo($image, 'panorama', static::PANORAMA_WIDTH, static::PANORAMA_HEIGHT, false, false);
|
2023-04-01 14:29:14 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
}
|
2016-09-01 23:13:23 +02:00
|
|
|
}
|
|
|
|
|
2023-12-02 01:29:11 +01:00
|
|
|
protected function sixLandscapes(array $photos, $altLayout)
|
|
|
|
{
|
|
|
|
$chunks = array_chunk($photos, 3);
|
|
|
|
$this->sideLandscape($chunks[0], $altLayout);
|
|
|
|
$this->threeLandscapes($chunks[1], $altLayout);
|
|
|
|
}
|
|
|
|
|
2023-12-02 00:50:04 +01:00
|
|
|
protected function sidePortrait(array $photos, $altLayout)
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
$image = array_shift($photos);
|
|
|
|
|
|
|
|
echo '
|
2023-04-01 14:53:40 +02:00
|
|
|
<div class="row g-5 mb-5 tile-feat-portrait',
|
|
|
|
$altLayout ? ' flex-row-reverse' : '', '">
|
2023-04-01 14:29:14 +02:00
|
|
|
<div class="col-md-4">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2019-09-29 14:12:30 +02:00
|
|
|
$this->photo($image, 'portrait', static::PORTRAIT_WIDTH, static::PORTRAIT_HEIGHT, 'centre');
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>
|
2023-04-01 14:29:14 +02:00
|
|
|
<div class="col-md-8">
|
|
|
|
<div class="row g-5">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
foreach ($photos as $image)
|
2023-04-01 14:29:14 +02:00
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div class="col-md-6">';
|
|
|
|
|
|
|
|
$this->photo($image, 'landscape', static::TILE_WIDTH, static::TILE_HEIGHT, 'top');
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
echo '
|
2023-04-01 14:29:14 +02:00
|
|
|
</div>
|
2016-09-01 23:13:23 +02:00
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2023-12-02 00:50:04 +01:00
|
|
|
protected function sideLandscape(array $photos, $altLayout)
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
$image = array_shift($photos);
|
|
|
|
|
|
|
|
echo '
|
2023-04-01 14:53:40 +02:00
|
|
|
<div class="row g-5 mb-5 tile-feat-landscape',
|
|
|
|
$altLayout ? ' flex-row-reverse' : '', '">
|
2023-04-01 14:29:14 +02:00
|
|
|
<div class="col-md-8">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2019-09-29 14:12:30 +02:00
|
|
|
$this->photo($image, 'landscape', static::LANDSCAPE_WIDTH, static::LANDSCAPE_HEIGHT, 'top');
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>
|
2023-04-01 14:29:14 +02:00
|
|
|
<div class="col-md-4">
|
|
|
|
<div class="row g-5">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
foreach ($photos as $image)
|
2023-04-01 14:29:14 +02:00
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div>';
|
|
|
|
|
2019-09-29 14:12:30 +02:00
|
|
|
$this->photo($image, 'landscape', static::TILE_WIDTH, static::TILE_HEIGHT, 'top');
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-04-01 14:29:14 +02:00
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2016-09-01 23:13:23 +02:00
|
|
|
echo '
|
2023-04-01 14:29:14 +02:00
|
|
|
</div>
|
2016-09-01 23:13:23 +02:00
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2023-12-02 00:50:04 +01:00
|
|
|
protected function threeLandscapes(array $photos, $altLayout)
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
echo '
|
2023-12-02 00:50:04 +01:00
|
|
|
<div class="row g-5 mb-5 tile-row-landscapes">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
foreach ($photos as $image)
|
2023-04-01 14:29:14 +02:00
|
|
|
{
|
|
|
|
echo '
|
2023-12-02 00:50:04 +01:00
|
|
|
<div class="col-md-4">';
|
2023-04-01 14:29:14 +02:00
|
|
|
|
2023-12-02 00:50:04 +01:00
|
|
|
$this->photo($image, 'landscape', static::TILE_WIDTH, static::TILE_HEIGHT, true);
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-04-01 14:29:14 +02:00
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2016-09-01 23:13:23 +02:00
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2023-12-02 00:50:04 +01:00
|
|
|
protected function threePortraits(array $photos, $altLayout)
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
echo '
|
2023-12-02 00:50:04 +01:00
|
|
|
<div class="row g-5 mb-5 tile-row-portraits">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
foreach ($photos as $image)
|
2023-04-01 14:29:14 +02:00
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div class="col-md-4">';
|
|
|
|
|
2023-12-02 00:50:04 +01:00
|
|
|
$this->photo($image, 'portrait', static::PORTRAIT_WIDTH, static::PORTRAIT_HEIGHT, true);
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-04-01 14:29:14 +02:00
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2016-09-01 23:13:23 +02:00
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
2016-09-02 20:23:47 +02:00
|
|
|
|
2023-12-02 00:50:04 +01:00
|
|
|
protected function dualLandscapes(array $photos, $altLayout)
|
2016-09-02 20:23:47 +02:00
|
|
|
{
|
|
|
|
echo '
|
2023-12-02 00:50:04 +01:00
|
|
|
<div class="row g-5 mb-5 tile-duo">';
|
2016-09-02 20:23:47 +02:00
|
|
|
|
|
|
|
foreach ($photos as $image)
|
2023-04-01 14:29:14 +02:00
|
|
|
{
|
|
|
|
echo '
|
2023-12-02 00:50:04 +01:00
|
|
|
<div class="col-md-6">';
|
2023-04-01 14:29:14 +02:00
|
|
|
|
2023-12-02 00:50:04 +01:00
|
|
|
$this->photo($image, 'duo', static::DUO_WIDTH, static::DUO_HEIGHT, true);
|
2016-09-02 20:23:47 +02:00
|
|
|
|
2023-04-01 14:29:14 +02:00
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2016-09-02 20:23:47 +02:00
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
2016-09-04 16:00:39 +02:00
|
|
|
|
2023-12-19 22:42:30 +01:00
|
|
|
protected function dualMixed(array $photos, $altLayout)
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div class="row g-5 mb-5 tile-feat-landscape',
|
|
|
|
$altLayout ? ' flex-row-reverse' : '', '">
|
|
|
|
<div class="col-md-8">';
|
|
|
|
|
2023-12-23 13:47:16 +01:00
|
|
|
$image = array_shift($photos);
|
2023-12-19 22:42:30 +01:00
|
|
|
$this->photo($image, 'landscape', static::LANDSCAPE_WIDTH, static::LANDSCAPE_HEIGHT, 'top');
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
<div class="col-md-4">';
|
|
|
|
|
2023-12-23 13:47:16 +01:00
|
|
|
$image = array_shift($photos);
|
2023-12-19 22:42:30 +01:00
|
|
|
$this->photo($image, 'portrait', static::PORTRAIT_WIDTH, static::PORTRAIT_HEIGHT, true);
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2023-12-02 00:50:04 +01:00
|
|
|
protected function dualPortraits(array $photos, $altLayout)
|
|
|
|
{
|
|
|
|
// Recycle the row layout so portraits don't appear too large
|
|
|
|
$this->threePortraits($photos, $altLayout);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function singleLandscape(array $photos, $altLayout)
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div class="row g-5 mb-5 tile-single">
|
|
|
|
<div class="col-md-6">';
|
|
|
|
|
|
|
|
$image = array_shift($photos);
|
|
|
|
$this->photo($image, 'single', static::SINGLE_WIDTH, static::SINGLE_HEIGHT, 'top');
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function singlePortrait(array $photos, $altLayout)
|
|
|
|
{
|
|
|
|
// Recycle the row layout so portraits don't appear too large
|
|
|
|
$this->threePortraits($photos, $altLayout);
|
|
|
|
}
|
|
|
|
|
2016-09-04 16:00:39 +02:00
|
|
|
public function setUrlSuffix($suffix)
|
|
|
|
{
|
|
|
|
$this->url_suffix = $suffix;
|
|
|
|
}
|
2016-09-01 23:13:23 +02:00
|
|
|
}
|