Browse Source

📦 按要求修改

快乐的梦鱼 1 week ago
parent
commit
38f9dc3943
9 changed files with 299 additions and 762 deletions
  1. 187 0
      CommonCategory.php
  2. 65 0
      CommonQuery.php
  3. 31 2
      Db.class.php
  4. 3 185
      danWeiGaiKuang.php
  5. 3 185
      gongZuoDongTai.php
  6. 2 2
      index.php
  7. 3 185
      luDaoWenMai.php
  8. 3 196
      wenBaoJiaYuan.php
  9. 2 7
      xinWenXiangQing.php

+ 187 - 0
CommonCategory.php

@@ -0,0 +1,187 @@
+<?php
+// 引入公共查询类
+require_once 'CommonQuery.php';
+
+// 主频道名称
+$mainChannelName = $inMainChannelName;
+
+// 使用loadChildChannelByChannelName函数获取子分类
+$sideMenu = loadChildChannelByChannelName($mainChannelName);
+
+// 获取URL参数
+$selectedChannel = isset($_GET['channel']) ? $_GET['channel'] : '';
+$currentPage = isset($_GET['page']) ? intval($_GET['page']) : 1;
+
+// 验证当前页码
+if ($currentPage < 1) {
+    $currentPage = 1;
+}
+
+// 每页显示的文章数量
+$pageSize = 12;
+
+// 确定要查询的频道名称
+$queryChannel = !empty($selectedChannel) ? $selectedChannel : $mainChannelName;
+
+// 如果没有结果但选择了子分类,尝试查询主频道下所有子频道的文章
+if (empty($selectedChannel)) {
+
+  // 从sideMenu中提取所有id
+  $channelIds = [];
+  if (!empty($sideMenu)) {
+    $channelIds = array_map(function($item) {
+      return $item['id'] ?? null;
+    }, $sideMenu);
+    // 过滤掉空值
+    $channelIds = array_filter($channelIds);
+  }
+  $results = loadListByChannelIdInNameAndPage($pageSize, $channelIds, $currentPage);
+  $queryChannel = $mainChannelName;
+} else {
+  $results = loadListByChannelNameAndPage($pageSize, $queryChannel, $currentPage);
+}
+$workUpdates = $results['list'];
+$totalPages = $results['totalPages'];
+
+// 轮播图数据
+$carouselItems = getBannerData();
+?>
+<!DOCTYPE html>
+<html lang="zh-CN">
+
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>厦门市文化遗产保护中心 - <?php echo $queryChannel; ?></title>
+  <link rel="stylesheet" href="/css/fonts.css">
+  <link rel="stylesheet" href="/css/fontawesome.min.css">
+  <link rel="stylesheet" href="/css/bootstrap.min.css">
+  <link rel="stylesheet" href="/css/swiper-bundle.min.css">
+  <link rel="stylesheet" href="/css/style.css">
+  <script src="/js/jquery-3.7.1.js"></script>
+  <script src="/js/bootstrap.bundle.js"></script>
+  <script src="/js/swiper-bundle.min.js"></script>
+</head>
+
+<body>
+  <?php include __DIR__ . '/components/navbar.php'; ?>
+
+  <!-- 轮播图 -->
+  <div class="swiper mySwiper" style="width: 100%; height: 400px;">
+    <div class="swiper-wrapper">
+      <?php foreach ($carouselItems as $item): ?>
+        <div class="swiper-slide">
+          <img src="<?php echo $item['image']; ?>" alt="<?php echo $item['alt']; ?>" style="width: 100%; height: 100%; object-fit: cover;">
+        </div>
+      <?php endforeach; ?>
+    </div>
+    <div class="swiper-pagination"></div>
+    <div class="swiper-button-prev"></div>
+    <div class="swiper-button-next"></div>
+  </div>
+
+  <!-- 主要内容 -->
+  <div class="main-content">
+    <div class="container">
+      <div class="row">
+        <!-- 左侧导航 -->
+        <div class="col-12 col-sm-12 col-md-4 col-lg-3">
+          <div class="sidebar">
+            <div class="title">
+                <h2><?php echo $mainChannelName; ?></h2>
+              </div>
+              <ul class="sidebar-menu">
+                <?php if (!empty($sideMenu)): ?>
+                  <?php foreach ($sideMenu as $item): ?>
+                    <li><a href="?channel=<?php echo urlencode($item['name']); ?>&page=1" class="<?php echo $selectedChannel == $item['name'] ? 'active' : ''; ?>"><?php echo $item['name']; ?><i class="fa fa-arrow-right"></i></a></li>
+                  <?php endforeach; ?>
+                <?php else: ?>
+                  <li class="no-content">暂无相关子分类</li>
+                <?php endif; ?>
+              </ul>
+            </div>
+          </div>
+        
+        <!-- 右侧内容 -->
+        <div class="col-12 col-sm-12 col-md-8 col-lg-9">
+          <div class="content">
+            <div class="section-title">
+              <h2 class="icon"><?php echo $queryChannel; ?></h2>
+              
+              <nav aria-label="breadcrumb">
+                <ol class="breadcrumb">
+                  <li class="breadcrumb-item"><a href="/">首页</a></li>
+                  <li class="breadcrumb-item"><a href="./">工作动态</a></li>
+                  <?php if ($selectedChannel): ?>
+                    <li class="breadcrumb-item active" aria-current="page"><?php echo $selectedChannel; ?></li>
+                  <?php else: ?>
+                    <li class="breadcrumb-item active" aria-current="page">工作动态</li>
+                  <?php endif; ?>
+                </ol>
+              </nav>
+            </div>
+            
+            <!-- 文章列表 -->
+            <div class="news-list">
+              <?php if (!empty($workUpdates)): ?>
+                <?php foreach ($workUpdates as $item): ?>
+                  <?php
+                  // 确保所有必要字段存在
+                  $title = isset($item['title']) ? $item['title'] : '暂无标题';
+                  $articleId = isset($item['id']) ? $item['id'] : '';
+                  $date = isset($item['createtime']) ? date('Y-m-d', intval($item['createtime'])) : '未知日期';
+                  ?>
+                  <div class="news-item">
+                    <a href="/xinWenXiangQing/?id=<?php echo $articleId; ?>&channel=<?php echo urlencode($queryChannel); ?>" class="title"><?php echo $title; ?></a>
+                    <span class="date"><?php echo $date; ?></span>
+                  </div>
+                <?php endforeach; ?>
+              <?php else: ?>
+                <div class="no-news">暂无相关文章</div>
+              <?php endif; ?>
+            </div>
+                    
+                    <!-- 分页 -->
+            <nav aria-label="List Page navigation">
+              <ul class="pagination mt-4">
+                <li class="prev"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage > 1 ? $currentPage - 1 : 1; ?>">&lt;</a></li>
+                <?php for ($i = 1; $i <= $totalPages; $i++): ?>
+                  <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $i; ?>"><?php echo $i; ?></a></li>
+                <?php endfor; ?>
+                <li class="next"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage < $totalPages ? $currentPage + 1 : $totalPages; ?>">&gt;</a></li>
+              </ul>
+            </nav>
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+
+  <?php include __DIR__ . '/components/footer.php'; ?>
+
+  <script>
+    $(document).ready(function() {
+      // 初始化 Swiper
+      const swiper = new Swiper(".mySwiper", {
+        slidesPerView: 1,
+        spaceBetween: 30,
+        loop: true,
+        pagination: {
+          el: ".swiper-pagination",
+          clickable: true,
+        },
+        navigation: {
+          nextEl: ".swiper-button-next",
+          prevEl: ".swiper-button-prev",
+        },
+        autoplay: {
+          delay: 5000,
+          disableOnInteraction: false,
+        },
+      });
+      
+    });
+  </script>
+</body>
+
+</html>

+ 65 - 0
CommonQuery.php

@@ -87,6 +87,48 @@ function loadListByChannelNameAndPage($maxCount, $name, $page, $searchKeyword =
         return ['list' => [], 'totalPages' => 0];
     }
 }
+function loadListByChannelIdInNameAndPage($maxCount, $channelIds, $page, $searchKeyword = '') {
+    try {        
+        // 查询符合条件的文章总数量
+        $totalCountQuery = Db::table('pr_cms_archives')
+            ->in('channel_id', $channelIds)
+            ->where('status', 'normal');
+        
+        // 如果提供了搜索关键字,添加对title字段的模糊搜索
+        if (!empty($searchKeyword)) {
+            $totalCountQuery->where('title', 'like', '%' . $searchKeyword . '%');
+        }
+        
+        $totalCount = $totalCountQuery->count();
+        
+        // 计算总页数
+        $totalPages = $totalCount > 0 ? ceil($totalCount / $maxCount) : 0;
+        
+        // 查询当前页的文章列表
+        $articlesQuery = Db::table('pr_cms_archives')
+            ->in('channel_id', $channelIds)
+            ->where('status', 'normal');
+        
+        // 如果提供了搜索关键字,添加对title字段的模糊搜索
+        if (!empty($searchKeyword)) {
+            $articlesQuery->where('title', 'like', '%' . $searchKeyword . '%');
+        }
+        
+        $articles = $articlesQuery
+            ->order('createtime DESC')
+            ->limit(($page - 1) * $maxCount, $maxCount)
+            ->get();
+        
+        // 返回包含文章列表和总页数的数组
+        return [
+            'list' => $articles ?? [],
+            'totalPages' => $totalPages
+        ];
+    } catch (Exception $e) {
+        // 发生异常时返回包含空列表和0总页数的数组
+        return ['list' => [], 'totalPages' => 0];
+    }
+}
 function loadListPage($maxCount, $page, $searchKeyword = '') {
     try {
         // 2. 查询符合条件的文章总数量
@@ -217,4 +259,27 @@ function getBannerData() {
         // 发生异常时返回空数组
         return [];
     }
+}
+
+/**
+ * 获取flag字段包含recommend的前几篇文章列表
+ * @param int $maxCount 要获取的文章数量
+ * @return array 推荐文章列表
+ */
+function getRecommendArticles($maxCount) {
+    try {
+        // 从pr_cms_archives表中查询flag包含recommend的文章
+        // 先按weigh降序排序,再按createtime降序排序
+        $articles = Db::table('pr_cms_archives')
+            ->where('status', 'normal')
+            ->where('flag', 'like', '%recommend%')
+            ->order('weigh DESC, createtime DESC')
+            ->limit(0, $maxCount)
+            ->get();
+        
+        return $articles ?? [];
+    } catch (Exception $e) {
+        // 发生异常时返回空数组
+        return [];
+    }
 }

+ 31 - 2
Db.class.php

@@ -87,6 +87,24 @@ class Db
         }
         return $this;
     }
+    
+    /** IN查询 */
+    public function in(string $field, array $values): self
+    {
+        if (!empty($values)) {
+            $this->wheres[] = [$field, 'IN', $values];
+        }
+        return $this;
+    }
+    
+    /** NOT IN查询 */
+    public function notIn(string $field, array $values): self
+    {
+        if (!empty($values)) {
+            $this->wheres[] = [$field, 'NOT IN', $values];
+        }
+        return $this;
+    }
 
     public function order(string $order): self
     {
@@ -209,8 +227,19 @@ class Db
         }
         $str = [];
         foreach ($this->wheres as list($f, $o, $v)) {
-            $str[]        = "`{$f}` {$o} ?";
-            $this->params[] = $v;
+            if (in_array(strtoupper($o), ['IN', 'NOT IN']) && is_array($v)) {
+                // 处理IN和NOT IN查询,需要特殊处理数组值
+                $placeholders = [];
+                foreach ($v as $value) {
+                    $placeholders[] = '?';
+                    $this->params[] = $value;
+                }
+                $str[] = "`{$f}` {$o} (" . implode(',', $placeholders) . ")";
+            } else {
+                // 普通查询条件
+                $str[] = "`{$f}` {$o} ?";
+                $this->params[] = $v;
+            }
         }
         $sql .= ' WHERE ' . implode(' AND ', $str);
     }

+ 3 - 185
danWeiGaiKuang.php

@@ -1,186 +1,4 @@
 <?php
-// 引入公共查询类
-require_once 'CommonQuery.php';
-
-// 主频道名称
-$mainChannelName = '单位概况';
-
-// 使用loadChildChannelByChannelName函数获取子分类
-$sideMenu = loadChildChannelByChannelName($mainChannelName);
-
-// 获取URL参数
-$selectedChannel = isset($_GET['channel']) ? $_GET['channel'] : '';
-$currentPage = isset($_GET['page']) ? intval($_GET['page']) : 1;
-
-// 验证当前页码
-if ($currentPage < 1) {
-    $currentPage = 1;
-}
-
-// 每页显示的文章数量
-$pageSize = 12;
-
-// 确定要查询的频道名称
-$queryChannel = !empty($selectedChannel) ? $selectedChannel : (count($sideMenu) > 0 ? $sideMenu[0]['name'] : $mainChannelName);
-
-// 使用loadListByChannelNameAndPage函数获取文章列表
-$results = loadListByChannelNameAndPage($pageSize, $queryChannel, $currentPage);
-$workUpdates = $results['list'];
-$totalPages = $results['totalPages'];
-
-// 如果没有结果尝试查询主频道
-if (empty($workUpdates)) {
-    $results = loadListByChannelNameAndPage($pageSize, $mainChannelName, 1);
-    $workUpdates = $results['list'];
-    $totalPages = $results['totalPages'];
-    $currentPage = 1;
-    $queryChannel = $mainChannelName;
-}
-
-// 轮播图数据
-$carouselItems = [
-  [
-    "image" => "/images/test-header-4.png",
-    "alt" => $mainChannelName
-  ]
-];
-?>
-<!DOCTYPE html>
-<html lang="zh-CN">
-
-<head>
-  <meta charset="UTF-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>厦门市文化遗产保护中心 - <?php echo $queryChannel; ?></title>
-  <link rel="stylesheet" href="/css/fonts.css">
-  <link rel="stylesheet" href="/css/fontawesome.min.css">
-  <link rel="stylesheet" href="/css/bootstrap.min.css">
-  <link rel="stylesheet" href="/css/swiper-bundle.min.css">
-  <link rel="stylesheet" href="/css/style.css">
-  <script src="/js/jquery-3.7.1.js"></script>
-  <script src="/js/bootstrap.bundle.js"></script>
-  <script src="/js/swiper-bundle.min.js"></script>
-</head>
-
-<body>
-  <?php include __DIR__ . '/components/navbar.php'; ?>
-
-  <!-- 轮播图 -->
-  <div class="swiper mySwiper" style="width: 100%; height: 400px;">
-    <div class="swiper-wrapper">
-      <?php foreach ($carouselItems as $item): ?>
-        <div class="swiper-slide">
-          <img src="<?php echo $item['image']; ?>" alt="<?php echo $item['alt']; ?>" style="width: 100%; height: 100%; object-fit: cover;">
-        </div>
-      <?php endforeach; ?>
-    </div>
-    <div class="swiper-pagination"></div>
-    <div class="swiper-button-prev"></div>
-    <div class="swiper-button-next"></div>
-  </div>
-
-  <!-- 主要内容 -->
-  <div class="main-content">
-    <div class="container">
-      <div class="row">
-        <!-- 左侧导航 -->
-        <div class="col-12 col-sm-12 col-md-4 col-lg-3">
-          <div class="sidebar">
-            <div class="title">
-                <h2><?php echo $mainChannelName; ?></h2>
-              </div>
-              <ul class="sidebar-menu">
-                <?php if (!empty($sideMenu)): ?>
-                  <?php foreach ($sideMenu as $item): ?>
-                    <li><a href="?channel=<?php echo urlencode($item['name']); ?>&page=1" class="<?php echo $selectedChannel == $item['name'] ? 'active' : ''; ?>"><?php echo $item['name']; ?><i class="fa fa-arrow-right"></i></a></li>
-                  <?php endforeach; ?>
-                <?php else: ?>
-                  <li class="no-content">暂无相关子分类</li>
-                <?php endif; ?>
-              </ul>
-            </div>
-          </div>
-        
-        <!-- 右侧内容 -->
-        <div class="col-12 col-sm-12 col-md-8 col-lg-9">
-          <div class="content">
-            <div class="section-title">
-              <h2 class="icon"><?php echo $queryChannel; ?></h2>
-              
-              <nav aria-label="breadcrumb">
-                <ol class="breadcrumb">
-                  <li class="breadcrumb-item"><a href="/">首页</a></li>
-                  <li class="breadcrumb-item"><a href="./">工作动态</a></li>
-                  <?php if ($selectedChannel): ?>
-                    <li class="breadcrumb-item active" aria-current="page"><?php echo $selectedChannel; ?></li>
-                  <?php else: ?>
-                    <li class="breadcrumb-item active" aria-current="page">工作动态</li>
-                  <?php endif; ?>
-                </ol>
-              </nav>
-            </div>
-            
-            <!-- 文章列表 -->
-            <div class="news-list">
-              <?php if (!empty($workUpdates)): ?>
-                <?php foreach ($workUpdates as $item): ?>
-                  <?php
-                  // 确保所有必要字段存在
-                  $title = isset($item['title']) ? $item['title'] : '暂无标题';
-                  $articleId = isset($item['id']) ? $item['id'] : '';
-                  $date = isset($item['createtime']) ? date('Y-m-d', intval($item['createtime'])) : '未知日期';
-                  ?>
-                  <div class="news-item">
-                    <a href="/xinWenXiangQing/?id=<?php echo $articleId; ?>&channel=<?php echo urlencode($queryChannel); ?>" class="title"><?php echo $title; ?></a>
-                    <span class="date"><?php echo $date; ?></span>
-                  </div>
-                <?php endforeach; ?>
-              <?php else: ?>
-                <div class="no-news">暂无相关文章</div>
-              <?php endif; ?>
-            </div>
-                    
-                    <!-- 分页 -->
-            <nav aria-label="List Page navigation">
-              <ul class="pagination mt-4">
-                <li class="prev"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage > 1 ? $currentPage - 1 : 1; ?>">&lt;</a></li>
-                <?php for ($i = 1; $i <= $totalPages; $i++): ?>
-                  <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $i; ?>"><?php echo $i; ?></a></li>
-                <?php endfor; ?>
-                <li class="next"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage < $totalPages ? $currentPage + 1 : $totalPages; ?>">&gt;</a></li>
-              </ul>
-            </nav>
-          </div>
-        </div>
-      </div>
-    </div>
-  </div>
-
-  <?php include __DIR__ . '/components/footer.php'; ?>
-
-  <script>
-    $(document).ready(function() {
-      // 初始化 Swiper
-      const swiper = new Swiper(".mySwiper", {
-        slidesPerView: 1,
-        spaceBetween: 30,
-        loop: true,
-        pagination: {
-          el: ".swiper-pagination",
-          clickable: true,
-        },
-        navigation: {
-          nextEl: ".swiper-button-next",
-          prevEl: ".swiper-button-prev",
-        },
-        autoplay: {
-          delay: 5000,
-          disableOnInteraction: false,
-        },
-      });
-      
-    });
-  </script>
-</body>
-
-</html>
+$inMainChannelName = '单位概况';
+require_once 'CommonCategory.php';
+?>

+ 3 - 185
gongZuoDongTai.php

@@ -1,186 +1,4 @@
 <?php
-// 引入公共查询类
-require_once 'CommonQuery.php';
-
-// 主频道名称
-$mainChannelName = '工作动态';
-
-// 使用loadChildChannelByChannelName函数获取子分类
-$sideMenu = loadChildChannelByChannelName($mainChannelName);
-
-// 获取URL参数
-$selectedChannel = isset($_GET['channel']) ? $_GET['channel'] : '';
-$currentPage = isset($_GET['page']) ? intval($_GET['page']) : 1;
-
-// 验证当前页码
-if ($currentPage < 1) {
-    $currentPage = 1;
-}
-
-// 每页显示的文章数量
-$pageSize = 12;
-
-// 确定要查询的频道名称
-$queryChannel = !empty($selectedChannel) ? $selectedChannel : (count($sideMenu) > 0 ? $sideMenu[0]['name'] : $mainChannelName);
-
-// 使用loadListByChannelNameAndPage函数获取文章列表
-$results = loadListByChannelNameAndPage($pageSize, $queryChannel, $currentPage);
-$workUpdates = $results['list'];
-$totalPages = $results['totalPages'];
-
-// 如果没有结果但选择了子分类,尝试查询主频道
-if (empty($workUpdates)) {
-    $results = loadListByChannelNameAndPage($pageSize, $mainChannelName, 1);
-    $workUpdates = $results['list'];
-    $totalPages = $results['totalPages'];
-    $currentPage = 1;
-    $queryChannel = $mainChannelName;
-}
-
-// 轮播图数据
-$carouselItems = [
-  [
-    "image" => "/images/test-header-4.png",
-    "alt" => $mainChannelName
-  ]
-];
-?>
-<!DOCTYPE html>
-<html lang="zh-CN">
-
-<head>
-  <meta charset="UTF-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>厦门市文化遗产保护中心 - <?php echo $queryChannel; ?></title>
-  <link rel="stylesheet" href="/css/fonts.css">
-  <link rel="stylesheet" href="/css/fontawesome.min.css">
-  <link rel="stylesheet" href="/css/bootstrap.min.css">
-  <link rel="stylesheet" href="/css/swiper-bundle.min.css">
-  <link rel="stylesheet" href="/css/style.css">
-  <script src="/js/jquery-3.7.1.js"></script>
-  <script src="/js/bootstrap.bundle.js"></script>
-  <script src="/js/swiper-bundle.min.js"></script>
-</head>
-
-<body>
-  <?php include __DIR__ . '/components/navbar.php'; ?>
-
-  <!-- 轮播图 -->
-  <div class="swiper mySwiper" style="width: 100%; height: 400px;">
-    <div class="swiper-wrapper">
-      <?php foreach ($carouselItems as $item): ?>
-        <div class="swiper-slide">
-          <img src="<?php echo $item['image']; ?>" alt="<?php echo $item['alt']; ?>" style="width: 100%; height: 100%; object-fit: cover;">
-        </div>
-      <?php endforeach; ?>
-    </div>
-    <div class="swiper-pagination"></div>
-    <div class="swiper-button-prev"></div>
-    <div class="swiper-button-next"></div>
-  </div>
-
-  <!-- 主要内容 -->
-  <div class="main-content">
-    <div class="container">
-      <div class="row">
-        <!-- 左侧导航 -->
-        <div class="col-12 col-sm-12 col-md-4 col-lg-3">
-          <div class="sidebar">
-            <div class="title">
-                <h2><?php echo $mainChannelName; ?></h2>
-              </div>
-              <ul class="sidebar-menu">
-                <?php if (!empty($sideMenu)): ?>
-                  <?php foreach ($sideMenu as $item): ?>
-                    <li><a href="?channel=<?php echo urlencode($item['name']); ?>&page=1" class="<?php echo $selectedChannel == $item['name'] ? 'active' : ''; ?>"><?php echo $item['name']; ?><i class="fa fa-arrow-right"></i></a></li>
-                  <?php endforeach; ?>
-                <?php else: ?>
-                  <li class="no-content">暂无相关子分类</li>
-                <?php endif; ?>
-              </ul>
-            </div>
-          </div>
-        
-        <!-- 右侧内容 -->
-        <div class="col-12 col-sm-12 col-md-8 col-lg-9">
-          <div class="content">
-            <div class="section-title">
-              <h2 class="icon"><?php echo $queryChannel; ?></h2>
-              
-              <nav aria-label="breadcrumb">
-                <ol class="breadcrumb">
-                  <li class="breadcrumb-item"><a href="/">首页</a></li>
-                  <li class="breadcrumb-item"><a href="./">工作动态</a></li>
-                  <?php if ($selectedChannel): ?>
-                    <li class="breadcrumb-item active" aria-current="page"><?php echo $selectedChannel; ?></li>
-                  <?php else: ?>
-                    <li class="breadcrumb-item active" aria-current="page">工作动态</li>
-                  <?php endif; ?>
-                </ol>
-              </nav>
-            </div>
-            
-            <!-- 文章列表 -->
-            <div class="news-list">
-              <?php if (!empty($workUpdates)): ?>
-                <?php foreach ($workUpdates as $item): ?>
-                  <?php
-                  // 确保所有必要字段存在
-                  $title = isset($item['title']) ? $item['title'] : '暂无标题';
-                  $articleId = isset($item['id']) ? $item['id'] : '';
-                  $date = isset($item['createtime']) ? date('Y-m-d', intval($item['createtime'])) : '未知日期';
-                  ?>
-                  <div class="news-item">
-                    <a href="/xinWenXiangQing/?id=<?php echo $articleId; ?>&channel=<?php echo urlencode($queryChannel); ?>" class="title"><?php echo $title; ?></a>
-                    <span class="date"><?php echo $date; ?></span>
-                  </div>
-                <?php endforeach; ?>
-              <?php else: ?>
-                <div class="no-news">暂无相关文章</div>
-              <?php endif; ?>
-            </div>
-                    
-                    <!-- 分页 -->
-            <nav aria-label="List Page navigation">
-              <ul class="pagination mt-4">
-                <li class="prev"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage > 1 ? $currentPage - 1 : 1; ?>">&lt;</a></li>
-                <?php for ($i = 1; $i <= $totalPages; $i++): ?>
-                  <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $i; ?>"><?php echo $i; ?></a></li>
-                <?php endfor; ?>
-                <li class="next"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage < $totalPages ? $currentPage + 1 : $totalPages; ?>">&gt;</a></li>
-              </ul>
-            </nav>
-          </div>
-        </div>
-      </div>
-    </div>
-  </div>
-
-  <?php include __DIR__ . '/components/footer.php'; ?>
-
-  <script>
-    $(document).ready(function() {
-      // 初始化 Swiper
-      const swiper = new Swiper(".mySwiper", {
-        slidesPerView: 1,
-        spaceBetween: 30,
-        loop: true,
-        pagination: {
-          el: ".swiper-pagination",
-          clickable: true,
-        },
-        navigation: {
-          nextEl: ".swiper-button-next",
-          prevEl: ".swiper-button-prev",
-        },
-        autoplay: {
-          delay: 5000,
-          disableOnInteraction: false,
-        },
-      });
-      
-    });
-  </script>
-</body>
-
-</html>
+$inMainChannelName = '工作动态';
+require_once 'CommonCategory.php';
+?>

+ 2 - 2
index.php

@@ -3,7 +3,7 @@ require 'CommonQuery.php';
 
 // 轮播图数据 - 从pr_cms_block表中获取
 $carouselItems = getBannerData();
-$carouselItems2 = loadListByChannelName(6, "热门新闻");
+$carouselItems2 = getRecommendArticles(6);
 // 通知公告数据
 $notices = loadListByChannelName(10, "新闻公告");
 // 工作动态数据
@@ -124,7 +124,7 @@ $featured = loadListByChannelName(6, "热门新闻");
             <div class="swiper-pagination"></div>
           </div>
           <a href="https://www.12371.cn/special/xxzd/">
-            <img src="images/xuexi.png" style="width: 100%; height:130px;object-fit:cover;" /> 
+            <img src="images/xuexi.png" class="mt-3" style="width: 100%; height:130px;object-fit:cover;" /> 
           </a>
         </div>
       </div>

+ 3 - 185
luDaoWenMai.php

@@ -1,186 +1,4 @@
 <?php
-// 引入公共查询类
-require_once 'CommonQuery.php';
-
-// 主频道名称
-$mainChannelName = '鹭岛文脉';
-
-// 使用loadChildChannelByChannelName函数获取子分类
-$sideMenu = loadChildChannelByChannelName($mainChannelName);
-
-// 获取URL参数
-$selectedChannel = isset($_GET['channel']) ? $_GET['channel'] : '';
-$currentPage = isset($_GET['page']) ? intval($_GET['page']) : 1;
-
-// 验证当前页码
-if ($currentPage < 1) {
-    $currentPage = 1;
-}
-
-// 每页显示的文章数量
-$pageSize = 12;
-
-// 确定要查询的频道名称
-$queryChannel = !empty($selectedChannel) ? $selectedChannel : (count($sideMenu) > 0 ? $sideMenu[0]['name'] : $mainChannelName);
-
-// 使用loadListByChannelNameAndPage函数获取文章列表
-$results = loadListByChannelNameAndPage($pageSize, $queryChannel, $currentPage);
-$workUpdates = $results['list'];
-$totalPages = $results['totalPages'];
-
-// 如果没有结果但选择了子分类,尝试查询主频道
-if (empty($workUpdates)) {
-    $results = loadListByChannelNameAndPage($pageSize, $mainChannelName, 1);
-    $workUpdates = $results['list'];
-    $totalPages = $results['totalPages'];
-    $currentPage = 1;
-    $queryChannel = $mainChannelName;
-}
-
-// 轮播图数据
-$carouselItems = [
-  [
-    "image" => "/images/test-header-4.png",
-    "alt" => $mainChannelName
-  ]
-];
-?>
-<!DOCTYPE html>
-<html lang="zh-CN">
-
-<head>
-  <meta charset="UTF-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>厦门市文化遗产保护中心 - <?php echo $queryChannel; ?></title>
-  <link rel="stylesheet" href="/css/fonts.css">
-  <link rel="stylesheet" href="/css/fontawesome.min.css">
-  <link rel="stylesheet" href="/css/bootstrap.min.css">
-  <link rel="stylesheet" href="/css/swiper-bundle.min.css">
-  <link rel="stylesheet" href="/css/style.css">
-  <script src="/js/jquery-3.7.1.js"></script>
-  <script src="/js/bootstrap.bundle.js"></script>
-  <script src="/js/swiper-bundle.min.js"></script>
-</head>
-
-<body>
-  <?php include __DIR__ . '/components/navbar.php'; ?>
-
-  <!-- 轮播图 -->
-  <div class="swiper mySwiper" style="width: 100%; height: 400px;">
-    <div class="swiper-wrapper">
-      <?php foreach ($carouselItems as $item): ?>
-        <div class="swiper-slide">
-          <img src="<?php echo $item['image']; ?>" alt="<?php echo $item['alt']; ?>" style="width: 100%; height: 100%; object-fit: cover;">
-        </div>
-      <?php endforeach; ?>
-    </div>
-    <div class="swiper-pagination"></div>
-    <div class="swiper-button-prev"></div>
-    <div class="swiper-button-next"></div>
-  </div>
-
-  <!-- 主要内容 -->
-  <div class="main-content">
-    <div class="container">
-      <div class="row">
-        <!-- 左侧导航 -->
-        <div class="col-12 col-sm-12 col-md-4 col-lg-3">
-          <div class="sidebar">
-            <div class="title">
-                <h2><?php echo $mainChannelName; ?></h2>
-              </div>
-              <ul class="sidebar-menu">
-                <?php if (!empty($sideMenu)): ?>
-                  <?php foreach ($sideMenu as $item): ?>
-                    <li><a href="?channel=<?php echo urlencode($item['name']); ?>&page=1" class="<?php echo $selectedChannel == $item['name'] ? 'active' : ''; ?>"><?php echo $item['name']; ?><i class="fa fa-arrow-right"></i></a></li>
-                  <?php endforeach; ?>
-                <?php else: ?>
-                  <li class="no-content">暂无相关子分类</li>
-                <?php endif; ?>
-              </ul>
-            </div>
-          </div>
-        
-        <!-- 右侧内容 -->
-        <div class="col-12 col-sm-12 col-md-8 col-lg-9">
-          <div class="content">
-            <div class="section-title">
-              <h2 class="icon"><?php echo $queryChannel; ?></h2>
-              
-              <nav aria-label="breadcrumb">
-                <ol class="breadcrumb">
-                  <li class="breadcrumb-item"><a href="/">首页</a></li>
-                  <li class="breadcrumb-item"><a href="./">工作动态</a></li>
-                  <?php if ($selectedChannel): ?>
-                    <li class="breadcrumb-item active" aria-current="page"><?php echo $selectedChannel; ?></li>
-                  <?php else: ?>
-                    <li class="breadcrumb-item active" aria-current="page">工作动态</li>
-                  <?php endif; ?>
-                </ol>
-              </nav>
-            </div>
-            
-            <!-- 文章列表 -->
-            <div class="news-list">
-              <?php if (!empty($workUpdates)): ?>
-                <?php foreach ($workUpdates as $item): ?>
-                  <?php
-                  // 确保所有必要字段存在
-                  $title = isset($item['title']) ? $item['title'] : '暂无标题';
-                  $articleId = isset($item['id']) ? $item['id'] : '';
-                  $date = isset($item['createtime']) ? date('Y-m-d', intval($item['createtime'])) : '未知日期';
-                  ?>
-                  <div class="news-item">
-                    <a href="/xinWenXiangQing/?id=<?php echo $articleId; ?>&channel=<?php echo urlencode($queryChannel); ?>" class="title"><?php echo $title; ?></a>
-                    <span class="date"><?php echo $date; ?></span>
-                  </div>
-                <?php endforeach; ?>
-              <?php else: ?>
-                <div class="no-news">暂无相关文章</div>
-              <?php endif; ?>
-            </div>
-                    
-                    <!-- 分页 -->
-            <nav aria-label="List Page navigation">
-              <ul class="pagination mt-4">
-                <li class="prev"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage > 1 ? $currentPage - 1 : 1; ?>">&lt;</a></li>
-                <?php for ($i = 1; $i <= $totalPages; $i++): ?>
-                  <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $i; ?>"><?php echo $i; ?></a></li>
-                <?php endfor; ?>
-                <li class="next"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage < $totalPages ? $currentPage + 1 : $totalPages; ?>">&gt;</a></li>
-              </ul>
-            </nav>
-          </div>
-        </div>
-      </div>
-    </div>
-  </div>
-
-  <?php include __DIR__ . '/components/footer.php'; ?>
-
-  <script>
-    $(document).ready(function() {
-      // 初始化 Swiper
-      const swiper = new Swiper(".mySwiper", {
-        slidesPerView: 1,
-        spaceBetween: 30,
-        loop: true,
-        pagination: {
-          el: ".swiper-pagination",
-          clickable: true,
-        },
-        navigation: {
-          nextEl: ".swiper-button-next",
-          prevEl: ".swiper-button-prev",
-        },
-        autoplay: {
-          delay: 5000,
-          disableOnInteraction: false,
-        },
-      });
-      
-    });
-  </script>
-</body>
-
-</html>
+$inMainChannelName = '鹭岛文脉';
+require_once 'CommonCategory.php';
+?>

+ 3 - 196
wenBaoJiaYuan.php

@@ -1,197 +1,4 @@
 <?php
-require_once 'CommonQuery.php';
-
-// 轮播图数据 - 修改为单张图片
-$carouselItems = [
-  [
-    "image" => "/images/test-header-5.png",
-    "alt" => "文保家园"
-  ]
-];
-
-// 获取文保家园的子分类
-$sideMenu = loadChildChannelByChannelName("文保家园");
-
-// 主频道名称
-$mainChannelName = "文保家园";
-
-// 获取URL参数 - 选中的频道
-$queryChannel = !empty($selectedChannel) ? $selectedChannel : (count($sideMenu) > 0 ? $sideMenu[0]['name'] : $mainChannelName);
-
-// 获取URL参数 - 当前页码
-$currentPage = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0 ? intval($_GET['page']) : 1;
-
-// 每页显示的文章数量
-$pageSize = 9;
-
-// 确定要查询的频道名称
-$channelToQuery = $queryChannel;
-if (empty($channelToQuery)) {
-    // 如果没有选中的频道或选中的频道不存在于子分类中,则使用主频道
-    $channelToQuery = $mainChannelName;
-}
-
-// 获取文章列表和总页数
-$articleResult = loadListByChannelNameAndPage($pageSize, $channelToQuery, $currentPage);
-$workUpdates = $articleResult['list'];
-$totalPages = $articleResult['totalPages'];
-
-// 如果子分类为空或当前查询的频道没有文章,则显示主频道的文章
-if (empty($sideMenu) || empty($workUpdates)) {
-    $articleResult = loadListByChannelNameAndPage($pageSize, $mainChannelName, $currentPage);
-    $workUpdates = $articleResult['list'];
-    $totalPages = $articleResult['totalPages'];
-    $channelToQuery = $mainChannelName;
-}
-?>
-<!DOCTYPE html>
-<html lang="zh-CN">
-
-<head>
-  <meta charset="UTF-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>厦门市文化遗产保护中心 - <?php echo $channelToQuery; ?></title>
-  <link rel="stylesheet" href="/css/fonts.css">
-  <link rel="stylesheet" href="/css/fontawesome.min.css">
-  <link rel="stylesheet" href="/css/bootstrap.min.css">
-  <link rel="stylesheet" href="/css/swiper-bundle.min.css">
-  <link rel="stylesheet" href="/css/style.css">
-  <script src="/js/jquery-3.7.1.js"></script>
-  <script src="/js/bootstrap.bundle.js"></script>
-  <script src="/js/swiper-bundle.min.js"></script>
-</head>
-
-<body>
-  <?php include __DIR__ . '/components/navbar.php'; ?>
-
-  <!-- 轮播图 -->
-  <div class="swiper mySwiper" style="width: 100%; height: 400px;">
-    <div class="swiper-wrapper">
-      <?php foreach ($carouselItems as $item): ?>
-        <div class="swiper-slide">
-          <img src="<?php echo $item['image']; ?>" alt="<?php echo $item['alt']; ?>" style="width: 100%; height: 100%; object-fit: cover;">
-        </div>
-      <?php endforeach; ?>
-    </div>
-    <div class="swiper-pagination"></div>
-    <div class="swiper-button-prev"></div>
-    <div class="swiper-button-next"></div>
-  </div>
-
-  <!-- 主要内容 -->
-  <div class="main-content">
-    <div class="container">
-      <div class="row">
-        <!-- 左侧导航 -->
-        <div class="col-12 col-sm-12 col-md-4 col-lg-3">
-          <div class="sidebar">
-            <div class="title">
-                <h2><?php echo $mainChannelName; ?></h2>
-              </div>
-              <ul class="sidebar-menu">
-                <?php if (!empty($sideMenu)): ?>
-                  <?php foreach ($sideMenu as $item): ?>
-                    <li>
-                      <a href="?channel=<?php echo urlencode($item['name']); ?>&page=1" class="<?php echo $queryChannel == $item['name'] ? 'active' : ''; ?>">
-                        <?php echo $item['name']; ?>
-                        <i class="fa fa-arrow-right"></i>
-                      </a>
-                    </li>
-                  <?php endforeach; ?>
-                <?php else: ?>
-                  <li>
-                    <a href="?channel=<?php echo urlencode($mainChannelName); ?>&page=1" class="active">
-                      <?php echo $mainChannelName; ?>
-                      <i class="fa fa-arrow-right"></i>
-                    </a>
-                  </li>
-                <?php endif; ?>
-              </ul>
-          </div>
-        </div>
-        
-        <!-- 右侧内容 -->
-        <div class="col-12 col-sm-12 col-md-8 col-lg-9">
-          <div class="content">
-            <div class="section-title">
-                <h2 class="icon"><?php echo $channelToQuery; ?></h2>
-                
-                <nav aria-label="breadcrumb">
-                  <ol class="breadcrumb">
-                    <li class="breadcrumb-item"><a href="/">首页</a></li>
-                    <li class="breadcrumb-item"><a href="?channel=<?php echo urlencode($mainChannelName); ?>&page=1"><?php echo $mainChannelName; ?></a></li>
-                    <?php if ($queryChannel && $queryChannel != $mainChannelName): ?>
-                      <li class="breadcrumb-item active" aria-current="page"><?php echo $queryChannel; ?></li>
-                    <?php else: ?>
-                      <li class="breadcrumb-item active" aria-current="page"><?php echo $mainChannelName; ?></li>
-                    <?php endif; ?>
-                  </ol>
-                </nav>
-              </div>
-              
-              <!-- 文章列表 -->
-              <div class="news-list">
-                <?php if (!empty($workUpdates)): ?>
-                  <?php foreach ($workUpdates as $item): ?>
-                    <div class="news-item">
-                      <a href="/xinWenXiangQing/?id=<?php echo isset($item['id']) ? $item['id'] : (isset($item['title']) ? urlencode($item['title']) : ''); ?>" class="title">
-                        <?php echo isset($item['title']) ? $item['title'] : ''; ?>
-                      </a>
-                      <span class="date">
-                        <?php echo isset($item['createtime']) ? date('Y-m-d', intval($item['createtime'])) : (isset($item['date']) ? $item['date'] : ''); ?>
-                      </span>
-                    </div>
-                  <?php endforeach; ?>
-                <?php else: ?>
-                  <div class="no-news">暂无相关文章</div>
-                <?php endif; ?>
-              </div>
-              
-              <!-- 分页 -->
-              <?php if ($totalPages > 1): ?>
-                <nav aria-label="List Page navigation">
-                  <ul class="pagination mt-4">
-                    <?php for ($i = 1; $i <= $totalPages; $i++): ?>
-                      <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>">
-                        <a href="?channel=<?php echo urlencode($queryChannel); ?>&page=<?php echo $i; ?>">
-                          <?php echo $i; ?>
-                        </a>
-                      </li>
-                    <?php endfor; ?>
-                  </ul>
-                </nav>
-              <?php endif; ?>
-          </div>
-        </div>
-      </div>
-    </div>
-  </div>
-
-  <?php include __DIR__ . '/components/footer.php'; ?>
-
-  <script>
-    $(document).ready(function() {
-      // 初始化 Swiper
-      const swiper = new Swiper(".mySwiper", {
-        slidesPerView: 1,
-        spaceBetween: 30,
-        loop: true,
-        pagination: {
-          el: ".swiper-pagination",
-          clickable: true,
-        },
-        navigation: {
-          nextEl: ".swiper-button-next",
-          prevEl: ".swiper-button-prev",
-        },
-        autoplay: {
-          delay: 5000,
-          disableOnInteraction: false,
-        },
-      });
-      
-    });
-  </script>
-</body>
-
-</html>
+$inMainChannelName = '文保家园';
+require_once 'CommonCategory.php';
+?>

+ 2 - 7
xinWenXiangQing.php

@@ -44,13 +44,8 @@ if (!$newsData) {
     }
 }
 
-// 轮播图数据 - 使用当前频道名称
-$carouselItems = [
-  [
-    "image" => "/images/test-header-2.png",
-    "alt" => $currentChannel
-  ]
-];
+// 轮播图数据
+$carouselItems = getBannerData();
 ?>
 <!DOCTYPE html>
 <html lang="zh-CN">