Add page publication history and reusable blocks
This commit is contained in:
+22
-22
@@ -14,8 +14,9 @@ $path = '/' . $slug;
|
||||
$home = $page['page_type'] === 'home';
|
||||
$pageTypes = LayoutPage::TYPES + SystemPage::TYPES;
|
||||
$layoutSlugs = array_column($designs, 'slug', 'id');
|
||||
$published = $page['status'] === 'published';
|
||||
$publicPage = !$page['layout_kind'] && in_array($page['page_type'], ['page', 'home'], true);
|
||||
$published = $publication !== null;
|
||||
$publicPage = $published && $publication['layout_kind'] === null && in_array($publication['page_type'], ['page', 'home'], true);
|
||||
$publicationLabel = !$published ? '草稿' : ($publication['version'] === $page['version'] ? '已发布' : '已发布 · 草稿有更新');
|
||||
$usesSitePalette = empty($page['theme']);
|
||||
$defaultPalette = $usesSitePalette && $defaultPaletteId !== null
|
||||
? (array_column($palettes, null, 'id')[$defaultPaletteId] ?? null) : null;
|
||||
@@ -45,7 +46,7 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<header class="admin-heading">
|
||||
<div><h1 data-page-editor-title><?= $e($title) ?></h1><p class="studio-page-meta">
|
||||
<?php if ($layout): ?><span class="dashboard-page-state"><?= $e(LayoutPage::TYPES[$layout['kind']]) ?></span>
|
||||
<?php else: ?><?php if ($systemLabel || $home): ?><span><?= $e($home ? '首页' : $systemLabel) ?></span><?php else: ?><code><?= $e($path) ?></code><?php endif ?><span class="dashboard-page-state" data-page-publication data-published="<?= $published ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span><?php endif ?>
|
||||
<?php else: ?><?php if ($systemLabel || $home): ?><span><?= $e($home ? '首页' : $systemLabel) ?></span><?php else: ?><code><?= $e($path) ?></code><?php endif ?><span class="dashboard-page-state" data-page-publication data-published="<?= $published ? 'true' : 'false' ?>"><?= $e($publicationLabel) ?></span><?php endif ?>
|
||||
</p></div>
|
||||
<div class="actions">
|
||||
<a class="button button-outline" href="#studio-page-settings"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>页面设置</a>
|
||||
@@ -62,12 +63,10 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<?php if ($systemLabel): ?><a class="button button-outline" href="/admin/settings"><?= View::fragment('studio-icon', ['icon' => 'settings']) ?>站点设置</a>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php if ($publicPage): ?>
|
||||
<span data-page-public<?= $published ? '' : ' hidden' ?>><?= View::fragment('admin-view-link', ['href' => $path, 'icon' => 'external']) ?></span>
|
||||
<?php endif ?>
|
||||
<span data-page-preview<?= $publicPage && $published ? ' hidden' : '' ?>>
|
||||
<?= View::fragment('admin-view-link', ['href' => $previewUrl, 'icon' => 'preview', 'label' => '预览已保存内容']) ?>
|
||||
</span>
|
||||
<a class="button button-outline" href="/admin/copy-page/<?= $e($slug) ?>"><?= View::fragment('studio-icon', ['icon' => 'copy']) ?>复制页面</a>
|
||||
<a class="button button-outline" href="/admin/page-history/<?= $e($slug) ?>"><?= View::fragment('studio-icon', ['icon' => 'history']) ?>版本历史</a>
|
||||
<span data-page-public<?= $publicPage ? '' : ' hidden' ?>><?= View::fragment('admin-view-link', ['href' => $publicPage ? '/' . $publication['slug'] : $path, 'icon' => 'external', 'label' => '查看公开页面']) ?></span>
|
||||
<?= View::fragment('admin-view-link', ['href' => $previewUrl, 'icon' => 'preview', 'label' => '预览已保存草稿']) ?>
|
||||
</div>
|
||||
</header>
|
||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||
@@ -76,7 +75,7 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<h2 id="studio-library-title">页面编辑</h2>
|
||||
<?= View::fragment('studio-templates', [
|
||||
'layers' => View::fragment('studio-layers', compact('page', 'slug', 'token')),
|
||||
'layoutKind' => $page['layout_kind'], 'slug' => $slug, 'token' => $token,
|
||||
'layoutKind' => $page['layout_kind'], 'slug' => $slug, 'token' => $token, 'reusableBlocks' => $reusableBlocks,
|
||||
]) ?>
|
||||
</aside>
|
||||
<div class="studio-workspace">
|
||||
@@ -133,7 +132,7 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<button class="button button-primary" form="studio-page-settings" type="submit"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存页面</button>
|
||||
</div>
|
||||
<div class="studio-frame-window">
|
||||
<iframe title="可编辑页面画布" src="<?= $e($previewUrl) ?>?canvas=1" sandbox="allow-same-origin"></iframe>
|
||||
<iframe title="可编辑页面画布" src="<?= $e($previewUrl) ?>?canvas=1" sandbox="allow-same-origin allow-popups allow-popups-to-escape-sandbox"></iframe>
|
||||
<div class="studio-element-tools" data-element-tools role="group" aria-label="所选元素" hidden>
|
||||
<div class="studio-element-align" data-element-align role="group" aria-label="对齐">
|
||||
<?php foreach (['left' => '居左', 'center' => '居中', 'right' => '居右'] as $value => $label): ?>
|
||||
@@ -237,7 +236,7 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
</dialog>
|
||||
</section>
|
||||
</div>
|
||||
<form id="studio-page-settings" class="admin-form admin-panel studio-inspector" data-save-inline data-public-page="<?= $publicPage ? '1' : '0' ?>" method="post" action="/admin/pages/<?= $e($slug) ?>">
|
||||
<form id="studio-page-settings" class="admin-form admin-panel studio-inspector" data-save-inline method="post" action="/admin/pages/<?= $e($slug) ?>">
|
||||
<h2>页面设置</h2>
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($page['version']) ?>">
|
||||
@@ -314,6 +313,7 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<details class="admin-options" data-shared-auth<?= $layoutHasMember ? '' : ' hidden' ?>>
|
||||
<summary>会员登录设置</summary>
|
||||
<?= View::fragment('design-provider-fields', ['item' => $layout, 'provider' => $layout['payload']['provider'], 'layoutHasMember' => $layoutHasMember]) ?>
|
||||
<?php if ($layoutSecretPending): ?><p class="field-note">客户端密钥已暂存,将在发布时生效。</p><?php endif ?>
|
||||
</details>
|
||||
<?php endif ?>
|
||||
<textarea name="hero_actions" hidden><?= $e(Database::json(Buttons::validate($page['actions']))) ?></textarea>
|
||||
@@ -337,16 +337,16 @@ $spacingPresets = [0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128];
|
||||
<p class="field-note">本页 Head 尚不可用。<?= $e(Database::MIGRATION_REQUIRED) ?></p>
|
||||
<?php endif ?>
|
||||
<div class="form-submit studio-settings-actions">
|
||||
<button class="button button-primary" type="submit"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存页面</button>
|
||||
<?php if (!$layout): ?>
|
||||
<div class="studio-publication">
|
||||
<span>发布状态</span><span class="dashboard-page-state" data-page-publication data-published="<?= $published ? 'true' : 'false' ?>"><?= $published ? '已发布' : '草稿' ?></span>
|
||||
<button class="button button-outline" type="submit" name="status" value="<?= $published ? 'draft' : 'published' ?>" data-publish-button>
|
||||
<span data-publication-action="published"<?= $published ? ' hidden' : '' ?>><?= View::fragment('studio-icon', ['icon' => 'publish']) ?>发布</span>
|
||||
<span data-publication-action="draft"<?= $published ? '' : ' hidden' ?>><?= View::fragment('studio-icon', ['icon' => 'unpublish']) ?>转为草稿</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<button class="button button-primary" type="submit" data-save-draft><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存草稿</button>
|
||||
<div class="studio-publication">
|
||||
<span>发布状态</span><span class="dashboard-page-state" data-page-publication data-published="<?= $published ? 'true' : 'false' ?>"><?= $e($publicationLabel) ?></span>
|
||||
<button class="button button-outline" type="submit" name="status" value="published" data-publish-button>
|
||||
<?= View::fragment('studio-icon', ['icon' => 'publish']) ?><span data-publish-label><?= $published ? '发布更新' : '发布' ?></span>
|
||||
</button>
|
||||
<button class="button button-outline" type="submit" name="status" value="draft" data-unpublish-button data-confirm="撤下此页面的公开版本?"<?= $published ? '' : ' hidden' ?>>
|
||||
<?= View::fragment('studio-icon', ['icon' => 'unpublish']) ?>撤下发布
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="feedback success" data-page-save-feedback role="status" hidden></p>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user