Edit shared headers and footers as page types

This commit is contained in:
2026-11-23 20:58:42 +08:00
parent 636788b65c
commit 9d386dd39c
40 changed files with 725 additions and 937 deletions
+10 -8
View File
@@ -1,8 +1,10 @@
<?php
use App\Content\LayoutPage;
use App\Content\View;
$e = View::escape(...);
$live = count(array_filter($pages, static fn (array $page): bool => $page['status'] === 'published'));
$regular = array_filter($pages, static fn (array $page): bool => $page['layout_kind'] === null);
$live = count(array_filter($regular, static fn (array $page): bool => $page['status'] === 'published'));
?>
<header class="admin-heading dashboard-heading">
<h1>网站后台</h1>
@@ -16,7 +18,7 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu
<section class="admin-panel dashboard-pages" aria-labelledby="pages-title" data-page-list>
<div class="admin-heading compact">
<h2 id="pages-title">网站页面</h2>
<p class="field-note"><?= $live ?> 个已发布 · <?= count($pages) - $live ?> 个草稿</p>
<p class="field-note"><?= $live ?> 个已发布 · <?= count($regular) - $live ?> 个草稿 · <?= count($pages) - count($regular) ?> 个页头页脚</p>
</div>
<div class="dashboard-filters" data-page-filters hidden>
<label>查找页面<input type="search" data-page-search placeholder="页面名称或地址"></label>
@@ -24,15 +26,17 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu
<option value="">全部状态</option>
<option value="published">已发布</option>
<option value="draft">草稿</option>
<option value="header">页头</option>
<option value="footer">页脚</option>
</select></label>
</div>
<p class="empty-state" data-page-empty role="status"<?= $pages ? ' hidden' : '' ?>><?= $pages ? '没有匹配的页面。' : '暂无页面。' ?></p>
<ul class="admin-list dashboard-page-list">
<?php foreach ($pages as $page): ?>
<?php $path = $page['slug'] === 'home' ? '/' : '/' . $page['slug']; $published = $page['status'] === 'published'; ?>
<li data-page-item="<?= $e($page['status']) ?>" data-page-label="<?= $e($page['name'] . ' ' . $page['title'] . ' ' . $path) ?>">
<div class="dashboard-page-label"><strong><?= $e($page['name']) ?></strong><small><?= $e($path) ?></small></div>
<span class="dashboard-page-state" data-published="<?= $published ? 'true' : 'false' ?>"><?= $published ? '已发布' : '草稿' ?></span>
<?php $kind = $page['layout_kind']; $path = $page['slug'] === 'home' ? '/' : '/' . $page['slug']; $published = $kind === null && $page['status'] === 'published'; ?>
<li data-page-item="<?= $e($kind ?? $page['status']) ?>" data-page-label="<?= $e($page['name'] . ' ' . $page['title'] . ' ' . ($kind ? LayoutPage::TYPES[$kind] : $path)) ?>">
<div class="dashboard-page-label"><strong><?= $e($page['name']) ?></strong><?php if (!$kind): ?><small><?= $e($path) ?></small><?php endif ?></div>
<span class="dashboard-page-state" data-published="<?= $published ? 'true' : 'false' ?>"><?= $kind ? $e(LayoutPage::TYPES[$kind]) : ($published ? '已发布' : '草稿') ?></span>
<div class="dashboard-page-actions">
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>">编辑页面</a>
<a href="<?= $e($published ? $path : '/admin/pages/' . $page['slug'] . '/preview') ?>" target="_blank" rel="noopener"><?= $published ? '查看' : '预览' ?></a>
@@ -50,8 +54,6 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu
<section class="admin-panel dashboard-settings" aria-labelledby="quick-title">
<h2 id="quick-title">站点编辑</h2>
<ul class="dashboard-setting-buttons">
<li><a class="button button-outline" href="/admin/design/header/new">新建页头</a></li>
<li><a class="button button-outline" href="/admin/design/footer/new">新建页脚</a></li>
<li><a class="button button-outline" href="/admin/settings">站点设置</a></li>
<li><a class="button button-outline" href="/admin/media">打开媒体库</a></li>
</ul>