NewHome/notice.php

59 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* notice.php —— 更新公告(前台展示页)
* 数据来自 notices 表由后台「更新公告管理」admin/notice.php维护
* 展示每条公告的发布时间与最后修改时间,内容支持超链接与换行。
*/
$P = '';
require_once __DIR__ . '/includes/layout.php';
$pdo = db();
// 置顶优先;其余按发布时间倒序(旧公告保留、顺次展示)
$notices = $pdo->query('SELECT * FROM notices WHERE enabled = 1 ORDER BY pinned DESC, created_at DESC, id DESC')->fetchAll();
layout_head('更新公告');
?>
<div class="func-bar">
<div class="wrap func-bar-inner">
<a class="btn btn-sm" href="index.php" title="返回首页">← 返回首页</a>
<span class="func-bar-title">更新公告</span>
<span class="spacer"></span>
</div>
</div>
<main class="page-main">
<div class="wrap page-body">
<?php if (!$notices): ?>
<div class="panel-card">
<p class="tip" style="margin:0">暂无更新公告。</p>
</div>
<?php else: ?>
<?php foreach ($notices as $n): ?>
<?php
$title = trim((string) $n['title']);
$created = (string) $n['created_at'];
$updated = (string) $n['updated_at'];
?>
<div class="notice-item">
<h2 class="notice-title">
<?php if ((int) $n['pinned'] === 1): ?><span class="badge badge-ok">置顶</span><?php endif; ?>
<?= $title !== '' ? he($title) : '公告' ?>
</h2>
<div class="notice-meta">
<?php if ($created !== ''): ?><span>发布时间:<?= he($created) ?></span><?php endif; ?>
<?php if ($updated !== ''): ?>
<span>最后修改:<?= he($updated) ?><?= ($updated === $created) ? '(未修改)' : '' ?></span>
<?php endif; ?>
</div>
<div class="notice-body"><?= notice_html((string) $n['content']) ?></div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</main>
<?php layout_theme_fab(); ?>
<script src="assets/js/common.js"></script>
</body>
</html>