2023-10-10 15:55:39 +00:00
|
|
|
<nav class="flex flex-col flex-1 py-4 overflow-y-auto">
|
|
|
|
<?php foreach ($navigation as $section => $data):
|
2024-05-02 15:32:27 +00:00
|
|
|
if ($data['items'] === []) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-10-10 15:55:39 +00:00
|
|
|
$isSectionActive = false;
|
|
|
|
$activeItem = '';
|
|
|
|
foreach ($data['items'] as $item) {
|
2024-05-02 15:32:27 +00:00
|
|
|
$href = str_starts_with($item, '/') ? $item : route_to($item, $podcastId ?? null, $episodeId ?? null);
|
|
|
|
if (url_is($href)) {
|
2023-10-10 15:55:39 +00:00
|
|
|
$activeItem = $item;
|
|
|
|
$isSectionActive = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<details <?= $isSectionActive ? 'open="open"' : '' ?> class="<?= $isSectionActive ? 'bg-navigation-active' : '' ?> [&[open]>summary::after]:rotate-90">
|
2024-05-09 17:55:41 +00:00
|
|
|
<summary class="inline-flex items-center w-full h-12 px-4 py-2 font-semibold after:w-5 after:h-5 after:transition-transform after:content-chevronRightIcon after:ml-2 after:opacity-60 after:text-white">
|
2023-10-10 15:55:39 +00:00
|
|
|
<div class="inline-flex items-center mr-auto">
|
2024-04-26 17:57:25 +00:00
|
|
|
<?= icon($data['icon'], [
|
|
|
|
'class' => 'opacity-60 text-2xl mr-4',
|
|
|
|
]) ?>
|
2023-10-10 15:55:39 +00:00
|
|
|
<?= lang($langKey . '.' . $section) ?>
|
|
|
|
<?php if (array_key_exists('count', $data)): ?>
|
2024-05-09 17:55:41 +00:00
|
|
|
<a href="<?= route_to($data['count-route'], $podcastId ?? null, $episodeId ?? null) ?>" class="px-2 ml-2 text-xs font-normal rounded-full <?= $isSectionActive ? 'bg-navigation' : 'bg-navigation-active' ?>"><?= $data['count'] ?></a>
|
2023-10-10 15:55:39 +00:00
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<?php if(array_key_exists('add-cta', $data)): ?>
|
2024-05-09 17:55:41 +00:00
|
|
|
<a href="<?= route_to($data['add-cta'], $podcastId ?? null, $episodeId ?? null) ?>" class="p-2 rounded-full shadow bg-accent-base" title="<?= lang($langKey . '.' . $data['add-cta']) ?>" data-tooltip="bottom">
|
2024-04-26 17:57:25 +00:00
|
|
|
<?= icon('add-fill') ?>
|
2023-10-10 15:55:39 +00:00
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
|
|
|
</summary>
|
|
|
|
<ul class="flex flex-col pb-4">
|
2024-05-02 15:32:27 +00:00
|
|
|
<?php foreach ($data['items'] as $key => $item):
|
2023-10-10 15:55:39 +00:00
|
|
|
$isActive = $item === $activeItem;
|
2024-05-09 17:55:41 +00:00
|
|
|
|
|
|
|
$label = (array_key_exists('items-labels', $data) && array_key_exists($item, $data['items-labels'])) ? $data['items-labels'][$item] : lang($langKey . '.' . $item);
|
2024-05-02 15:32:27 +00:00
|
|
|
$href = str_starts_with($item, '/') ? $item : route_to($item, $podcastId ?? null, $episodeId ?? null);
|
2024-01-08 16:25:39 +00:00
|
|
|
|
|
|
|
$isAllowed = true;
|
|
|
|
if (array_key_exists('items-permissions', $data) && array_key_exists($item, $data['items-permissions'])) {
|
|
|
|
if (isset($podcastId)) {
|
|
|
|
$isAllowed = can_podcast(auth()->user(), $podcastId, $data['items-permissions'][$item]);
|
|
|
|
} else {
|
|
|
|
$isAllowed = auth()->user()->can($data['items-permissions'][$item]);
|
|
|
|
}
|
|
|
|
}
|
2023-10-10 15:55:39 +00:00
|
|
|
?>
|
|
|
|
<li class="inline-flex">
|
2024-01-09 16:12:15 +00:00
|
|
|
<?php if ($isAllowed): ?>
|
2024-05-15 18:30:56 +00:00
|
|
|
<a class="line-clamp-1 leading-9 relative w-full py-1 pl-14 pr-2 text-sm hover:opacity-100 before:content-chevronRightIcon before:absolute before:top-2 before:-ml-5 before:opacity-0 before:w-5 before:h-5 hover:bg-navigation-active<?= $isActive
|
|
|
|
? ' before:opacity-100 font-semibold'
|
2024-05-02 15:32:27 +00:00
|
|
|
: ' hover:before:opacity-60 focus:before:opacity-60' ?>" href="<?= $href ?>"><?= $label ?></a>
|
2024-01-09 16:12:15 +00:00
|
|
|
<?php else: ?>
|
2024-05-15 18:30:56 +00:00
|
|
|
<span data-tooltip="right" title="<?= lang('Navigation.not-authorized') ?>" class="relative w-full py-3 pr-2 text-sm cursor-not-allowed line-clamp-2 before:inset-y-0 before:my-auto pl-14 hover:opacity-100 before:absolute before:content-prohibitedIcon before:-ml-5 before:opacity-60 before:w-4 before:h-4 hover:bg-navigation-active"><?= $label ?></span>
|
2024-01-09 16:12:15 +00:00
|
|
|
<?php endif; ?>
|
2023-10-10 15:55:39 +00:00
|
|
|
</li>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</ul>
|
|
|
|
</details>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</nav>
|