AzuraCast/templates/partials/sidebar_menu.phtml

88 lines
3.4 KiB
PHTML

<?php
/**
* @var array $menu
* @var string $active
* @var \App\Http\Router $router
* @var \App\View\GlobalSections $sections
*/
$active ??= null;
$sections->appendStart('bodyjs');
?>
<script>
$(function () {
$('.navdrawer-nav a[title]').tooltip({
'html': true,
'placement': 'right',
'boundary': 'viewport'
});
});
</script>
<?php
$sections->end();
?>
<ul class="navdrawer-nav">
<?php
foreach ($menu as $category_id => $category): ?>
<li class="nav-item">
<a class="nav-link <?= ($category['class'] ?? '') ?> <?php
if ($active === $category_id): ?>active<?php
endif; ?>"
<?php
if (empty($category['items'])): ?>href="<?= $category['url'] ?>" <?php
else: ?>data-toggle="collapse" href="#sidebar-submenu-<?= $category_id ?>"<?php
endif; ?>
<?php
if ($category['external'] ?? false): ?>target="_blank"<?php
endif; ?>
<?php
if (isset($category['confirm'])): ?>data-confirm-title="<?= $this->e($category['confirm']) ?>"<?php
endif; ?>
<?php
if (isset($category['title'])): ?>title="<?= $this->e($category['title']) ?>"<?php
endif; ?>>
<i class="navdrawer-nav-icon material-icons" aria-hidden="true"><?=$category['icon']?></i>
<?=$category['label']?>
<?php
if ($category['external'] ?? false): ?>
<i class="material-icons sm">open_in_new</i>
<?php
endif; ?>
</a>
<?php
if (!empty($category['items'])): ?>
<div class="collapse pb-2" id="sidebar-submenu-<?=$category_id?>">
<ul class="navdrawer-nav">
<?php
foreach ($category['items'] as $item_id => $item): ?>
<li class="nav-item">
<a class="nav-link pl-4 py-2 <?= ($item['class'] ?? '') ?>"
href="<?= $item['url'] ?>"
<?php
if ($item['external'] ?? false): ?>target="_blank"<?php
endif; ?>
<?php
if (isset($item['confirm'])): ?>data-confirm-title="<?= $this->e(
$item['confirm']
) ?>"<?php
endif; ?>
<?php
if (isset($item['title'])): ?>title="<?= $this->e($item['title']) ?>"<?php
endif; ?>>
<?= $item['label'] ?>
<?php
if ($item['external'] ?? false): ?>
<i class="material-icons sm">open_in_new</i>
<?php
endif; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>