2016-09-01 23:13:23 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* AlbumIndex.php
|
|
|
|
* Contains the album index template.
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
class AlbumIndex extends SubTemplate
|
|
|
|
{
|
|
|
|
protected $albums;
|
|
|
|
protected $show_edit_buttons;
|
|
|
|
protected $show_labels;
|
|
|
|
protected $row_limit = 1000;
|
|
|
|
|
|
|
|
const TILE_WIDTH = 400;
|
2017-11-09 15:57:16 +01:00
|
|
|
const TILE_HEIGHT = 300;
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
public function __construct(array $albums, $show_edit_buttons = false, $show_labels = true)
|
|
|
|
{
|
|
|
|
$this->albums = $albums;
|
|
|
|
$this->show_edit_buttons = $show_edit_buttons;
|
|
|
|
$this->show_labels = $show_labels;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function html_content()
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div class="tiled_grid">';
|
|
|
|
|
|
|
|
foreach (array_chunk($this->albums, 3) as $photos)
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div class="tiled_row">';
|
|
|
|
|
|
|
|
foreach ($photos as $album)
|
|
|
|
{
|
|
|
|
echo '
|
2019-09-29 14:16:50 +02:00
|
|
|
<div class="landscape">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
if ($this->show_edit_buttons)
|
|
|
|
echo '
|
|
|
|
<a class="edit" href="#">Edit</a>';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<a href="', $album['link'], '">';
|
|
|
|
|
|
|
|
if (isset($album['thumbnail']))
|
2023-01-01 19:37:22 +01:00
|
|
|
{
|
|
|
|
$thumbs = [];
|
|
|
|
foreach ([1, 2] as $factor)
|
|
|
|
$thumbs[$factor] = $album['thumbnail']->getThumbnailUrl(
|
|
|
|
static::TILE_WIDTH * $factor, static::TILE_HEIGHT * $factor, true, true);
|
|
|
|
|
2016-09-01 23:13:23 +02:00
|
|
|
echo '
|
2023-01-01 19:37:22 +01:00
|
|
|
<img src="', $thumbs[1], '"' . (isset($thumbs[2]) ?
|
|
|
|
' srcset="' . $thumbs[2] . ' 2x"' : '') .
|
|
|
|
' alt="">';
|
|
|
|
}
|
2016-09-01 23:13:23 +02:00
|
|
|
else
|
|
|
|
echo '
|
|
|
|
<img src="', BASEURL, '/images/nothumb.png" alt="">';
|
|
|
|
|
|
|
|
if ($this->show_labels)
|
|
|
|
echo '
|
|
|
|
<h4>', $album['caption'], '</h4>';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</a>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
}
|