2022-10-15 11:22:08 +00:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
$userPodcasts = get_podcasts_user_can_interact_with(auth()->user()); ?>
|
|
|
|
|
2021-11-05 14:36:34 +00:00
|
|
|
<div class="sticky top-0 left-0 z-50 flex items-center justify-between w-full h-10 text-white border-b bg-navigation border-navigation">
|
2021-10-13 15:43:40 +00:00
|
|
|
<div class="inline-flex items-center h-full">
|
2024-05-09 17:55:41 +00:00
|
|
|
<a href="<?= route_to('home') ?>" class="inline-flex items-center h-full px-2 border-r border-navigation">
|
2021-10-13 15:43:40 +00:00
|
|
|
<?= svg('castopod-logo-base', 'h-6') ?>
|
|
|
|
</a>
|
2024-05-09 17:55:41 +00:00
|
|
|
<a href="<?= route_to('admin') ?>" class="inline-flex items-center h-full px-2 text-sm font-semibold sm:px-6 hover:underline" title="<?= lang('Navigation.go_to_admin') ?>">
|
2023-11-17 17:26:37 +00:00
|
|
|
<span class="hidden sm:block"><?= lang('Navigation.go_to_admin') ?></span>
|
2024-04-26 17:57:25 +00:00
|
|
|
<?= icon('external-link-fill', [
|
|
|
|
'class' => 'sm:ml-1 text-xl sm:text-base sm:opacity-60',
|
|
|
|
]) ?>
|
2021-10-13 15:43:40 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="inline-flex items-center h-full">
|
2024-05-09 17:55:41 +00:00
|
|
|
<button type="button" class="relative h-full px-2" id="notifications-dropdown" data-dropdown="button" data-dropdown-target="notifications-dropdown-menu" aria-haspopup="true" aria-expanded="false" title="<?= lang('Notifications.title') ?>" data-tooltip="bottom">
|
2024-04-26 17:57:25 +00:00
|
|
|
<?= icon('notification-2-fill', [
|
|
|
|
'class' => 'text-2xl opacity-80',
|
|
|
|
]) ?>
|
2022-10-15 11:22:08 +00:00
|
|
|
<?php if (($actorIdsWithUnreadNotifications = get_actor_ids_with_unread_notifications(auth()->user())) !== []): ?>
|
2022-08-12 16:02:56 +00:00
|
|
|
<span class="absolute top-2 right-2 w-2.5 h-2.5 bg-red-500 rounded-full border border-navigation-bg"></span>
|
|
|
|
<?php endif ?>
|
|
|
|
</button>
|
|
|
|
<?php
|
|
|
|
$notificationsTitle = lang('Notifications.title');
|
|
|
|
|
2023-02-22 16:29:45 +00:00
|
|
|
$items = [
|
|
|
|
[
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'html',
|
2023-08-26 13:03:01 +00:00
|
|
|
'content' => esc(<<<HTML
|
2022-08-12 16:02:56 +00:00
|
|
|
<span class="px-4 my-2 text-xs font-semibold tracking-wider uppercase text-skin-muted">{$notificationsTitle}</span>
|
2023-08-26 13:03:01 +00:00
|
|
|
HTML),
|
2023-02-22 16:29:45 +00:00
|
|
|
],
|
|
|
|
];
|
2022-08-12 16:02:56 +00:00
|
|
|
|
2023-02-22 16:29:45 +00:00
|
|
|
if ($userPodcasts !== []) {
|
|
|
|
foreach ($userPodcasts as $userPodcast) {
|
|
|
|
$userPodcastTitle = esc($userPodcast->title);
|
2022-08-12 16:02:56 +00:00
|
|
|
|
2023-02-22 16:29:45 +00:00
|
|
|
$unreadNotificationDotDisplayClass = in_array($userPodcast->actor_id, $actorIdsWithUnreadNotifications, true) ? '' : 'hidden';
|
2022-08-12 16:02:56 +00:00
|
|
|
|
2023-02-22 16:29:45 +00:00
|
|
|
$items[] = [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'link',
|
2023-08-26 13:03:01 +00:00
|
|
|
'title' => <<<HTML
|
2022-08-12 16:02:56 +00:00
|
|
|
<div class="inline-flex items-center flex-1 text-sm align-middle">
|
|
|
|
<div class="relative">
|
|
|
|
<img src="{$userPodcast->cover->tiny_url}" class="w-6 h-6 mr-2 rounded-full" loading="lazy" />
|
|
|
|
<span class="absolute top-0 right-1 w-2.5 h-2.5 bg-red-500 rounded-full border border-background-elevated {$unreadNotificationDotDisplayClass}"></span>
|
|
|
|
</div>
|
|
|
|
<span class="max-w-xs truncate">{$userPodcastTitle}</span>
|
|
|
|
</div>
|
2023-08-26 13:03:01 +00:00
|
|
|
HTML
|
2023-02-22 16:29:45 +00:00
|
|
|
,
|
|
|
|
'uri' => route_to('notification-list', $userPodcast->id),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$noNotificationsText = lang('Notifications.no_notifications');
|
|
|
|
$items[] = [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'html',
|
2023-08-26 13:03:01 +00:00
|
|
|
'content' => esc(<<<HTML
|
2022-08-12 16:02:56 +00:00
|
|
|
<span class="mx-4 my-2 text-sm italic text-center text-skin-muted">{$noNotificationsText}</span>
|
2023-08-26 13:03:01 +00:00
|
|
|
HTML),
|
2023-02-22 16:29:45 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
?>
|
2024-05-09 17:55:41 +00:00
|
|
|
<x-DropdownMenu id="notifications-dropdown-menu" labelledby="notifications-dropdown" items="<?= esc(json_encode($items)) ?>" placement="bottom-end"/>
|
2022-10-15 11:22:08 +00:00
|
|
|
|
2022-08-12 16:02:56 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
2024-05-09 17:55:41 +00:00
|
|
|
class="inline-flex items-center h-full px-3 text-sm font-semibold gap-x-2"
|
2022-08-12 16:02:56 +00:00
|
|
|
id="my-account-dropdown"
|
|
|
|
data-dropdown="button"
|
|
|
|
data-dropdown-target="my-account-dropdown-menu"
|
|
|
|
aria-haspopup="true"
|
2022-10-15 11:22:08 +00:00
|
|
|
aria-expanded="false">
|
|
|
|
<div class="relative mr-1">
|
2024-04-26 17:57:25 +00:00
|
|
|
<?= icon('account-circle-fill', [
|
|
|
|
'class' => 'text-3xl opacity-60',
|
|
|
|
]) ?>
|
2022-10-15 11:22:08 +00:00
|
|
|
<?php if (can_user_interact()): ?>
|
|
|
|
<?= auth()
|
|
|
|
->user()
|
2022-08-12 16:02:56 +00:00
|
|
|
->podcasts === [] ? '' : '<img src="' . interact_as_actor()->avatar_image_url . '" class="absolute bottom-0 w-4 h-4 border rounded-full -right-1 border-navigation-bg" loading="lazy" />' ?>
|
2022-10-15 11:22:08 +00:00
|
|
|
<?php endif; ?>
|
2022-08-12 16:02:56 +00:00
|
|
|
</div>
|
2022-10-15 11:22:08 +00:00
|
|
|
<?= esc(auth()->user()->username) ?>
|
2024-04-26 17:57:25 +00:00
|
|
|
<?= icon('arrow-drop-down-fill', [
|
|
|
|
'class' => 'ml-auto text-2xl',
|
|
|
|
]) ?></button>
|
2021-10-13 15:43:40 +00:00
|
|
|
<?php
|
2023-02-22 16:29:45 +00:00
|
|
|
$interactButtons = '';
|
|
|
|
foreach ($userPodcasts as $userPodcast) {
|
|
|
|
if (can_podcast(auth()->user(), $userPodcast->id, 'interact-as')) {
|
2024-04-26 17:57:25 +00:00
|
|
|
$checkMark = interact_as_actor_id() === $userPodcast->actor_id ? icon('check-fill', [
|
|
|
|
'class' => 'ml-2 bg-accent-base text-accent-contrast rounded-full',
|
|
|
|
]) : '';
|
2023-02-22 16:29:45 +00:00
|
|
|
$userPodcastTitle = esc($userPodcast->title);
|
2021-10-13 15:43:40 +00:00
|
|
|
|
2023-08-26 13:03:01 +00:00
|
|
|
$interactButtons .= <<<HTML
|
2022-10-15 11:22:08 +00:00
|
|
|
<button class="inline-flex items-center w-full px-4 py-1 hover:bg-highlight" id="interact-as-actor-{$userPodcast->id}" name="actor_id" value="{$userPodcast->actor_id}">
|
|
|
|
<div class="inline-flex items-center flex-1 text-sm"><img src="{$userPodcast->cover->tiny_url}" class="w-6 h-6 mr-2 rounded-full" loading="lazy" /><span class="max-w-xs truncate">{$userPodcastTitle}</span>{$checkMark}</div>
|
|
|
|
</button>
|
2023-08-26 13:03:01 +00:00
|
|
|
HTML;
|
2023-02-22 16:29:45 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-13 15:43:40 +00:00
|
|
|
|
2023-02-22 16:29:45 +00:00
|
|
|
$interactAsText = lang('Common.choose_interact');
|
|
|
|
$interactAsRoute = route_to('interact-as-actor');
|
|
|
|
$csrfField = csrf_field();
|
2021-10-13 15:43:40 +00:00
|
|
|
|
2023-02-22 16:29:45 +00:00
|
|
|
$menuItems = [
|
|
|
|
[
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'link',
|
2023-02-22 16:29:45 +00:00
|
|
|
'title' => lang('Navigation.account.my-account'),
|
2023-06-12 14:47:38 +00:00
|
|
|
'uri' => route_to('my-account'),
|
2023-02-22 16:29:45 +00:00
|
|
|
],
|
|
|
|
[
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'link',
|
2023-02-22 16:29:45 +00:00
|
|
|
'title' => lang('Navigation.account.change-password'),
|
2023-06-12 14:47:38 +00:00
|
|
|
'uri' => route_to('change-password'),
|
2023-02-22 16:29:45 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'type' => 'separator',
|
|
|
|
],
|
|
|
|
[
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'link',
|
2023-02-22 16:29:45 +00:00
|
|
|
'title' => lang('Navigation.account.logout'),
|
2023-06-12 14:47:38 +00:00
|
|
|
'uri' => route_to('logout'),
|
2023-02-22 16:29:45 +00:00
|
|
|
],
|
|
|
|
];
|
2021-10-13 15:43:40 +00:00
|
|
|
|
2023-02-22 16:29:45 +00:00
|
|
|
if ($userPodcasts !== []) {
|
|
|
|
$menuItems = array_merge([
|
|
|
|
[
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'html',
|
2023-08-26 13:03:01 +00:00
|
|
|
'content' => esc(<<<HTML
|
2022-07-22 16:45:11 +00:00
|
|
|
<nav class="flex flex-col py-2 whitespace-nowrap">
|
2021-11-05 14:36:34 +00:00
|
|
|
<span class="px-4 mb-2 text-xs font-semibold tracking-wider uppercase text-skin-muted">{$interactAsText}</span>
|
2022-10-15 11:22:08 +00:00
|
|
|
<form action="{$interactAsRoute}" method="POST" class="flex flex-col">
|
2021-10-13 15:43:40 +00:00
|
|
|
{$csrfField}
|
|
|
|
{$interactButtons}
|
|
|
|
</form>
|
|
|
|
</nav>
|
2023-08-26 13:03:01 +00:00
|
|
|
HTML),
|
2023-02-22 16:29:45 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'type' => 'separator',
|
|
|
|
],
|
|
|
|
], $menuItems);
|
|
|
|
}
|
|
|
|
?>
|
2024-05-09 17:55:41 +00:00
|
|
|
<x-DropdownMenu id="my-account-dropdown-menu" labelledby="my-account-dropdown" items="<?= esc(json_encode($menuItems)) ?>" />
|
2021-10-13 15:43:40 +00:00
|
|
|
</div>
|
|
|
|
</div>
|