<?php
/**
 * 芋头CMS
 * ============================================================================
 * 版权所有 2016-2028 沅陵县乌托邦网络服务有限公司，并保留所有权利。
 * 网站地址: http://www.yutoucms.cn
 * ----------------------------------------------------------------------------
 * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷。
 * ============================================================================
 * Author: 芋头 <mxgsf@qq.com>
 * Date: 2026-6-1
 */
?>
<!-- Top Bar -->
<div class="topbar">
<div class="container">
<div class="topbar-inner">
<div class="topbar-left">
<span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg>
您好！欢迎访问 <?php echo htmlspecialchars(isset($site['site_name']) ? $site['site_name'] : ''); ?> 官网！
</span>
</div>
<div class="topbar-right">
<a href="<?php echo getUrl('channel', 3); ?>">关于我们</a>
<span>|</span>
<a href="<?php echo getUrl('guestbook'); ?>">联系我们</a>
</div>
</div>
</div>
</div>

<!-- Header -->
<header class="header">
<div class="container">
<div class="header-inner">
<a href="/" class="logo">
<?php if(!empty($site['site_logo'])): ?>
<img src="<?php echo htmlspecialchars($site['site_logo']); ?>" alt="<?php echo htmlspecialchars(isset($site['site_name']) ? $site['site_name'] : ''); ?>" style="height:40px;">
<?php else: ?>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="2" y="3" width="20" height="14" rx="2"/>
<line x1="8" y1="21" x2="16" y2="21"/>
<line x1="12" y1="17" x2="12" y2="21"/>
</svg>
<span><?php echo htmlspecialchars(isset($site['site_name']) ? $site['site_name'] : '企业网站'); ?></span>
<?php endif; ?>
</a>
<nav class="nav">
<a href="/">首页</a>
<?php
$topChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = 0 AND is_show = 1 ORDER BY list_order ASC, id ASC");
foreach($topChannels as $ch):
  $children = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [$ch['id']]);
?>
<div class="nav-item">
<a href="<?php echo getUrl('channel', $ch['id']); ?>">
<?php echo htmlspecialchars($ch['channel_name']); ?>
<?php if(!empty($children)): ?>
<svg class="arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
<?php endif; ?>
</a>
<?php if(!empty($children)): ?>
<div class="nav-dropdown">
<?php foreach($children as $child): ?>
<a href="<?php echo getUrl('channel', $child['id']); ?>"><?php echo htmlspecialchars($child['channel_name']); ?></a>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
<div class="nav-item">
<a href="<?php echo getUrl('guestbook'); ?>">联系我们</a>
</div>
</nav>
<div class="header-right">
<div class="header-phone">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/></svg>
<span><?php echo htmlspecialchars(isset($site['site_phone']) ? $site['site_phone'] : '400-888-8888'); ?></span>
</div>
</div>
</div>
</div>
</header>