Add a module kernel (ModuleManifest, ModuleRegistry) that allows modules to contribute routes, UI slots, search providers, layout context, session lifecycle, and permissions. Modules are activated via config/modules.php or APP_ENABLED_MODULES env variable. Conflicts (duplicate routes, permissions, slot keys) cause a fail-fast with a clear error message. Extract the address book from hardcoded Core integration points into the first module (modules/addressbook/). The module provides: - Aside icon-bar tab + People panel via UI slot system - Global search resource via AddressBookSearchProvider - Layout context data via AddressBookLayoutProvider - Session lifecycle via AddressBookSessionProvider Core cleanup removes address-book hardcodings from SearchSqlResourceProvider, SearchUiMetaProvider, SearchItemMapperProvider, appBuildLayoutNavContext(), and the aside templates. Permissions (ADDRESS_BOOK_VIEW) and business logic (AddressBookService) remain in Core as they gate general user visibility. Includes 38 new tests (894 total), PHPStan level 5 clean, and architecture tests verifying zero hardcoded address-book references in search/templates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
728 lines
41 KiB
PHTML
728 lines
41 KiB
PHTML
<?php
|
|
|
|
use MintyPHP\Service\Docs\DocsCatalogService;
|
|
use MintyPHP\Support\BookmarkUrlNormalizer;
|
|
|
|
$layoutAuth = is_array($viewAuth['layout'] ?? null) ? $viewAuth['layout'] : [];
|
|
$canViewTenants = (bool) ($layoutAuth['can_view_tenants'] ?? false);
|
|
$canViewDepartments = (bool) ($layoutAuth['can_view_departments'] ?? false);
|
|
$canViewUsers = (bool) ($layoutAuth['can_view_users'] ?? false);
|
|
$canViewRoles = (bool) ($layoutAuth['can_view_roles'] ?? false);
|
|
$canViewPermissions = (bool) ($layoutAuth['can_view_permissions'] ?? false);
|
|
$canViewSettings = (bool) ($layoutAuth['can_view_settings'] ?? false);
|
|
$canViewImports = (bool) ($layoutAuth['can_view_imports'] ?? false);
|
|
$canViewJobs = (bool) ($layoutAuth['can_view_jobs'] ?? false);
|
|
$canViewApiDocs = (bool) ($layoutAuth['can_view_api_docs'] ?? false);
|
|
$canViewDocs = (bool) ($layoutAuth['can_view_docs'] ?? false);
|
|
$canViewMailLog = (bool) ($layoutAuth['can_view_mail_log'] ?? false);
|
|
$canViewApiAudit = (bool) ($layoutAuth['can_view_api_audit'] ?? false);
|
|
$canViewSystemAudit = (bool) ($layoutAuth['can_view_system_audit'] ?? false);
|
|
$canViewImportsAudit = (bool) ($layoutAuth['can_view_imports_audit'] ?? false);
|
|
$canViewUserLifecycleAudit = (bool) ($layoutAuth['can_view_user_lifecycle_audit'] ?? false);
|
|
$canViewStats = (bool) ($layoutAuth['can_view_stats'] ?? false);
|
|
$docsDefaultSlug = DocsCatalogService::defaultSlug();
|
|
$docsDefaultPath = 'admin/docs/' . $docsDefaultSlug;
|
|
$hasOrganization = $canViewTenants || $canViewDepartments || $canViewUsers;
|
|
$hasUsersSection = $canViewRoles || $canViewPermissions;
|
|
$hasAutomationSection = $canViewImports || $canViewJobs || $canViewApiDocs;
|
|
$hasMonitoringSection = $canViewStats;
|
|
$hasLogsSection = $canViewMailLog || $canViewApiAudit || $canViewSystemAudit || $canViewImportsAudit || $canViewUserLifecycleAudit;
|
|
$hasSystemSection = $canViewSettings || $canViewDocs;
|
|
$hasAdminPanel = layoutHasAdminPanel($layoutAuth);
|
|
|
|
// Declarative nav config for admin panel groups
|
|
$adminNavGroups = [
|
|
[
|
|
'key' => 'admin-organization',
|
|
'label' => t('Organization'),
|
|
'icon' => 'bi-building',
|
|
'visible' => $hasOrganization,
|
|
'items' => [
|
|
[
|
|
'label' => t('Tenants'),
|
|
'path' => 'admin/tenants',
|
|
'active' => navActive('admin/tenants', true),
|
|
'visible' => $canViewTenants,
|
|
'withTenant' => false,
|
|
],
|
|
[
|
|
'label' => t('Departments'),
|
|
'path' => 'admin/departments',
|
|
'active' => navActive('admin/departments', true),
|
|
'visible' => $canViewDepartments,
|
|
'withTenant' => true,
|
|
],
|
|
[
|
|
'label' => t('Users'),
|
|
'path' => 'admin/users',
|
|
'active' => navActive('admin/users', true),
|
|
'visible' => $canViewUsers,
|
|
'withTenant' => true,
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'key' => 'admin-roles-permissions',
|
|
'label' => t('Roles & permissions'),
|
|
'icon' => 'bi-shield-lock',
|
|
'visible' => $hasUsersSection,
|
|
'items' => [
|
|
[
|
|
'label' => t('Roles'),
|
|
'path' => 'admin/roles',
|
|
'active' => navActive('admin/roles', true),
|
|
'visible' => $canViewRoles,
|
|
'withTenant' => false,
|
|
],
|
|
[
|
|
'label' => t('Permissions'),
|
|
'path' => 'admin/permissions',
|
|
'active' => navActive('admin/permissions', true),
|
|
'visible' => $canViewPermissions,
|
|
'withTenant' => false,
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'key' => 'admin-automation',
|
|
'label' => t('Automation & integrations'),
|
|
'icon' => 'bi-plug',
|
|
'visible' => $hasAutomationSection,
|
|
'items' => [
|
|
[
|
|
'label' => t('Imports'),
|
|
'path' => 'admin/imports',
|
|
'active' => navActive('admin/imports', true),
|
|
'visible' => $canViewImports,
|
|
'withTenant' => false,
|
|
],
|
|
[
|
|
'label' => t('Scheduled jobs'),
|
|
'path' => 'admin/scheduled-jobs',
|
|
'active' => navActive('admin/scheduled-jobs', true),
|
|
'visible' => $canViewJobs,
|
|
'withTenant' => false,
|
|
],
|
|
[
|
|
'label' => t('API docs'),
|
|
'path' => 'admin/api-docs',
|
|
'active' => navActive('admin/api-docs', true),
|
|
'visible' => $canViewApiDocs,
|
|
'withTenant' => false,
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'key' => 'admin-monitoring',
|
|
'label' => t('Monitoring'),
|
|
'icon' => 'bi-graph-up',
|
|
'visible' => $hasMonitoringSection,
|
|
'items' => [
|
|
[
|
|
'label' => t('Statistics'),
|
|
'path' => 'admin/stats',
|
|
'active' => navActive('admin/stats', true),
|
|
'visible' => $canViewStats,
|
|
'withTenant' => false,
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'key' => 'admin-logs',
|
|
'label' => t('Logs'),
|
|
'icon' => 'bi-journal-text',
|
|
'visible' => $hasLogsSection,
|
|
'items' => [
|
|
[
|
|
'label' => t('Mail logs'),
|
|
'path' => 'admin/mail-log',
|
|
'active' => navActive('admin/mail-log', true),
|
|
'visible' => $canViewMailLog,
|
|
'withTenant' => false,
|
|
],
|
|
[
|
|
'label' => t('API audit'),
|
|
'path' => 'admin/api-audit',
|
|
'active' => navActive('admin/api-audit', true),
|
|
'visible' => $canViewApiAudit,
|
|
'withTenant' => false,
|
|
],
|
|
[
|
|
'label' => t('System audit logs'),
|
|
'path' => 'admin/system-audit',
|
|
'active' => navActive('admin/system-audit', true),
|
|
'visible' => $canViewSystemAudit,
|
|
'withTenant' => false,
|
|
],
|
|
[
|
|
'label' => t('Import logs'),
|
|
'path' => 'admin/import-audit',
|
|
'active' => navActive('admin/import-audit', true),
|
|
'visible' => $canViewImportsAudit,
|
|
'withTenant' => false,
|
|
],
|
|
[
|
|
'label' => t('User lifecycle logs'),
|
|
'path' => 'admin/user-lifecycle-audit',
|
|
'active' => navActive('admin/user-lifecycle-audit', true),
|
|
'visible' => $canViewUserLifecycleAudit,
|
|
'withTenant' => false,
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'key' => 'admin-system',
|
|
'label' => t('System'),
|
|
'icon' => 'bi-sliders',
|
|
'visible' => $hasSystemSection,
|
|
'items' => [
|
|
[
|
|
'label' => t('Settings'),
|
|
'path' => 'admin/settings',
|
|
'active' => navActive('admin/settings', true),
|
|
'visible' => $canViewSettings,
|
|
'withTenant' => false,
|
|
],
|
|
[
|
|
'label' => t('Documentation'),
|
|
'path' => $docsDefaultPath,
|
|
'active' => navActive('admin/docs', true),
|
|
'visible' => $canViewDocs,
|
|
'withTenant' => false,
|
|
],
|
|
],
|
|
],
|
|
];
|
|
|
|
// Render helper for grouped admin aside navigation
|
|
$renderAdminNavGroup = static function (array $group, string $tenantQueryParam): void {
|
|
if (empty($group['visible'])) {
|
|
return;
|
|
}
|
|
$groupKey = trim((string) ($group['key'] ?? ''));
|
|
if ($groupKey === '') {
|
|
return;
|
|
}
|
|
$items = $group['items'] ?? [];
|
|
$items = array_values(array_filter($items, static fn ($item) => !empty($item['visible'])));
|
|
if (!$items) {
|
|
return;
|
|
}
|
|
$groupIsActive = false;
|
|
foreach ($items as $item) {
|
|
$activeState = $item['active'] ?? [];
|
|
if (!empty($activeState['isActive'])) {
|
|
$groupIsActive = true;
|
|
break;
|
|
}
|
|
}
|
|
?>
|
|
<li class="app-sidebar-group app-sidebar-admin-group">
|
|
<details data-details-key="<?php e($groupKey); ?>"<?php if ($groupIsActive): ?> open<?php endif; ?>>
|
|
<summary>
|
|
<?php if (!empty($group['icon'])): ?><i class="bi <?php e($group['icon']); ?>"></i> <?php endif; ?>
|
|
<span><?php e($group['label'] ?? ''); ?></span>
|
|
</summary>
|
|
<ul>
|
|
<?php foreach ($items as $item): ?>
|
|
<?php
|
|
$href = $item['path'] ?? '';
|
|
if ($href !== '' && !empty($item['withTenant'])) {
|
|
$href .= $tenantQueryParam;
|
|
}
|
|
$active = $item['active'] ?? ['class' => '', 'aria' => ''];
|
|
?>
|
|
<li>
|
|
<a href="<?php e($href); ?>" class="<?php e($active['class'] ?? ''); ?>" <?php echo $active['aria'] ?? ''; ?>>
|
|
<?php e($item['label'] ?? ''); ?>
|
|
</a>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</details>
|
|
</li>
|
|
<?php
|
|
};
|
|
|
|
// Read precomputed layout context from web/index.php (before Session::end()).
|
|
$layoutNav = is_array($layoutNav ?? null) ? $layoutNav : [];
|
|
$currentTenant = is_array($layoutNav['currentTenant'] ?? null) ? $layoutNav['currentTenant'] : null;
|
|
$availableTenants = is_array($layoutNav['availableTenants'] ?? null) ? $layoutNav['availableTenants'] : [];
|
|
$tenantQueryParam = trim((string) ($layoutNav['tenantQueryParam'] ?? ''));
|
|
$tenantAvatar = is_array($layoutNav['tenantAvatar'] ?? null) ? $layoutNav['tenantAvatar'] : [];
|
|
$tenantUuid = trim((string) ($tenantAvatar['uuid'] ?? ''));
|
|
$tenantName = trim((string) ($tenantAvatar['name'] ?? ''));
|
|
$hasTenantAvatar = !empty($tenantAvatar['hasAvatar']);
|
|
$csrfKey = trim((string) ($layoutNav['csrfKey'] ?? \MintyPHP\Session::$csrfSessionKey));
|
|
$csrfToken = (string) ($layoutNav['csrfToken'] ?? '');
|
|
?>
|
|
<aside class="app-sidebar" id="app-sidebar" data-app-component="sidebar-toggle">
|
|
<?php if ($currentTenant): ?>
|
|
<div class="app-sidebar-tenant-logo">
|
|
<a href="<?php e(lurl('')); ?>">
|
|
<?php if ($hasTenantAvatar): ?>
|
|
<img src="auth/tenant-avatar-file?uuid=<?php e($tenantUuid); ?>&size=128" alt="<?php e($tenantName); ?>"
|
|
title="<?php e($tenantName); ?>">
|
|
<?php else: ?>
|
|
<div class="app-sidebar-tenant-name">
|
|
<?php e($tenantName); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</a>
|
|
<button type="button" class="app-sidebar-tenant-toggle" data-sidebar-toggle
|
|
aria-label="<?php e(t('Toggle Sidebar')); ?>">
|
|
<i class="bi bi-list"></i>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div id="app-sidebar-panels" class="app-sidebar-panels">
|
|
<nav id="aside-panel-explorer" class="app-sidebar-panel" data-aside-panel="explorer"
|
|
data-aside-title="<?php e(t('Explorer')); ?>" role="tabpanel" aria-labelledby="aside-tab-explorer"
|
|
aria-label="<?php e(t('Primary navigation')); ?>">
|
|
<ul>
|
|
<li>
|
|
<?php $home = navActive(['', 'admin'], false); ?>
|
|
<a href="<?php e(lurl('')); ?>" class="<?php e($home['class']); ?>" <?php echo $home['aria']; ?>>
|
|
<?php e(t('Home')); ?>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
<?php if ($hasAdminPanel): ?>
|
|
<nav id="aside-panel-admin" class="app-sidebar-panel" data-aside-panel="admin"
|
|
data-aside-title="<?php e(t('Admin')); ?>" data-aside-details-storage="aside-admin-sections-v1"
|
|
data-aside-details-open-active="1" role="tabpanel" aria-labelledby="aside-tab-admin" hidden>
|
|
<ul>
|
|
<?php foreach ($adminNavGroups as $group): ?>
|
|
<?php $renderAdminNavGroup($group, $tenantQueryParam); ?>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</nav>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
// ── Module-contributed aside panels (aside.tab_panel slot) ──
|
|
$moduleSlots = is_array($layoutNav['moduleSlots'] ?? null) ? $layoutNav['moduleSlots'] : [];
|
|
$modulePanelSlots = is_array($moduleSlots['aside.tab_panel'] ?? null) ? $moduleSlots['aside.tab_panel'] : [];
|
|
foreach ($modulePanelSlots as $panelSlot):
|
|
if (!is_array($panelSlot)) { continue; }
|
|
$panelKey = $panelSlot['key'] ?? '';
|
|
$panelLabel = $panelSlot['label'] ?? '';
|
|
$panelTemplate = $panelSlot['panel_template'] ?? '';
|
|
$panelPermission = $panelSlot['permission'] ?? '';
|
|
if ($panelPermission !== '' && empty($layoutAuth[$panelPermission])) { continue; }
|
|
if ($panelKey === '' || $panelTemplate === '') { continue; }
|
|
?>
|
|
<?php
|
|
$panelDetailsStorage = $panelSlot['details_storage'] ?? '';
|
|
$panelDetailsOpenActive = !empty($panelSlot['details_open_active']);
|
|
?>
|
|
<nav id="aside-panel-<?php e($panelKey); ?>" class="app-sidebar-panel"
|
|
data-aside-panel="<?php e($panelKey); ?>"
|
|
<?php if ($panelDetailsStorage !== ''): ?>data-aside-details-storage="<?php e($panelDetailsStorage); ?>"<?php endif; ?>
|
|
<?php if ($panelDetailsOpenActive): ?>data-aside-details-open-active="1"<?php endif; ?>
|
|
data-aside-title="<?php e(t($panelLabel)); ?>"
|
|
role="tabpanel" aria-labelledby="aside-tab-<?php e($panelKey); ?>" hidden>
|
|
<?php
|
|
// Include the module-provided panel template
|
|
$panelTemplatePath = $panelTemplate;
|
|
if (is_file($panelTemplatePath)) {
|
|
include $panelTemplatePath;
|
|
}
|
|
?>
|
|
</nav>
|
|
<?php endforeach; ?>
|
|
|
|
<div id="aside-panel-search" class="app-sidebar-panel" data-app-component="global-search" data-aside-panel="search"
|
|
data-aside-title="<?php e(t('Search')); ?>" role="tabpanel" aria-labelledby="aside-tab-search" hidden>
|
|
<form class="app-search">
|
|
<input type="search" name="side-search" id="side-search" placeholder="<?php e(t('Search...')); ?>"
|
|
aria-label="<?php e(t('Search')); ?>">
|
|
<span class="app-search-shortcut" data-search-shortcut aria-hidden="true"></span>
|
|
</form>
|
|
<div class="app-search-empty-state" data-global-search-empty>
|
|
<i class="bi bi-search" aria-hidden="true"></i>
|
|
<p><?php e(t('To start searching, type in the search field.')); ?></p>
|
|
<small class="muted" data-search-empty-hint-template="<?php e(t('Tip: Use {shortcut} to focus search quickly.')); ?>"></small>
|
|
</div>
|
|
<nav id="global-search">
|
|
<ul class="app-search-results" data-global-search-results aria-live="polite">
|
|
<?php if ($canViewUsers): ?>
|
|
<?php $usersSearch = navActive('admin/users', true); ?>
|
|
<li data-search-key="users" data-search-base="<?php e(lurl('admin/users')); ?>">
|
|
<a href="<?php e(lurl('admin/users')); ?>" class="<?php e($usersSearch['class']); ?>" <?php echo $usersSearch['aria']; ?>>
|
|
<span><?php e(t('Users')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($canViewAddressBook): ?>
|
|
<?php $addressBookSearch = navActive('address-book', true); ?>
|
|
<li data-search-key="address-book" data-search-base="<?php e(lurl('address-book')); ?>">
|
|
<a href="<?php e(lurl('address-book')); ?>" class="<?php e($addressBookSearch['class'] ?? ''); ?>"
|
|
<?php echo $addressBookSearch['aria'] ?? ''; ?>>
|
|
<span><?php e(t('Address book')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($canViewTenants): ?>
|
|
<?php $tenantsSearch = navActive('admin/tenants', true); ?>
|
|
<li data-search-key="tenants" data-search-base="<?php e(lurl('admin/tenants')); ?>">
|
|
<a href="<?php e(lurl('admin/tenants')); ?>" class="<?php e($tenantsSearch['class']); ?>" <?php echo $tenantsSearch['aria']; ?>>
|
|
<span><?php e(t('Tenants')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($canViewDepartments): ?>
|
|
<?php $departmentsSearch = navActive('admin/departments', true); ?>
|
|
<li data-search-key="departments" data-search-base="<?php e(lurl('admin/departments')); ?>">
|
|
<a href="<?php e(lurl('admin/departments')); ?>"
|
|
class="<?php e($departmentsSearch['class']); ?>" <?php echo $departmentsSearch['aria']; ?>>
|
|
<span><?php e(t('Departments')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($canViewRoles): ?>
|
|
<?php $rolesSearch = navActive('admin/roles', true); ?>
|
|
<li data-search-key="roles" data-search-base="<?php e(lurl('admin/roles')); ?>">
|
|
<a href="<?php e(lurl('admin/roles')); ?>" class="<?php e($rolesSearch['class']); ?>" <?php echo $rolesSearch['aria']; ?>>
|
|
<span><?php e(t('Roles')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($canViewPermissions): ?>
|
|
<?php $permissionsSearch = navActive('admin/permissions', true); ?>
|
|
<li data-search-key="permissions" data-search-base="<?php e(lurl('admin/permissions')); ?>">
|
|
<a href="<?php e(lurl('admin/permissions')); ?>"
|
|
class="<?php e($permissionsSearch['class']); ?>" <?php echo $permissionsSearch['aria']; ?>>
|
|
<span><?php e(t('Permissions')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($canViewJobs): ?>
|
|
<?php $scheduledJobsSearch = navActive('admin/scheduled-jobs', true); ?>
|
|
<li data-search-key="scheduled-jobs" data-search-base="<?php e(lurl('admin/scheduled-jobs')); ?>">
|
|
<a href="<?php e(lurl('admin/scheduled-jobs')); ?>"
|
|
class="<?php e($scheduledJobsSearch['class']); ?>" <?php echo $scheduledJobsSearch['aria']; ?>>
|
|
<span><?php e(t('Scheduled jobs')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php
|
|
$pagesSearch = navActivePublicPages();
|
|
?>
|
|
<li data-search-key="pages" data-search-base="<?php e(lurl('')); ?>">
|
|
<a href="<?php e(lurl('')); ?>" class="<?php e($pagesSearch['class']); ?>" <?php echo $pagesSearch['aria']; ?>>
|
|
<span><?php e(t('Pages')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php if ($canViewDocs): ?>
|
|
<?php $docsSearch = navActive('admin/docs', true); ?>
|
|
<li data-search-key="docs" data-search-base="<?php e(lurl($docsDefaultPath)); ?>">
|
|
<a href="<?php e(lurl($docsDefaultPath)); ?>" class="<?php e($docsSearch['class']); ?>" <?php echo $docsSearch['aria']; ?>>
|
|
<span><?php e(t('Documentation')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php $hotkeysSearch = navActive('help/hotkeys', true); ?>
|
|
<li data-search-key="hotkeys" data-search-base="<?php e(lurl('help/hotkeys')); ?>">
|
|
<a href="<?php e(lurl('help/hotkeys')); ?>" class="<?php e($hotkeysSearch['class']); ?>" <?php echo $hotkeysSearch['aria']; ?>>
|
|
<span><?php e(t('Keyboard shortcuts')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php if ($canViewMailLog): ?>
|
|
<?php $mailLogSearch = navActive('admin/mail-log', true); ?>
|
|
<li data-search-key="mail-log" data-search-base="<?php e(lurl('admin/mail-log')); ?>">
|
|
<a href="<?php e(lurl('admin/mail-log')); ?>" class="<?php e($mailLogSearch['class']); ?>"
|
|
<?php echo $mailLogSearch['aria']; ?>>
|
|
<span><?php e(t('Mail logs')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($canViewApiAudit): ?>
|
|
<?php $apiAuditSearch = navActive('admin/api-audit', true); ?>
|
|
<li data-search-key="api-audit" data-search-base="<?php e(lurl('admin/api-audit')); ?>">
|
|
<a href="<?php e(lurl('admin/api-audit')); ?>" class="<?php e($apiAuditSearch['class']); ?>"
|
|
<?php echo $apiAuditSearch['aria']; ?>>
|
|
<span><?php e(t('API audit')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($canViewSystemAudit): ?>
|
|
<?php $systemAuditSearch = navActive('admin/system-audit', true); ?>
|
|
<li data-search-key="system-audit" data-search-base="<?php e(lurl('admin/system-audit')); ?>">
|
|
<a href="<?php e(lurl('admin/system-audit')); ?>" class="<?php e($systemAuditSearch['class']); ?>"
|
|
<?php echo $systemAuditSearch['aria']; ?>>
|
|
<span><?php e(t('System audit')); ?></span>
|
|
<span class="badge" data-search-count>0</span>
|
|
</a>
|
|
<ul class="app-search-preview" data-search-preview></ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
|
|
<?php
|
|
$bookmarkData = is_array($layoutNav['bookmarks'] ?? null) ? $layoutNav['bookmarks'] : ['groups' => [], 'ungrouped' => []];
|
|
$bookmarkGroups = is_array($bookmarkData['groups'] ?? null) ? $bookmarkData['groups'] : [];
|
|
$bookmarkUngrouped = is_array($bookmarkData['ungrouped'] ?? null) ? $bookmarkData['ungrouped'] : [];
|
|
$currentPath = BookmarkUrlNormalizer::canonicalizeRequestUri((string) ($_SERVER['REQUEST_URI'] ?? ''), localeBase());
|
|
?>
|
|
<nav id="aside-panel-bookmarks" class="app-sidebar-panel" data-app-component="bookmark-panel" data-aside-panel="bookmarks"
|
|
data-aside-title="<?php e(t('Bookmarks')); ?>"
|
|
data-aside-details-storage="aside-bookmarks-groups-v1"
|
|
data-bookmark-reorder-url="<?php e(lurl('bookmarks/reorder-data')); ?>"
|
|
data-bookmark-group-delete-url="<?php e(lurl('bookmarks/group-delete-data')); ?>"
|
|
data-bookmark-delete-url="<?php e(lurl('bookmarks/delete-data')); ?>"
|
|
data-bookmark-msg-group-delete-confirm="<?php e(t('Delete group and keep bookmarks?')); ?>"
|
|
data-bookmark-msg-group-deleted="<?php e(t('Group deleted')); ?>"
|
|
data-bookmark-msg-group-updated="<?php e(t('Group updated')); ?>"
|
|
data-bookmark-msg-bookmark-delete-confirm="<?php e(t('Delete this bookmark?')); ?>"
|
|
data-bookmark-msg-bookmark-deleted="<?php e(t('Bookmark deleted')); ?>"
|
|
data-bookmark-msg-group-action-failed="<?php e(t('Group action failed')); ?>"
|
|
data-bookmark-msg-bookmark-action-failed="<?php e(t('Bookmark action failed')); ?>"
|
|
data-bookmark-msg-group-delete-failed="<?php e(t('Group delete failed')); ?>"
|
|
data-bookmark-msg-bookmark-delete-failed="<?php e(t('Bookmark action failed')); ?>"
|
|
data-bookmark-msg-reorder-saved="<?php e(t('Reorder saved')); ?>"
|
|
data-bookmark-msg-reorder-failed="<?php e(t('Reorder failed')); ?>"
|
|
data-bookmark-label-delete="<?php e(t('Delete')); ?>"
|
|
role="tabpanel" aria-labelledby="aside-tab-bookmarks" hidden>
|
|
<?php if (!$bookmarkGroups && !$bookmarkUngrouped): ?>
|
|
<?php
|
|
$emptyState = [
|
|
'message' => t('No bookmarks yet'),
|
|
'size' => 'compact',
|
|
'align' => 'center',
|
|
];
|
|
require templatePath('partials/app-empty-state.phtml');
|
|
?>
|
|
<?php else: ?>
|
|
<?php
|
|
$bookmarkRootItems = [];
|
|
foreach ($bookmarkUngrouped as $bm) {
|
|
$bmId = (int) ($bm['id'] ?? 0);
|
|
if ($bmId <= 0) {
|
|
continue;
|
|
}
|
|
$bookmarkRootItems[] = [
|
|
'type' => 'bookmark',
|
|
'id' => $bmId,
|
|
'sort_order' => (int) ($bm['sort_order'] ?? 0),
|
|
'bookmark' => $bm,
|
|
];
|
|
}
|
|
foreach ($bookmarkGroups as $group) {
|
|
$gId = (int) ($group['id'] ?? 0);
|
|
if ($gId <= 0) {
|
|
continue;
|
|
}
|
|
$bookmarkRootItems[] = [
|
|
'type' => 'group',
|
|
'id' => $gId,
|
|
'sort_order' => (int) ($group['sort_order'] ?? 0),
|
|
'group' => $group,
|
|
];
|
|
}
|
|
usort($bookmarkRootItems, static function (array $a, array $b): int {
|
|
$sortCmp = ((int) ($a['sort_order'] ?? 0)) <=> ((int) ($b['sort_order'] ?? 0));
|
|
if ($sortCmp !== 0) {
|
|
return $sortCmp;
|
|
}
|
|
$typeCmp = strcmp((string) ($a['type'] ?? ''), (string) ($b['type'] ?? ''));
|
|
if ($typeCmp !== 0) {
|
|
return $typeCmp;
|
|
}
|
|
return ((int) ($a['id'] ?? 0)) <=> ((int) ($b['id'] ?? 0));
|
|
});
|
|
$rootCount = count($bookmarkRootItems);
|
|
?>
|
|
<ul data-bookmark-root-list>
|
|
<?php foreach ($bookmarkRootItems as $rootIndex => $rootItem): ?>
|
|
<?php
|
|
$rootType = (string) ($rootItem['type'] ?? '');
|
|
$rootFirst = $rootIndex === 0;
|
|
$rootLast = $rootIndex === ($rootCount - 1);
|
|
?>
|
|
<?php if ($rootType === 'bookmark'): ?>
|
|
<?php
|
|
$bm = is_array($rootItem['bookmark'] ?? null) ? $rootItem['bookmark'] : [];
|
|
$bmId = (int) ($bm['id'] ?? 0);
|
|
$bmName = trim((string) ($bm['name'] ?? ''));
|
|
$bmUrl = trim((string) ($bm['url'] ?? ''));
|
|
$bmCanonicalUrl = BookmarkUrlNormalizer::canonicalizeRelative($bmUrl);
|
|
$bmActive = $bmCanonicalUrl !== '' && $currentPath === $bmCanonicalUrl;
|
|
?>
|
|
<li class="app-sidebar-bookmark-root-item app-sidebar-bookmark-item"
|
|
data-bookmark-root-kind="bookmark"
|
|
data-bookmark-root-id="<?php e($bmId); ?>"
|
|
data-bookmark-id="<?php e($bmId); ?>"
|
|
data-bookmark-name="<?php e($bmName); ?>"
|
|
data-bookmark-group-id="">
|
|
<a href="<?php e(lurl($bmUrl)); ?>"
|
|
class="<?php e($bmActive ? 'active' : ''); ?>"
|
|
<?php echo $bmActive ? 'aria-current="page"' : ''; ?>>
|
|
<?php e($bmName); ?>
|
|
</a>
|
|
<details class="app-sidebar-bookmark-action-menu" data-bookmark-action-menu>
|
|
<summary class="icon-button" title="<?php e(t('Actions')); ?>" aria-label="<?php e(t('Actions')); ?>">
|
|
<i class="bi bi-three-dots"></i>
|
|
</summary>
|
|
<ul class="app-sidebar-bookmark-action-menu-list" role="menu" aria-label="<?php e(t('Bookmark actions')); ?>">
|
|
<li>
|
|
<button type="button" role="menuitem" data-bookmark-item-action="edit">
|
|
<?php e(t('Edit')); ?>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button type="button" role="menuitem" data-bookmark-item-action="move-up" data-bookmark-item-action-scope="root" <?php if ($rootFirst): ?>disabled<?php endif; ?>>
|
|
<?php e(t('Move bookmark up')); ?>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button type="button" role="menuitem" data-bookmark-item-action="move-down" data-bookmark-item-action-scope="root" <?php if ($rootLast): ?>disabled<?php endif; ?>>
|
|
<?php e(t('Move bookmark down')); ?>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button type="button" role="menuitem" class="app-sidebar-bookmark-action-danger" data-bookmark-item-action="delete">
|
|
<?php e(t('Delete bookmark')); ?>
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
</details>
|
|
</li>
|
|
<?php else: ?>
|
|
<?php
|
|
$group = is_array($rootItem['group'] ?? null) ? $rootItem['group'] : [];
|
|
$gId = (int) ($group['id'] ?? 0);
|
|
$gName = trim((string) ($group['name'] ?? ''));
|
|
$gIcon = trim((string) ($group['icon'] ?? 'bi-folder'));
|
|
$gBookmarks = is_array($group['bookmarks'] ?? null) ? $group['bookmarks'] : [];
|
|
?>
|
|
<li class="app-sidebar-group app-sidebar-bookmark-group app-sidebar-bookmark-root-item"
|
|
data-bookmark-root-kind="group"
|
|
data-bookmark-root-id="<?php e($gId); ?>"
|
|
data-bookmark-group-id="<?php e($gId); ?>"
|
|
data-bookmark-group-name="<?php e($gName); ?>"
|
|
data-bookmark-group-icon="<?php e($gIcon); ?>">
|
|
<div class="app-sidebar-bookmark-group-shell">
|
|
<div class="app-sidebar-bookmark-group-header">
|
|
<small class="app-sidebar-bookmark-group-label">
|
|
<i class="bi <?php e($gIcon); ?>" aria-hidden="true"></i>
|
|
<span><?php e($gName); ?></span>
|
|
</small>
|
|
<details class="app-sidebar-bookmark-action-menu app-sidebar-bookmark-group-menu" data-bookmark-action-menu>
|
|
<summary class="icon-button" title="<?php e(t('Actions')); ?>" aria-label="<?php e(t('Actions')); ?>">
|
|
<i class="bi bi-three-dots"></i>
|
|
</summary>
|
|
<ul class="app-sidebar-bookmark-action-menu-list" role="menu" aria-label="<?php e(t('Group actions')); ?>">
|
|
<li>
|
|
<button type="button" role="menuitem" data-bookmark-group-action="edit">
|
|
<?php e(t('Edit')); ?>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button type="button" role="menuitem" data-bookmark-group-action="move-up" <?php if ($rootFirst): ?>disabled<?php endif; ?>>
|
|
<?php e(t('Move group up')); ?>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button type="button" role="menuitem" data-bookmark-group-action="move-down" <?php if ($rootLast): ?>disabled<?php endif; ?>>
|
|
<?php e(t('Move group down')); ?>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button type="button" role="menuitem" class="app-sidebar-bookmark-action-danger" data-bookmark-group-action="delete">
|
|
<?php e(t('Delete group')); ?>
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
</details>
|
|
</div>
|
|
<?php if ($gBookmarks): ?>
|
|
<ul data-bookmark-group-bookmark-list>
|
|
<?php $groupBookmarkCount = count($gBookmarks); ?>
|
|
<?php foreach ($gBookmarks as $bookmarkIndex => $bm): ?>
|
|
<?php
|
|
$bmId = (int) ($bm['id'] ?? 0);
|
|
$bmName = trim((string) ($bm['name'] ?? ''));
|
|
$bmUrl = trim((string) ($bm['url'] ?? ''));
|
|
$bmCanonicalUrl = BookmarkUrlNormalizer::canonicalizeRelative($bmUrl);
|
|
$bmActive = $bmCanonicalUrl !== '' && $currentPath === $bmCanonicalUrl;
|
|
$bookmarkFirst = $bookmarkIndex === 0;
|
|
$bookmarkLast = $bookmarkIndex === ($groupBookmarkCount - 1);
|
|
?>
|
|
<li class="app-sidebar-bookmark-item"
|
|
data-bookmark-id="<?php e($bmId); ?>"
|
|
data-bookmark-name="<?php e($bmName); ?>"
|
|
data-bookmark-group-id="<?php e($gId); ?>">
|
|
<a href="<?php e(lurl($bmUrl)); ?>"
|
|
class="<?php e($bmActive ? 'active' : ''); ?>"
|
|
<?php echo $bmActive ? 'aria-current="page"' : ''; ?>>
|
|
<?php e($bmName); ?>
|
|
</a>
|
|
<details class="app-sidebar-bookmark-action-menu" data-bookmark-action-menu>
|
|
<summary class="icon-button" title="<?php e(t('Actions')); ?>" aria-label="<?php e(t('Actions')); ?>">
|
|
<i class="bi bi-three-dots"></i>
|
|
</summary>
|
|
<ul class="app-sidebar-bookmark-action-menu-list" role="menu" aria-label="<?php e(t('Bookmark actions')); ?>">
|
|
<li>
|
|
<button type="button" role="menuitem" data-bookmark-item-action="edit">
|
|
<?php e(t('Edit')); ?>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button type="button" role="menuitem" data-bookmark-item-action="move-up" <?php if ($bookmarkFirst): ?>disabled<?php endif; ?>>
|
|
<?php e(t('Move bookmark up')); ?>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button type="button" role="menuitem" data-bookmark-item-action="move-down" <?php if ($bookmarkLast): ?>disabled<?php endif; ?>>
|
|
<?php e(t('Move bookmark down')); ?>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button type="button" role="menuitem" class="app-sidebar-bookmark-action-danger" data-bookmark-item-action="delete">
|
|
<?php e(t('Delete bookmark')); ?>
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
</details>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
</div>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
</nav>
|
|
</div>
|
|
</aside>
|