/
List.php
66 lines (60 loc) · 2.01 KB
/
List.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
// +----------------------------------------------------------------------
// | SISOME 标签列表
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://www.sisome.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 绛木子 <master@lixianhua.com>
// +----------------------------------------------------------------------
class Widget_Metas_List extends Widget_Abstract_Metas
{
/**
* 入口函数
*
* @access public
* @return void
*/
public function execute()
{
$this->parameter->setDefault(array(
'sort' => 'count',
'ignoreZeroCount' => false,
'desc' => true,
'limit' => 0,
'type' =>'',
)
);
$select = $this->select()->order($this->parameter->sort,
$this->parameter->desc ? Typecho_Db::SORT_DESC : Typecho_Db::SORT_ASC);
if($this->parameter->type && in_array($this->parameter->type, array('tag','category'))){
$select->where('type = ?', $this->parameter->type);
}
/** 忽略零数量 */
if ($this->parameter->ignoreZeroCount) {
$select->where('count > 0');
}
/** 总数限制 */
if ($this->parameter->limit) {
$select->limit($this->parameter->limit);
}
/** 父级分类 */
if ($this->parameter->parent) {
$select->where('parent = ?', $this->parameter->parent);
}
$this->db->fetchAll($select, array($this, 'push'));
}
/**
* 按分割数输出字符串
*
* @access public
* @param string $param 需要输出的值
* @return void
*/
public function split()
{
$args = func_get_args();
array_unshift($args, $this->count);
echo call_user_func_array(array('Typecho_Common', 'splitByCount'), $args);
}
}