summaryrefslogtreecommitdiffstats
path: root/libs/Contents.php
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2020-05-30 15:17:22 +0800
committerBigCoke233 <hi@guhub.cn>2020-05-30 15:17:22 +0800
commitc3bb692fe6a7289cac4b726e9887d4c2304110ff (patch)
tree7cb221cf73ae3c90145f15600c8b28ded00b3a33 /libs/Contents.php
parentbd0a23b052dc750db72d2b98349044a56ede2419 (diff)
:zap: Perf: 归档页面,折叠往年的文章列表
Diffstat (limited to 'libs/Contents.php')
-rw-r--r--libs/Contents.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/libs/Contents.php b/libs/Contents.php
index 055d4ce..b424add 100644
--- a/libs/Contents.php
+++ b/libs/Contents.php
@@ -314,4 +314,27 @@ class Contents
), '', ' - ');
Helper::options()->title();
}
-}
+
+ /**
+ * 内容归档
+ */
+ public static function archives($widget) {
+ $db = Typecho_Db::get();
+ $rows = $db->fetchAll($db->select()
+ ->from('table.contents')
+ ->order('table.contents.created', Typecho_Db::SORT_DESC)
+ ->where('table.contents.type = ?', 'post')
+ ->where('table.contents.status = ?', 'publish'));
+
+ $stat = array();
+ foreach ($rows as $row) {
+ $row = $widget->filter($row);
+ $arr = array(
+ 'title' => $row['title'],
+ 'permalink' => $row['permalink']);
+
+ $stat[date('Y', $row['created'])][$row['created']] = $arr;
+ }
+ return $stat;
+ }
+} \ No newline at end of file