From c3bb692fe6a7289cac4b726e9887d4c2304110ff Mon Sep 17 00:00:00 2001 From: BigCoke233 Date: Sat, 30 May 2020 15:17:22 +0800 Subject: =?UTF-8?q?:zap:=20Perf:=20=E5=BD=92=E6=A1=A3=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E6=8A=98=E5=8F=A0=E5=BE=80=E5=B9=B4=E7=9A=84=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/Contents.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'libs/Contents.php') 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 -- cgit v1.2.3