2016-09-04 14:49:13 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* AlbumButtonBox.php
|
|
|
|
* Defines the AlbumButtonBox template.
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2016, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2023-03-11 13:37:59 +01:00
|
|
|
class AlbumButtonBox extends Template
|
2016-09-04 14:49:13 +02:00
|
|
|
{
|
2024-01-14 21:28:45 +01:00
|
|
|
private $active_filter;
|
2022-12-25 13:50:33 +01:00
|
|
|
private $buttons;
|
2024-01-14 21:28:45 +01:00
|
|
|
private $filters;
|
2022-12-25 13:50:33 +01:00
|
|
|
|
2024-01-14 21:28:45 +01:00
|
|
|
public function __construct(array $buttons, array $filters, $active_filter)
|
2016-09-04 14:49:13 +02:00
|
|
|
{
|
2024-01-14 21:28:45 +01:00
|
|
|
$this->active_filter = $active_filter;
|
2016-09-04 14:49:13 +02:00
|
|
|
$this->buttons = $buttons;
|
2024-01-14 21:28:45 +01:00
|
|
|
$this->filters = $filters;
|
2016-09-04 14:49:13 +02:00
|
|
|
}
|
|
|
|
|
2023-03-11 13:37:59 +01:00
|
|
|
public function html_main()
|
2016-09-04 14:49:13 +02:00
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div class="album_button_box">';
|
|
|
|
|
|
|
|
foreach ($this->buttons as $button)
|
|
|
|
echo '
|
2023-03-11 13:51:12 +01:00
|
|
|
<a class="btn btn-light" href="', $button['url'], '">', $button['caption'], '</a>';
|
2016-09-04 14:49:13 +02:00
|
|
|
|
2024-01-14 22:17:09 +01:00
|
|
|
if (!empty($this->filters))
|
|
|
|
{
|
|
|
|
echo '
|
2024-01-14 21:28:45 +01:00
|
|
|
<div class="dropdown">
|
|
|
|
<button class="btn btn-light dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
2024-01-15 00:55:33 +01:00
|
|
|
<i class="bi bi-filter"></i>';
|
|
|
|
|
|
|
|
if ($this->active_filter)
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<span class="badge text-bg-danger">',
|
|
|
|
$this->filters[$this->active_filter]['label'], '</span>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2024-01-14 21:28:45 +01:00
|
|
|
</button>
|
|
|
|
<ul class="dropdown-menu">';
|
|
|
|
|
2024-01-14 22:17:09 +01:00
|
|
|
foreach ($this->filters as $key => $filter)
|
|
|
|
{
|
|
|
|
$is_active = $key === $this->active_filter;
|
|
|
|
echo '
|
2024-01-14 21:28:45 +01:00
|
|
|
<li><a class="dropdown-item', $is_active ? ' active' : '',
|
|
|
|
'" href="', $filter['link'], '">',
|
|
|
|
$filter['caption'],
|
|
|
|
'</a></li>';
|
2024-01-14 22:17:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</ul>
|
|
|
|
</div>';
|
2024-01-14 21:28:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2016-09-04 14:49:13 +02:00
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
}
|