44 lines
2.8 KiB
PHP
44 lines
2.8 KiB
PHP
<?php
|
|
$v = function ($k, $d = '') use ($n) { return $n ? ($n[$k] ?? $d) : $d; };
|
|
$isEdit = !empty($n);
|
|
?>
|
|
<div class="page-head">
|
|
<div><h1><?php echo $isEdit ? '编辑新闻' : '写新闻'; ?></h1></div>
|
|
<a class="btn-ghost" href="<?php echo site_url('admin/news'); ?>">← 返回</a>
|
|
</div>
|
|
<div class="admin-card">
|
|
<form id="pbForm" method="post" action="<?php echo site_url($isEdit ? 'admin/news/update/' . $n['id'] : 'admin/news/store'); ?>" enctype="multipart/form-data">
|
|
<?php echo csrf_field(); ?>
|
|
<div class="field"><label>标题 *</label><input name="title" value="<?php echo e($v('title')); ?>" required></div>
|
|
<div class="form-grid">
|
|
<div class="field"><label>作者</label><input name="author" value="<?php echo e($v('author', '酷冰甲')); ?>"></div>
|
|
<div class="field"><label>发布日期</label><input type="date" name="published_at" value="<?php echo e($v('published_at', date('Y-m-d'))); ?>"></div>
|
|
</div>
|
|
<div class="field"><label>摘要</label><input name="summary" value="<?php echo e($v('summary')); ?>"></div>
|
|
<div class="field"><label>URL 标识(留空按序号生成,短而稳定)</label><input name="slug" value="<?php echo e($v('slug')); ?>" placeholder="留空则自动生成如 12"></div>
|
|
<div class="field">
|
|
<label>正文(可视化编辑)</label>
|
|
<p class="pb-hint" style="margin:0 0 8px">下方为可视化编辑器:上传素材、拖拽文字/图片/按钮自由排版,拖动右下角缩放、双击文字直接编辑。保存后前台按此布局整页展示。</p>
|
|
<?php
|
|
$layoutJson = $v('layout');
|
|
$layoutArr = $layoutJson ? @json_decode($layoutJson, true) : [];
|
|
if (!is_array($layoutArr)) $layoutArr = [];
|
|
echo \Core\View::buffer('admin/parts/builder', ['module' => 'news', 'layout' => $layoutArr]);
|
|
?>
|
|
<input type="hidden" name="content" value="<?php echo e($v('content')); ?>">
|
|
<input type="hidden" name="layout" id="pbLayout">
|
|
</div>
|
|
<div class="form-grid">
|
|
<div class="field"><label>封面图(上传,可选)</label><input type="file" name="cover" accept="image/*"></div>
|
|
<div class="field"><label>或图片地址</label><input name="cover_url" value="<?php echo e($v('cover')); ?>"></div>
|
|
</div>
|
|
<div class="field" style="display:flex;align-items:center;gap:8px">
|
|
<input type="checkbox" name="status" value="1" <?php echo $v('status', 1) ? 'checked' : ''; ?> id="st"> <label for="st" style="margin:0">立即发布</label>
|
|
</div>
|
|
<div class="form-actions">
|
|
<button class="btn-primary" type="submit">保存</button>
|
|
<a class="btn-ghost" href="<?php echo site_url('admin/news'); ?>">取消</a>
|
|
</div>
|
|
</form>
|
|
</div>
|