list.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. $pageTitle = 'Dynamic Pages - Admin Panel';
  3. $headerTitle = 'Dynamic Pages';
  4. ob_start();
  5. ?>
  6. <?php if (isset($success)): ?>
  7. <div class="bg-green-50 border border-green-200 rounded-lg p-4 mb-6">
  8. <div class="flex">
  9. <svg class="w-5 h-5 text-green-400 mr-3 mt-0.5" fill="currentColor" viewBox="0 0 20 20">
  10. <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
  11. </svg>
  12. <p class="text-sm text-green-700"><?= htmlspecialchars($success) ?></p>
  13. </div>
  14. </div>
  15. <?php endif; ?>
  16. <?php if (isset($error)): ?>
  17. <div class="bg-red-50 border border-red-200 rounded-lg p-4 mb-6">
  18. <div class="flex">
  19. <svg class="w-5 h-5 text-red-400 mr-3 mt-0.5" fill="currentColor" viewBox="0 0 20 20">
  20. <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
  21. </svg>
  22. <p class="text-sm text-red-700"><?= htmlspecialchars($error) ?></p>
  23. </div>
  24. </div>
  25. <?php endif; ?>
  26. <div class="bg-white shadow rounded-lg">
  27. <div class="px-6 py-4 border-b border-gray-200 flex justify-between items-center">
  28. <h3 class="text-lg font-medium text-gray-900">Pages</h3>
  29. <a href="/admin/pages/?action=create" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors">
  30. <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
  31. <path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd"/>
  32. </svg>
  33. New Page
  34. </a>
  35. </div>
  36. <?php if (!empty($pages)): ?>
  37. <div class="overflow-x-auto">
  38. <table class="min-w-full divide-y divide-gray-200">
  39. <thead class="bg-gray-50">
  40. <tr>
  41. <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
  42. <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Slug</th>
  43. <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Layout</th>
  44. <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Homepage</th>
  45. <th scope="col" class="relative px-6 py-3"><span class="sr-only">Actions</span></th>
  46. </tr>
  47. </thead>
  48. <tbody class="bg-white divide-y divide-gray-200">
  49. <?php foreach ($pages as $page): ?>
  50. <tr class="hover:bg-gray-50">
  51. <td class="px-6 py-4 whitespace-nowrap">
  52. <div class="text-sm font-medium text-gray-900"><?= htmlspecialchars($page['name']) ?></div>
  53. <?php if (!empty($page['title'])): ?>
  54. <div class="text-sm text-gray-500"><?= htmlspecialchars($page['title']) ?></div>
  55. <?php endif; ?>
  56. </td>
  57. <td class="px-6 py-4 whitespace-nowrap">
  58. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
  59. <?= htmlspecialchars($page['slug']) ?>
  60. </span>
  61. </td>
  62. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
  63. <?= htmlspecialchars($layouts[$page['layout']] ?? $page['layout']) ?>
  64. </td>
  65. <td class="px-6 py-4 whitespace-nowrap">
  66. <?php if ($page['is_homepage']): ?>
  67. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
  68. <svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20">
  69. <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
  70. </svg>
  71. Homepage
  72. </span>
  73. <?php else: ?>
  74. <span class="text-gray-400">-</span>
  75. <?php endif; ?>
  76. </td>
  77. <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
  78. <div class="flex justify-end space-x-2">
  79. <a href="/admin/pages/?action=edit&id=<?= $page['id'] ?>"
  80. class="inline-flex items-center px-3 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors">
  81. <svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
  82. <path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"/>
  83. </svg>
  84. Edit
  85. </a>
  86. <form method="POST" action="/admin/pages/" class="inline-block" onsubmit="return confirm('Are you sure you want to delete this page?')">
  87. <input type="hidden" name="action" value="delete">
  88. <input type="hidden" name="id" value="<?= $page['id'] ?>">
  89. <button type="submit"
  90. class="inline-flex items-center px-3 py-1.5 border border-red-300 shadow-sm text-xs font-medium rounded text-red-700 bg-red-50 hover:bg-red-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-colors">
  91. <svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
  92. <path fill-rule="evenodd" d="M9 2a1 1 0 000 2h2a1 1 0 100-2H9z" clip-rule="evenodd"/>
  93. <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8 7a1 1 0 012 0v4a1 1 0 11-2 0V7zm0 8a1 1 0 012 0v.01a1 1 0 11-2 0V15z" clip-rule="evenodd"/>
  94. </svg>
  95. Delete
  96. </button>
  97. </form>
  98. </div>
  99. </td>
  100. </tr>
  101. <?php endforeach; ?>
  102. </tbody>
  103. </table>
  104. </div>
  105. <?php else: ?>
  106. <div class="text-center py-12">
  107. <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  108. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
  109. </svg>
  110. <h3 class="mt-2 text-sm font-medium text-gray-900">No pages</h3>
  111. <p class="mt-1 text-sm text-gray-500">Get started by creating a new page.</p>
  112. <div class="mt-6">
  113. <a href="/admin/pages/?action=create" class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors">
  114. <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
  115. <path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd"/>
  116. </svg>
  117. New Page
  118. </a>
  119. </div>
  120. </div>
  121. <?php endif; ?>
  122. </div>
  123. <?php
  124. $content = ob_get_clean();
  125. include __DIR__ . '/../partials/layout.php';
  126. ?>