v3.0.0.2
FlatlyPage
- <?php
- function admin_admin_data(): array
- {
- static $data = null;
- if ($data === null) {
- $file = DATA_DIR . '/admin.json';
- $data = is_file($file) ? (json_decode(file_get_contents($file), true) ?: []) : [];
- }
- return $data;
- }
-
- function admin_sidebar(string $active): void
- {
- $adminData = admin_admin_data();
- $username = (string) ($adminData['username'] ?? 'admin');
- $items = [
- 'Content' => [
- ['index', '/admin/dashboard.php?tab=index', 'Homepage', '<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" /><polyline points="9 22 9 12 15 12 15 22" />'],
- ['products', '/admin/dashboard.php?tab=products', 'Pages', '<rect x="2" y="3" width="20" height="18" rx="2"></rect><rect x="3" y="4" width="18" height="6" fill="currentColor" opacity="0.3" stroke="none"></rect><line x1="6" y1="14" x2="14" y2="14"></line><line x1="6" y1="17" x2="11" y2="17"></line>'],
- ],
- 'Site' => [
- ['settings', '/admin/dashboard.php?tab=settings', 'Settings', '<circle cx="12" cy="12" r="3" /><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" />'],
- ['themes', '/admin/themes.php', 'Themes', '<path d="M20 7h-3a2 2 0 0 1-2-2V2" /><path d="M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z" /><path d="M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8" />'],
- ['updater', '/admin/updater.php', 'Updater', '<path d="M23 4v6h-6" /><path d="M1 20v-6h6" /><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" />'],
- ],
- 'CMS' => [
- ['system', '/admin/system.php', 'System', '<rect x="4" y="4" width="16" height="16" rx="2" /><rect x="9" y="9" width="6" height="6" /><path d="M9 1v3M15 1v3M9 20v3M15 20v3M20 9h3M20 14h3M1 9h3M1 14h3" />'],
- ],
- 'Newsletter' => [
- ['newsletter-settings', '/newsletter/settings.php', 'Settings', '<line x1="4" y1="21" x2="4" y2="14" /><line x1="4" y1="10" x2="4" y2="3" /><line x1="12" y1="21" x2="12" y2="12" /><line x1="12" y1="8" x2="12" y2="3" /><line x1="20" y1="21" x2="20" y2="16" /><line x1="20" y1="12" x2="20" y2="3" /><line x1="1" y1="14" x2="7" y2="14" /><line x1="9" y1="8" x2="15" y2="8" /><line x1="17" y1="16" x2="23" y2="16" />'],
- ['newsletter-manager', '/newsletter/manager.php', 'Manager', '<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline>'],
- ],
- 'Quick Actions' => [
- ['new', '/admin/dashboard.php?tab=new', 'New Page', '<circle cx="12" cy="12" r="10" /><line x1="12" y1="8" x2="12" y2="16" /><line x1="8" y1="12" x2="16" y2="12" />'],
- ['view-site', '/', 'View Site', '<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /><polyline points="15 3 21 3 21 9" /><line x1="10" y1="14" x2="21" y2="3" />'],
- ],
- ];
- ?>
- <aside class="sidebar">
- <button class="mobile-nav-toggle" onclick="document.querySelector('.sidebar').classList.remove('open')">
- <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
- <line x1="6" y1="6" x2="18" y2="18" />
- <line x1="6" y1="18" x2="18" y2="6" />
- </svg>
- </button>
-
- <div class="sidebar-header">
- <div class="sidebar-logo">
- <img src="/logos/flatlypage_light.svg" alt="Logo" style="width: 20px;">
- <span>FlatlyPage CMS</span>
- </div>
- </div>
-
- <nav class="sidebar-nav">
- <?php foreach ($items as $label => $links): ?>
- <div class="nav-section">
- <div class="nav-label"><?= e($label) ?></div>
- <?php foreach ($links as [$key, $href, $text, $icon]): ?>
- <a href="<?= e($href) ?>"<?= $key === 'view-site' ? ' target="_blank"' : '' ?> class="nav-item<?= $key === $active ? ' active' : '' ?>">
- <svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"><?= $icon ?></svg>
- <?= e($text) ?>
- </a>
- <?php endforeach; ?>
- </div>
- <?php endforeach; ?>
- </nav>
-
- <div class="sidebar-footer">
- <a href="/admin/account.php" class="user-menu<?= $active === 'account' ? ' active' : '' ?>">
- <div class="user-avatar">
- <?= e(strtoupper(substr($username, 0, 1))) ?>
- </div>
- <div class="user-info">
- <div class="user-name">
- <?= e($username) ?>
- </div>
- <div class="user-role">Account Settings</div>
- </div>
- </a>
- </div>
- </aside>
- <?php
- }
-