pics/templates/AlbumButtonBox.php

68 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
/*****************************************************************************
* AlbumButtonBox.php
* Defines the AlbumButtonBox template.
*
* Kabuki CMS (C) 2013-2016, Aaron van Geffen
*****************************************************************************/
class AlbumButtonBox extends Template
{
private $active_filter;
private $buttons;
private $filters;
public function __construct(array $buttons, array $filters, $active_filter)
{
$this->active_filter = $active_filter;
$this->buttons = $buttons;
$this->filters = $filters;
}
public function html_main()
{
echo '
<div class="album_button_box">';
foreach ($this->buttons as $button)
echo '
<a class="btn btn-light" href="', $button['url'], '">', $button['caption'], '</a>';
if (!empty($this->filters))
{
echo '
<div class="dropdown">
<button class="btn btn-light dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
<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 '
</button>
<ul class="dropdown-menu">';
foreach ($this->filters as $key => $filter)
{
$is_active = $key === $this->active_filter;
echo '
<li><a class="dropdown-item', $is_active ? ' active' : '',
'" href="', $filter['link'], '">',
$filter['caption'],
'</a></li>';
}
echo '
</ul>
</div>';
}
echo '
</div>';
}
}