<?php
$page_title = '动态';
include_once 'header.php';

$items = [];
$result = $conn->query("SELECT id, logo, activities_title, activities_txt, activities_link FROM activities ORDER BY sid ASC, id ASC");
if ($result) {
    $items = $result->fetch_all(MYSQLI_ASSOC);
}
?>
<body>
<div id="app" class="mobile-shell">
    <main class="page dynamic-page">
        <section class="top-card slim">
            <div class="brand-block">
                <img class="brand-logo" src="<?php echo e($logo); ?>" alt="木木导航">
                <div>
                    <h1>公告动态</h1>
                </div>
            </div>
        </section>

        <section class="poster-list">
            <?php if (!empty($items)): ?>
                <?php foreach ($items as $item): ?>
                    <?php $href = activity_jump_url($item['id'], $item['activities_link']); ?>
                    <a class="poster-card" href="<?php echo e($href); ?>" target="_blank" rel="noopener nofollow">
                        <img class="poster-img" src="<?php echo e($item['logo'] ?: $logo); ?>" alt="<?php echo e($item['activities_title']); ?>">
                        <div class="poster-body">
                            <div class="poster-badge">木木公告</div>
                            <h2><?php echo e($item['activities_title']); ?></h2>
                            <p><?php echo nl2br(e($item['activities_txt'])); ?></p>
                        </div>
                    </a>
                <?php endforeach; ?>
            <?php else: ?>
                <div class="empty-card">暂无公告</div>
            <?php endif; ?>
        </section>
    </main>
    <?php include 'footer.php'; renderNavigation('dynamic'); ?>
</div>
</body>
</html>
