forked from cynial/STBlog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCategories.php
More file actions
65 lines (50 loc) · 1.33 KB
/
Copy pathCategories.php
File metadata and controls
65 lines (50 loc) · 1.33 KB
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
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
/*
* Plugin Name: 分类列表Widget
* Plugin URI: http://www.cnsaturn.com/
* Description: 显示博客的分类列表
* Version: 0.1
* Author: Saturn
* Author Email: huyanggang@gmail.com
*/
class Categories
{
private $_CI;
public function __construct(&$plugin)
{
$plugin->register('Widget::Categories', $this, 'show_categories');
$this->_CI = &get_instance();
}
public function show_categories($format)
{
/** 输出格式为空?*/
if(empty($format)) return;
$categories = $this->_CI->stcache->get('Widget::Categories');
if(FALSE == $categories)
{
$categories = $this->_CI->metas_mdl->list_metas()->result();
$this->_CI->stcache->set('Widget::Categories', $categories);
}
if($categories)
{
foreach($categories as $category)
{
$wildcards = array(
'{permalink}',
'{description}',
'{title}',
'{count}'
);
$replaces = array(
site_url('category/'. $category->slug),
$category->description,
$category->name,
$category->count
);
echo str_replace($wildcards, $replaces, $format) . "\r\n";
}
}
}
}
/* End of file Categories.php */
/* Location: ./application/st_plugins/Categories.php */