<?php
/**
 * 公告详情：与帖子详情一样展示完整 HTML 正文
 */
$me = current_user();
$id = (int) input('id');
$notice = announcement_by_id($id);
if (!$notice || ((int) $notice['status'] !== 1 && !is_admin($me))) {
    $GLOBALS['PAGE'] = 'announcements';
    render_header('公告不存在');
    empty_state('没有找到这条公告', '可能已被撤回或删除');
    render_footer();
    return;
}
$author = announcement_author($notice);
$GLOBALS['PAGE'] = 'announcements';
render_header($notice['title']);
?>
<section class="notice-detail">
  <div class="notice-detail-head">
    <a class="link-btn" href="<?= e(page_url('announcements')) ?>">← 返回公告列表</a>
    <span class="announcement-kind-pill"><?= e(announcement_kind_label($notice['kind'])) ?></span>
  </div>
  <h1><?= e($notice['title']) ?></h1>
  <div class="notice-detail-meta">
    <?php if ($author): ?>
      <a class="notice-author" href="<?= e(page_url('user', ['id' => (int) $author['id']])) ?>">
        <?= verified_avatar_html($author, 'notice-avatar', 'notice-avatar-wrap') ?>
        <span><strong><?= e(display_name($author)) ?></strong><?= verify_badge($author, true) ?><small><?= is_official_account($author) ? '官方固定账号 · ' : '' ?><?= e(username_visible($author)) ?></small></span>
      </a>
    <?php endif; ?>
    <span class="muted">发布于 <?= e($notice['updated_at'] !== '' ? $notice['updated_at'] : $notice['created_at']) ?></span>
  </div>
  <article class="notice-body announcement-body"><?= announcement_content_html($notice) ?></article>
</section>
<?php render_footer(); ?>
