forked from laysense/laysense.cn
Migrate Laysense to upstream LaySite 1.4.3 with external site data
This commit is contained in:
@@ -1,41 +1,69 @@
|
||||
<?php
|
||||
use App\Content\LayoutPage;
|
||||
use App\Content\SystemPage;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$live = count(array_filter($pages, static fn (array $page): bool => $page['status'] === 'published'));
|
||||
$pageTypeLabels = LayoutPage::TYPES + SystemPage::TYPES;
|
||||
$regular = array_filter($pages, static fn (array $page): bool => $page['layout_kind'] === null && $page['page_type'] === 'page');
|
||||
$live = count(array_filter($regular, static fn (array $page): bool => $page['status'] === 'published'));
|
||||
$defaultSlugs = [];
|
||||
foreach (['header', 'footer'] as $kind) {
|
||||
if (isset($site[$kind . '_id'])) {
|
||||
$defaultSlugs[$kind] = LayoutPage::slug($kind, $site[$kind . '_id']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<header class="admin-heading dashboard-heading">
|
||||
<h1>网站后台</h1>
|
||||
<div class="actions">
|
||||
<a class="button button-primary" href="/admin/new-page">新建页面</a>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
|
||||
<a class="button button-outline" href="/admin/articles/new">写文章</a>
|
||||
<a class="button button-primary" href="/admin/new-page"><?= View::fragment('studio-icon', ['icon' => 'add']) ?>新建页面</a>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden><?= View::fragment('studio-icon', ['icon' => 'templates']) ?>整页模板</button>
|
||||
<a class="button button-outline" href="/admin/articles/new"><?= View::fragment('studio-icon', ['icon' => 'edit']) ?>写文章</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="dashboard-grid">
|
||||
<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>
|
||||
<label>发布状态<select data-page-status>
|
||||
<option value="">全部状态</option>
|
||||
<label>状态或类型<select data-page-status>
|
||||
<option value="">全部页面</option>
|
||||
<option value="published">已发布</option>
|
||||
<option value="draft">草稿</option>
|
||||
<option value="header">页头</option>
|
||||
<option value="footer">页脚</option>
|
||||
<?php foreach (SystemPage::TYPES as $type => $label): ?><option value="<?= $e($type) ?>"><?= $e($label) ?></option><?php endforeach ?>
|
||||
</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
|
||||
$type = $page['page_type'];
|
||||
$kind = $page['layout_kind'] ?? (isset(SystemPage::TYPES[$type]) ? $type : null);
|
||||
$label = $kind === null ? '' : ($pageTypeLabels[$kind] ?? '');
|
||||
$path = $page['slug'] === 'home' ? '/' : '/' . $page['slug'];
|
||||
$published = $page['status'] === 'published';
|
||||
$public = $kind === null && $published;
|
||||
?>
|
||||
<li data-page-item="<?= $e($kind ?? $page['status']) ?>" data-page-label="<?= $e($page['name'] . ' ' . $page['title'] . ' ' . ($kind ? $label : $path)) ?>">
|
||||
<div class="dashboard-page-label"><strong><?= $e($page['name']) ?></strong>
|
||||
<?php if ($kind === null): ?><small><?= $e($path) ?></small>
|
||||
<?php elseif (($defaultSlugs[$kind] ?? null) === $page['slug']): ?><small>站点默认</small>
|
||||
<?php elseif (($site['system_pages'][$kind] ?? null) === $page['slug']): ?><small><?= $kind === 'maintenance' ? ($site['maintenance_enabled'] ? '维护模式已开启' : '已选作维护页') : '已启用为 404 页' ?></small><?php endif ?>
|
||||
</div>
|
||||
<span class="dashboard-page-state" data-published="<?= !$page['layout_kind'] && $published ? 'true' : 'false' ?>"><?= $kind ? $e($label) : ($published ? '已发布' : '草稿') ?><?= isset(SystemPage::TYPES[$type]) ? ($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>
|
||||
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>"><?= View::fragment('studio-icon', ['icon' => 'edit']) ?>编辑页面</a>
|
||||
<?= View::fragment('admin-view-link', [
|
||||
'href' => $public ? $path : '/admin/pages/' . $page['slug'] . '/preview',
|
||||
'icon' => $public ? 'external' : 'preview',
|
||||
'label' => ($public ? '查看公开页面' : '预览页面') . ' · ' . $page['name'],
|
||||
]) ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
@@ -50,10 +78,8 @@ $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/settings/header">编辑页头</a></li>
|
||||
<li><a class="button button-outline" href="/admin/settings/footer">编辑页脚</a></li>
|
||||
<li><a class="button button-outline" href="/admin/settings/cdn">静态资源 CDN</a></li>
|
||||
<li><a class="button button-outline" href="/admin/media">打开媒体库</a></li>
|
||||
<li><a class="button button-outline" href="/admin/settings"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>站点设置</a></li>
|
||||
<li><a class="button button-outline" href="/admin/media"><?= View::fragment('studio-icon', ['icon' => 'media']) ?>打开媒体库</a></li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user