2016-09-01 23:13:23 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* AlbumIndex.php
|
|
|
|
* Contains the album index template.
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2023-03-11 13:37:59 +01:00
|
|
|
class AlbumIndex extends Template
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
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;
|
2023-04-01 14:02:58 +02:00
|
|
|
const TILE_RATIO = self::TILE_WIDTH / self::TILE_HEIGHT;
|
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;
|
|
|
|
}
|
|
|
|
|
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:02:58 +02:00
|
|
|
<div class="container album-index">
|
|
|
|
<div class="row g-5">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-04-01 14:02:58 +02:00
|
|
|
foreach ($this->albums as $album)
|
|
|
|
$this->renderAlbum($album);
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
}
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-04-01 14:02:58 +02:00
|
|
|
private function renderAlbum(array $album)
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div class="col-md-6 col-xl-4">
|
|
|
|
<div class="polaroid landscape">';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-04-01 14:02:58 +02:00
|
|
|
if ($this->show_edit_buttons)
|
|
|
|
echo '
|
2016-09-01 23:13:23 +02:00
|
|
|
<a class="edit" href="#">Edit</a>';
|
|
|
|
|
2023-04-01 14:02:58 +02:00
|
|
|
echo '
|
2016-09-01 23:13:23 +02:00
|
|
|
<a href="', $album['link'], '">';
|
|
|
|
|
2023-04-01 14:02:58 +02:00
|
|
|
if (isset($album['thumbnail']))
|
|
|
|
{
|
|
|
|
$thumbs = [];
|
|
|
|
foreach ([1, 2] as $factor)
|
|
|
|
$thumbs[$factor] = $album['thumbnail']->getThumbnailUrl(
|
|
|
|
static::TILE_WIDTH * $factor, static::TILE_HEIGHT * $factor, true, true);
|
2023-01-01 19:37:22 +01:00
|
|
|
|
2023-04-01 14:02:58 +02:00
|
|
|
echo '
|
|
|
|
<img alt="" src="', $thumbs[1], '"' . (isset($thumbs[2]) ?
|
2023-01-01 19:37:22 +01:00
|
|
|
' srcset="' . $thumbs[2] . ' 2x"' : '') .
|
2023-04-01 14:02:58 +02:00
|
|
|
' alt="" style="aspect-ratio: ', self::TILE_RATIO, '">';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<img alt="" src="', BASEURL, '/images/nothumb.svg"',
|
|
|
|
' style="aspect-ratio: ', self::TILE_RATIO, '; object-fit: unset">';
|
|
|
|
}
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2023-04-01 14:02:58 +02:00
|
|
|
if ($this->show_labels)
|
|
|
|
echo '
|
2016-09-01 23:13:23 +02:00
|
|
|
<h4>', $album['caption'], '</h4>';
|
|
|
|
|
2023-04-01 14:02:58 +02:00
|
|
|
echo '
|
2016-09-01 23:13:23 +02:00
|
|
|
</a>
|
2023-04-01 14:02:58 +02:00
|
|
|
</div>
|
2016-09-01 23:13:23 +02:00
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
}
|