WebOrbiton
v3.0.0.2

FlatlyPage

84 lines · 5.5 KB
  1. <?php
  2. function admin_admin_data(): array
  3. {
  4. static $data = null;
  5. if ($data === null) {
  6. $file = DATA_DIR . '/admin.json';
  7. $data = is_file($file) ? (json_decode(file_get_contents($file), true) ?: []) : [];
  8. }
  9. return $data;
  10. }
  11. ​
  12. function admin_sidebar(string $active): void
  13. {
  14. $adminData = admin_admin_data();
  15. $username = (string) ($adminData['username'] ?? 'admin');
  16. $items = [
  17. 'Content' => [
  18. ['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" />'],
  19. ['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>'],
  20. ],
  21. 'Site' => [
  22. ['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" />'],
  23. ['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" />'],
  24. ['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" />'],
  25. ],
  26. 'CMS' => [
  27. ['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" />'],
  28. ],
  29. 'Newsletter' => [
  30. ['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" />'],
  31. ['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>'],
  32. ],
  33. 'Quick Actions' => [
  34. ['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" />'],
  35. ['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" />'],
  36. ],
  37. ];
  38. ?>
  39. <aside class="sidebar">
  40. <button class="mobile-nav-toggle" onclick="document.querySelector('.sidebar').classList.remove('open')">
  41. <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
  42. <line x1="6" y1="6" x2="18" y2="18" />
  43. <line x1="6" y1="18" x2="18" y2="6" />
  44. </svg>
  45. </button>
  46. ​
  47. <div class="sidebar-header">
  48. <div class="sidebar-logo">
  49. <img src="/logos/flatlypage_light.svg" alt="Logo" style="width: 20px;">
  50. <span>FlatlyPage CMS</span>
  51. </div>
  52. </div>
  53. ​
  54. <nav class="sidebar-nav">
  55. <?php foreach ($items as $label => $links): ?>
  56. <div class="nav-section">
  57. <div class="nav-label"><?= e($label) ?></div>
  58. <?php foreach ($links as [$key, $href, $text, $icon]): ?>
  59. <a href="<?= e($href) ?>"<?= $key === 'view-site' ? ' target="_blank"' : '' ?> class="nav-item<?= $key === $active ? ' active' : '' ?>">
  60. <svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"><?= $icon ?></svg>
  61. <?= e($text) ?>
  62. </a>
  63. <?php endforeach; ?>
  64. </div>
  65. <?php endforeach; ?>
  66. </nav>
  67. ​
  68. <div class="sidebar-footer">
  69. <a href="/admin/account.php" class="user-menu<?= $active === 'account' ? ' active' : '' ?>">
  70. <div class="user-avatar">
  71. <?= e(strtoupper(substr($username, 0, 1))) ?>
  72. </div>
  73. <div class="user-info">
  74. <div class="user-name">
  75. <?= e($username) ?>
  76. </div>
  77. <div class="user-role">Account Settings</div>
  78. </div>
  79. </a>
  80. </div>
  81. </aside>
  82. <?php
  83. }
  84. ​