-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
39 lines (36 loc) · 1.49 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
function themeConfig($form) {
$logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点LOGO地址'), _t('在这里填入一个图片URL地址, 以在网站标题前加上一个LOGO'));
$form->addInput($logoUrl);
$banquan = new Typecho_Widget_Helper_Form_Element_Text('banquan', NULL, NULL, _t('版权信息'), _t('请填写版权信息'));
$form->addInput($banquan);
}
/**
* 内容归档
* @return array
*/
function archives($widget, $excerpt = false)
{
$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')
->where('table.contents.created < ?', time()));
$stat = array();
foreach ($rows as $row) {
$row = $widget->filter($row);
$arr = array(
'title' => $row['title'],
'permalink' => $row['permalink'],
'commentsNum' => $row['commentsNum'],
);
if($excerpt){
$arr['excerpt'] = substr($row['content'], 30);
}
$stat[date('Y-n', $row['created'])][$row['created']] = $arr;
}
return $stat;
}