<?php
/**
 * 芋头CMS - 模板标签帮助
 */
$action = isset($_GET['action']) ? $_GET['action'] : 'list';

if ($action === 'list') {
    ?>
    <div class="page-container fade-in">
        <div class="page-header">
            <div class="page-title">
                <div class="page-icon"><svg style="width:22px;height:22px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"/><line x1="7" y1="7" x2="7.01" y2="7"/></svg></div>
                <div>
                    <h1>模板标签帮助</h1>
                    <p style="font-size:12px;color:var(--gray-500);margin:0;">前台模板开发标签参考手册</p>
                </div>
            </div>
        </div>

        <style>
        .tag-section { margin-bottom: 28px; }
        .tag-section-title {
            font-size: 15px;
            font-weight: 700;
            color: #1e293b;
            padding: 10px 16px;
            background: linear-gradient(135deg, #f0fdf4, #dcfce7);
            border-radius: 8px 8px 0 0;
            border: 1px solid #bbf7d0;
            border-bottom: none;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .tag-section-title .num {
            background: #16a34a;
            color: #fff;
            font-size: 11px;
            font-weight: 700;
            padding: 2px 8px;
            border-radius: 10px;
        }
        .tag-table { width: 100%; border-collapse: collapse; border: 1px solid #e2e8f0; border-radius: 0 0 8px 8px; overflow: hidden; }
        .tag-table th {
            background: #f8fafc;
            padding: 10px 16px;
            text-align: left;
            font-size: 12px;
            font-weight: 600;
            color: #475569;
            border-bottom: 1px solid #e2e8f0;
        }
        .tag-table td {
            padding: 10px 16px;
            font-size: 13px;
            border-bottom: 1px solid #f1f5f9;
            vertical-align: top;
        }
        .tag-table tr:last-child td { border-bottom: none; }
        .tag-table tr:hover td { background: #f8fafc; }
        .tag-table .tag-label { font-family: 'Courier New', monospace; font-size: 12px; color: #7c3aed; background: #f5f3ff; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
        .tag-table .tagType-0 { font-family: 'Courier New', monospace; font-size: 11px; color: #16a34a; background: #f0fdf4; padding: 2px 6px; border-radius: 4px; }
        .tag-table .tagType-1 { font-family: 'Courier New', monospace; font-size: 11px; color: #2563eb; background: #eff6ff; padding: 2px 6px; border-radius: 4px; }
        .tag-table .tagType-2 { font-family: 'Courier New', monospace; font-size: 11px; color: #d97706; background: #fffbeb; padding: 2px 6px; border-radius: 4px; }
        .tag-table .tagType-3 { font-family: 'Courier New', monospace; font-size: 11px; color: #dc2626; background: #fef2f2; padding: 2px 6px; border-radius: 4px; }
        .tag-table .tagType-4 { font-family: 'Courier New', monospace; font-size: 11px; color: #9333ea; background: #faf5ff; padding: 2px 6px; border-radius: 4px; }
        .tag-table .tagType-5 { font-family: 'Courier New', monospace; font-size: 11px; color: #0891b2; background: #ecfeff; padding: 2px 6px; border-radius: 4px; }
        .tag-desc { color: #64748b; font-size: 12px; line-height: 1.5; }
        .tag-example { color: #16a34a; font-size: 12px; background: #f0fdf4; padding: 6px 10px; border-radius: 6px; font-family: 'Courier New', monospace; margin-top: 4px; display: block; word-break: break-all; }
        .tag-example .comment { color: #94a3b8; }
        .tag-note { margin-top: 6px; font-size: 11px; color: #d97706; background: #fffbeb; padding: 4px 8px; border-radius: 4px; display: inline-block; }
        .tag-table td:nth-child(3) { min-width: 200px; }
        .tag-table td:nth-child(4) { min-width: 260px; }
        .intro-box {
            background: linear-gradient(135deg, #eff6ff, #dbeafe);
            border: 1px solid #bfdbfe;
            border-radius: 8px;
            padding: 16px 20px;
            margin-bottom: 24px;
            font-size: 13px;
            color: #1e40af;
            line-height: 1.7;
        }
        .intro-box strong { color: #1d4ed8; }
        .intro-box code { background: #dbeafe; padding: 1px 5px; border-radius: 3px; font-family: 'Courier New', monospace; }
        </style>

        <div class="intro-box">
            <strong>使用说明：</strong> 前台模板位于<code>template/default/</code> 目录，模板语法为<strong>原生 PHP</strong>（非 Smarty）。
            所有标签在 <code>public/index.php</code> 分配模板时赋值，前台模板直接通过<code>&lt;?php echo ... ?&gt;</code> 输出。
            所有输出建议加 <code>htmlspecialchars()</code> 防止 XSS。
        </div>

        <!-- 分类1：网站配置 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="num">1</span> 网站配置标签 — 后台「系统设置 → 网站设置」</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">类型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">{$siteConfig['site_name']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">网站名称</td><td><code class="tag-example">&lt;a href="/"&gt;&lt;?php echo $siteConfig['site_name']; ?&gt;&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_title']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">网站标题（浏览器标签栏）</td><td><code class="tag-example">&lt;title&gt;&lt;?php echo $siteConfig['site_title']; ?&gt;&lt;/title&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_logo']}</span></td><td><span class="tagType-1">图片URL</span></td><td class="tag-desc">网站Logo图片地址</td><td><code class="tag-example">&lt;img src="&lt;?php echo htmlspecialchars($siteConfig['site_logo']); ?&gt;"&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_url']}</span></td><td><span class="tagType-1">网址</span></td><td class="tag-desc">网站完整地址，如 http://www.yutoucms.cn</td><td><code class="tag-example">&lt;a href="&lt;?php echo $siteConfig['site_url']; ?&gt;"&gt;官网&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_phone']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">联系电话</td><td><code class="tag-example">电话：&lt;?php echo $siteConfig['site_phone']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_email']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">邮箱地址</td><td><code class="tag-example">&lt;a href="mailto:&lt;?php echo $siteConfig['site_email']; ?&gt;"&gt;发邮件&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_address']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">联系地址</td><td><code class="tag-example">&lt;?php echo $siteConfig['site_address']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_icp']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">ICP备案号</td><td><code class="tag-example">&lt;a href="https://beian.mps.gov.cn/"&gt;&lt;?php echo $siteConfig['site_icp']; ?&gt;&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_police_icp']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">公安备案号（后台填"公安备案号"字段）</td><td><code class="tag-example">公安备案：&lt;?php echo $siteConfig['site_police_icp']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_description']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">网站描述（SEO）</td><td><code class="tag-example">&lt;meta name="description" content="&lt;?php echo $siteConfig['site_description']; ?&gt;"&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$siteConfig['site_keywords']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">网站关键词（SEO）</td><td><code class="tag-example">&lt;meta name="keywords" content="&lt;?php echo $siteConfig['site_keywords']; ?&gt;"&gt;</code></td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类2：自定义变量 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="num">2</span> 自定义变量标签 — 后台「系统设置 → 自定义变量」</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">类型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">{$custom['key']}</span></td><td><span class="tagType-0">文本</span></td><td class="tag-desc">后台创建的变量，key为变量标识。<br>类型支持：单行文本/多行文本/图片URL</td><td>
                        <code class="tag-example">&lt;!-- 图片类型 --&gt;<br>&lt;img src="&lt;?php echo htmlspecialchars($custom['qrcode'] ?? ''); ?&gt;"&gt;<br><br>&lt;!-- 文本类型 --&gt;<br>&lt;?php echo htmlspecialchars($custom['intro'] ?? ''); ?&gt;</code>
                        <span class="tag-note">后台"变量标识"填 key，前台用 $custom['key'] 输出</span>
                    </td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类3：内容列表 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="num">3</span> 内容列表标签 — {$lists} / {$item} / {$row}</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">所属模型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">{$item['title']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">内容标题</td><td><code class="tag-example">&lt;a href="&lt;?php echo getUrl('article', $item['id']); ?&gt;"&gt;&lt;?php echo htmlspecialchars($item['title']); ?&gt;&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['litpic']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">缩略图（图片URL）</td><td><code class="tag-example">&lt;img src="&lt;?php echo htmlspecialchars($item['litpic']); ?&gt;"&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['summary']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">摘要/简述，部分内容模型有</td><td><code class="tag-example">&lt;?php echo mb_substr(strip_tags($item['summary'] ?? ''), 0, 80); ?&gt;...</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['content']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">详细内容（HTML），详情页使用</td><td><code class="tag-example">&lt;?php echo $item['content']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['click']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">浏览量/点击次数</td><td><code class="tag-example">浏览：&lt;?php echo $item['click'] ?? 0; ?&gt; 次</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['create_time']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">发布时间（时间戳）</td><td><code class="tag-example">&lt;?php echo date('Y-m-d', $item['create_time']); ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['price']}</span></td><td><span class="tagType-3">产品</span></td><td class="tag-desc">产品现价（元）</td><td><code class="tag-example">价格：&lt;?php echo $item['price']; ?&gt; 元</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['market_price']}</span></td><td><span class="tagType-3">产品</span></td><td class="tag-desc">产品市场价</td><td><code class="tag-example">市场价：&lt;?php echo $item['market_price']; ?&gt; 元</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['stock']}</span></td><td><span class="tagType-3">产品</span></td><td class="tag-desc">产品库存数量</td><td><code class="tag-example">库存：&lt;?php echo $item['stock']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['albums']}</span></td><td><span class="tagType-4">图集</span></td><td class="tag-desc">图集图片列表（JSON数组格式）</td><td>
                        <code class="tag-example">&lt;?php<br> $albums = json_decode($item['albums'] ?? '[]', true);<br>  foreach($albums as $img):<br>&gt;&lt;img src="&lt;?php echo $img; ?&gt;"&gt;<br>&lt;?php endforeach; ?&gt;</code>
                        <span class="tag-note">数据库存储为JSON字符串，需 json_decode() 转数组</span>
                    </td></tr>
                    <tr><td><span class="tagLabel">{$item['video_path']}</span></td><td><span class="tagType-5">视频</span></td><td class="tag-desc">视频文件地址（URL或相对路径）</td><td><code class="tag-example">&lt;video src="&lt;?php echo htmlspecialchars($item['video_path']); ?&gt;"&gt;&lt;/video&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['video_duration']}</span></td><td><span class="tagType-5">视频</span></td><td class="tag-desc">视频时长（秒数，如185）</td><td><code class="tag-example">&lt;?php echo gmstrftime('%H:%M:%S', $item['video_duration']); ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['file_size']}</span></td><td><span class="tagType-2">下载</span></td><td class="tag-desc">下载文件大小（如12.5 MB）</td><td><code class="tag-example">文件大小：&lt;?php echo $item['file_size']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['down_count']}</span></td><td><span class="tagType-2">下载</span></td><td class="tag-desc">下载次数</td><td><code class="tag-example">下载：&lt;?php echo $item['down_count']; ?&gt; 次</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['department']}</span></td><td><span class="tagType-0">招聘</span></td><td class="tag-desc">招聘部门</td><td><code class="tag-example">部门：&lt;?php echo $item['department']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['region']}</span></td><td><span class="tagType-0">招聘</span></td><td class="tag-desc">工作地区</td><td><code class="tag-example">地区：&lt;?php echo $item['region']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$item['salary']}</span></td><td><span class="tagType-0">招聘</span></td><td class="tag-desc">薪资范围（如 8000-12000 元/月）</td><td><code class="tag-example">薪资：&lt;?php echo $item['salary']; ?&gt;</code></td></tr>
                   <tr><td><span class="tagLabel">{$item['quantity']}</span></td><td><span class="tagType-0">招聘</span></td><td class="tag-desc">招聘人数</td><td><code class="tag-example">人数：&lt;?php echo $item['quantity']; ?&gt; 人</code></td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类4：栏目/导航 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="tagLabel">4</span> 栏目/导航标签 — {$channels} / {$channel}</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">类型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">{$channel['channel_name']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">当前栏目名称</td><td><code class="tag-example">&lt;h1&gt;&lt;?php echo htmlspecialchars($channel['channel_name']); ?&gt;&lt;/h1&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$channel['id']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">当前栏目ID</td><td><code class="tag-example">栏目ID：&lt;?php echo $channel['id']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$channel['seo_title']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">栏目SEO标题（为空则用栏目名）</td><td><code class="tag-example">&lt;title&gt;&lt;?php echo $channel['seo_title'] ?: $channel['channel_name']; ?&gt;&lt;/title&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$channel['seo_keyword']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">栏目SEO关键词</td><td><code class="tag-example">&lt;meta name="keywords" content="&lt;?php echo $channel['seo_keyword']; ?&gt;"&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$channel['seo_description']}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">栏目SEO描述</td><td><code class="tag-example">&lt;meta name="description" content="&lt;?php echo $channel['seo_description']; ?&gt;"&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$channels}循环</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">所有栏目数组（用于导航）</td><td>
                        <code class="tag-example">&lt;?php foreach($channels as $ch): ?&gt;<br>&nbsp;&nbsp;[判断] &lt;?php if(empty($ch['parent_id'])): ?&gt;<br>&nbsp;&nbsp;&lt;li&gt;&lt;a href="&lt;?php echo getUrl('channel', $ch['id']); ?&gt;"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo $ch['channel_name']; ?&gt;<br>&nbsp;&nbsp;&lt;/a&gt;&lt;/li&gt;<br>&lt;?php endforeach; ?&gt;</code>
                        <span class="tag-note">后台「栏目管理」创建的栏目，按 parent_id 判断顶级或子级</span>
                    </td></tr>
                   <tr><td><span class="tagLabel">{$channelType}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">当前栏目模型类型（数字）</td><td>
                        <code class="tag-example">1=文章 2=产品 3=单页 4=图集 5=下载 7=视频 8=留言 9=招聘</code>
                       <span class="tag-note">在 channel/list.html 中用于判断模板分支</span>
                    </td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类5：幻灯片/轮播 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="tagLabel">5</span> 幻灯片/轮播标签 — {$slides} / {$slideList}</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">类型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">{$slides}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">幻灯片数组，后台「幻灯片管理」上传</td><td>
                        <code class="tag-example">&lt;?php foreach($slides as $s): ?&gt;<br>&nbsp;&nbsp;&lt;div class="slide"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;a href="&lt;?php echo htmlspecialchars($s['link'] ?? '#'); ?&gt;"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;img src="&lt;?php echo htmlspecialchars($s['litpic']); ?&gt;"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/a&gt;<br>&nbsp;&nbsp;&lt;/div&gt;<br>&lt;?php endforeach; ?&gt;</code>
                    </td></tr>
                    <tr><td><span class="tagLabel">{$s['litpic']}</span></td><td><span class="tagType-1">图片URL</span></td><td class="tag-desc">幻灯片图片路径</td><td><code class="tag-example">&lt;img src="&lt;?php echo htmlspecialchars($s['litpic']); ?&gt;"&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$s['link']}</span></td><td><span class="tagType-1">链接URL</span></td><td class="tag-desc">幻灯片点击跳转链接</td><td><code class="tag-example">&lt;a href="&lt;?php echo htmlspecialchars($s['link']); ?&gt;"&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$s['slide_name']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">幻灯片名称</td><td><code class="tag-example">&lt;?php echo htmlspecialchars($s['slide_name']); ?&gt;</code></td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类6：友情链接 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="tagLabel">6</span> 友情链接标签 — {$friendLinks}</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">类型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">{$friendLinks}</span></td><td><span class="tagType-2">通用</span></td><td class="tag-desc">所有友链数组，后台「友情链接」管理</td><td>
                        <code class="tag-example">&lt;?php foreach($friendLinks as $fl): ?&gt;<br>&nbsp;&nbsp;&lt;a href="&lt;?php echo htmlspecialchars($fl['link_url']); ?&gt;" target="_blank"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo htmlspecialchars($fl['link_name']); ?&gt;<br>&nbsp;&nbsp;&lt;/a&gt;<br>&lt;?php endforeach; ?&gt;</code>
                    </td></tr>
                    <tr><td><span class="tagLabel">{$fl['link_name']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">友链名称</td><td><code class="tag-example">&lt;?php echo htmlspecialchars($fl['link_name']); ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$fl['link_url']}</span></td><td><span class="tagType-1">网址</span></td><td class="tag-desc">友链跳转地址</td><td><code class="tag-example">href="&lt;?php echo htmlspecialchars($fl['link_url']); ?&gt;"</code></td></tr>
                    <tr><td><span class="tagLabel">{$fl['link_logo']}</span></td><td><span class="tagType-1">图片URL</span></td><td class="tag-desc">友链Logo图片（图片友链专用）</td><td><code class="tag-example">&lt;?php if(!empty($fl['link_logo'])): ?&gt;<br>&nbsp;&nbsp;&lt;img src="&lt;?php echo $fl['link_logo']; ?&gt;"&gt;<br>&lt;?php endif; ?&gt;</code></td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类7：分页 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="tagLabel">7</span> 分页标签 — {$page['html']} / {$pageHtml}</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">类型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">{$page['html']}</span></td><td><span class="tagType-2">HTML</span></td><td class="tag-desc">自动生成分页HTML，直接输出即可</td><td><code class="tag-example">&lt;div class="pagination"&gt;<br>&nbsp;&nbsp;&lt;?php echo $page['html'] ?? ''; ?&gt;<br>&lt;/div&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$page['total']}</span></td><td><span class="tagType-0">数字</span></td><td class="tag-desc">内容总条数</td><td><code class="tag-example">共 &lt;?php echo $page['total']; ?&gt; 条</code></td></tr>
                    <tr><td><span class="tagLabel">{$page['page']}</span></td><td><span class="tagType-0">数字</span></td><td class="tag-desc">当前页码</td><td><code class="tag-example">第 &lt;?php echo $page['page']; ?&gt; 页</code></td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类8：会员信息 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="tagLabel">8</span> 会员信息标签 — {$member}</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">类型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">{$member}</span></td><td><span class="tagType-2">数组</span></td><td class="tag-desc">当前登录会员信息数组，未登录为空</td><td>
                        <code class="tag-example">&lt;?php if(!empty($member)): ?&gt;<br>&nbsp;&nbsp;欢迎，&lt;?php echo $member['user_name']; ?&gt;<br>&lt;?php else: ?&gt;<br>&nbsp;&nbsp;&lt;a href="/member/login.php"&gt;登录&lt;/a&gt;<br>&lt;?php endif; ?&gt;</code>
                    </td></tr>
                    <tr><td><span class="tagLabel">{$member['user_name']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">会员用户名</td><td><code class="tag-example">&lt;?php echo $member['user_name']; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$member['nick_name']}</span></td><td><span class="tagType-1">文本</span></td><td class="tag-desc">会员昵称</td><td><code class="tag-example">&lt;?php echo $member['nick_name'] ?? ''; ?&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">{$member['balance']}</span></td><td><span class="tagType-0">数字</span></td><td class="tag-desc">账户余额（元）</td><td><code class="tag-example">余额：&lt;?php echo $member['balance']; ?&gt; 元</code></td></tr>
                    <tr><td><span class="tagLabel">{$member['avatar']}</span></td><td><span class="tagType-1">图片URL</span></td><td class="tag-desc">会员头像</td><td><code class="tag-example">&lt;img src="&lt;?php echo $member['avatar']; ?&gt;"&gt;</code></td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类9：系统函数 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="tagLabel">9</span> 系统函数 — getUrl() / getChannelTree()</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">类型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">getUrl('home')</span></td><td><span class="tagType-2">函数</span></td><td class="tag-desc">获取各页面URL地址</td><td>
                        <code class="tag-example">首页：getUrl('home')<br>栏目：getUrl('channel', $id)<br>文章：getUrl('article', $id)<br>产品：getUrl('product', $id)<br>图集：getUrl('image', $id)<br>视频：getUrl('video', $id)<br>下载：getUrl('download', $id)<br>招聘：getUrl('recruit', $id)<br>留言：getUrl('guestbook')</code>
                    </td></tr>
                    <tr><td><span class="tagLabel">getUrl('channel', $id)</span></td><td><span class="tagType-2">函数</span></td><td class="tag-desc">栏目列表页URL，$id为栏目ID</td><td><code class="tag-example">&lt;a href="&lt;?php echo getUrl('channel', $ch['id']); ?&gt;"&gt;&lt;?php echo $ch['channel_name']; ?&gt;&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">getUrl('article', $id)</span></td><td><span class="tagType-2">函数</span></td><td class="tag-desc">文章详情页URL</td><td><code class="tag-example">&lt;a href="&lt;?php echo getUrl('article', $item['id']); ?&gt;"&gt;查看详情&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">getUrl('product', $id)</span></td><td><span class="tagType-2">函数</span></td><td class="tag-desc">产品详情页URL</td><td><code class="tag-example">&lt;a href="&lt;?php echo getUrl('product', $item['id']); ?&gt;"&gt;查看产品&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">getUrl('search')</span></td><td><span class="tagType-2">函数</span></td><td class="tag-desc">搜索结果页URL</td><td><code class="tag-example">&lt;a href="&lt;?php echo getUrl('search'); ?&gt;"&gt;搜索&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">getUrl('guestbook')</span></td><td><span class="tagType-2">函数</span></td><td class="tag-desc">在线留言页URL</td><td><code class="tag-example">&lt;a href="&lt;?php echo getUrl('guestbook'); ?&gt;"&gt;在线留言&lt;/a&gt;</code></td></tr>
                    <tr><td><span class="tagLabel">date('Y-m-d', $ts)</span></td><td><span class="tagType-2">PHP函数</span></td><td class="tag-desc">时间戳转日期格式</td><td>
                        <code class="tag-example">&lt;?php echo date('Y-m-d', $item['create_time']); ?&gt;  // 2026-05-31<br>&lt;?php echo date('Y-m-d H:i', $item['create_time']); ?&gt;  // 2026-05-31 12:30</code>
                    </td></tr>
                    <tr><td><span class="tagLabel">mb_substr($,0, N)</span></td><td><span class="tagType-2">PHP函数</span></td><td class="tag-desc">字符串截取（中文安全）</td><td>
                        <code class="tag-example">&lt;?php echo mb_substr(strip_tags($item['summary']),0, 60); ?&gt;...</code>
                    </td></tr>
                    <tr><td><span class="tagLabel">strip_tags($)</span></td><td><span class="tagType-2">PHP函数</span></td><td class="tag-desc">去除HTML标签</td><td>
                        <code class="tag-example">// 结合 mb_substr 截取纯文本摘要<br>&lt;?php echo mb_substr(strip_tags($item['content']), 0, 100); ?&gt;</code>
                    </td></tr>
                   <tr><td><span class="tagLabel">htmlspecialchars($)</span></td><td><span class="tagType-2">PHP函数</span></td><td class="tag-desc">防XSS转义，输出文本时必须加</td><td>
                        <code class="tag-example">&lt;?php echo htmlspecialchars($item['title']); ?&gt;<br>&lt;?php echo htmlspecialchars($custom['var_key'] ?? ''); ?&gt;</code>
                        <span class="tag-note">⚠️ 所有用户输入内容输出时必须 htmlspecialchars()</span>
                    </td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类10：版权标签 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="tagLabel">10</span> 版权标签 — {$canRemoveCopyright}</div>
            <table class="tag-table">
                <thead><tr><th style="width:200px;">标签</th><th style="width:100px;">类型</th><th>说明</th><th>使用示例</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">{$canRemoveCopyright}</span></td><td><span class="tagType-0">布尔值</span></td><td class="tag-desc">是否可去除版权（后台授权后自动为true）<br>基础版/专业版 = true，免费版 = false</td><td>
                        <code class="tag-example">&lt;?php if(!empty($canRemoveCopyright) &amp;&amp; $canRemoveCopyright): ?&gt;<br>&nbsp;&nbsp;// 隐藏版权，显示网站名称<br>&nbsp;&nbsp;&lt;?php echo $siteConfig['site_name']; ?&gt;<br>&lt;?php else: ?&gt;<br>&nbsp;&nbsp;// 显示版权链接<br>&nbsp;&nbsp;&lt;a href="http://www.yutoucms.cn"&gt;芋头CMS&lt;/a&gt;<br>&lt;?php endif; ?&gt;</code>
                        <span class="tag-note">此变量在 _footer.php 中自动处理，无需手动判断</span>
                    </td></tr>
                   <tr><td colspan="3" style="background:#f8fafc;color:#64748b;font-size:12px;">
                        <strong>版本说明：</strong> 免费版显示版权链接 · 基础版/专业版自动隐藏版权
                    </td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类11：前台模板文件 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="tagLabel">11</span> 前台模板文件说明</div>
            <table class="tag-table">
                <thead><tr><th style="width:180px;">文件路径</th><th style="width:140px;">用途</th><th>说明</th></tr></thead>
                <tbody>
                    <tr><td><span class="tagLabel">template/default/_header.php</span></td><td><span class="tagType-1">公共头部</span></td><td class="tag-desc">所有页面公共头部（meta标签、导航、logo、CSS引用）</td></tr>
                    <tr><td><span class="tagLabel">template/default/_footer.php</span></td><td><span class="tagType-1">公共底部</span></td><td class="tag-desc">所有页面公共底部（联系方式、版权、备案、友链、备案号）</td></tr>
                    <tr><td><span class="tagLabel">template/default/index.html</span></td><td><span class="tagType-2">首页</span></td><td class="tag-desc">网站首页，入口 public/index.php?m=index</td></tr>
                    <tr><td><span class="tagLabel">template/default/channel/list.html</span></td><td><span class="tagType-2">栏目列表</span></td><td class="tag-desc">通用栏目列表页，根据 channelType 分发不同内容区</td></tr>
                    <tr><td><span class="tagLabel">template/default/article/list.html</span></td><td><span class="tagType-2">文章列表</span></td><td class="tag-desc">文章模型列表（channelType=1）</td></tr>
                    <tr><td><span class="tagLabel">template/default/article/article.html</span></td><td><span class="tagType-2">文章详情</span></td><td class="tag-desc">文章详情页（前台文章完整内容）</td></tr>
                    <tr><td><span class="tagLabel">template/default/product/list.html</span></td><td><span class="tagType-3">产品列表</span></td><td class="tag-desc">产品模型列表（channelType=2）</td></tr>
                    <tr><td><span class="tagLabel">template/default/product/article.html</span></td><td><span class="tagType-3">产品详情</span></td><td class="tag-desc">产品详情页（含价格、库存、购买按钮）</td></tr>
                    <tr><td><span class="tagLabel">template/default/image.html</span></td><td><span class="tagType-4">图集详情</span></td><td class="tag-desc">图集详情页（含 albums 多图展示）</td></tr>
                    <tr><td><span class="tagLabel">template/default/video.html</span></td><td><span class="tagType-5">视频详情</span></td><td class="tag-desc">视频详情页（含 video_path 播放器）</td></tr>
                    <tr><td><span class="tagLabel">template/default/download.html</span></td><td><span class="tagType-2">下载详情</span></td><td class="tag-desc">下载详情页（含文件下载链接）</td></tr>
                    <tr><td><span class="tagLabel">template/default/page.html</span></td><td><span class="tagType-2">单页面</span></td><td class="tag-desc">单页模型（channelType=3），如关于我们</td></tr>
                    <tr><td><span class="tagLabel">template/default/recruit.html</span></td><td><span class="tagType-0">招聘详情</span></td><td class="tag-desc">招聘详情页（含部门、薪资、工作地点）</td></tr>
                    <tr><td><span class="tagLabel">template/default/guestbook.html</span></td><td><span class="tagType-2">在线留言</span></td><td class="tag-desc">在线留言页面（留言表单+历史留言）</td></tr>
                    <tr><td><span class="tagLabel">template/default/search.html</span></td><td><span class="tagType-2">搜索结果</span></td><td class="tag-desc">全站搜索结果页</td></tr>
                    <tr><td><span class="tagLabel">template/default/404.html</span></td><td><span class="tagType-2">404错误页</span></td><td class="tag-desc">页面不存在时显示</td></tr>
                </tbody>
            </table>
        </div>

        <!-- 分类12：后台配置路径速查 -->
        <div class="tag-section">
            <div class="tag-section-title"><span class="tagLabel">12</span> 后台配置路径速查</div>
            <table class="tag-table">
                <thead><tr><th style="width:240px;">后台路径</th><th>说明</th></tr></thead>
                <tbody>
                    <tr><td>系统配置 → 系统设置 → 网站设置</td><td class="tag-desc">配置 site_name / site_logo / site_phone / site_icp / site_police_icp 等</td></tr>
                    <tr><td>系统配置 → 系统设置 → 自定义变量</td><td class="tag-desc">创建自定义变量，类型支持文本/图片，key唯一</td></tr>
                    <tr><td>内容管理 → 栏目管理</td><td class="tag-desc">创建栏目，栏目类型（模型）决定前台模板分支</td></tr>
                    <tr><td>系统配置 → 系统设置 → 幻灯片管理</td><td class="tag-desc">上传首页轮播图，生成 $slides 数组</td></tr>
                    <tr><td>互动营销 → 友情链接</td><td class="tag-desc">管理合作伙伴链接，生成 $friendLinks 数组</td></tr>
                    <tr><td>内容运营 → TAG标签管理</td><td class="tag-desc">管理文章TAG标签（当前页面）</td></tr>
                </tbody>
            </table>
        </div>

    </div>
    <?php
}
?>