📄 正在查看:twcms/control/tag_control.class.php
1<?php
2/**
3 * (C)2012-2014 twcms.com TongWang Inc.
4 * Author: wuzhaohuan <kongphp@gmail.com>
5 */
6
7defined('TWCMS_PATH') or exit;
8
9class tag_control extends control{
10 public $_cfg = array(); // 全站参数
11 public $_var = array(); // 标签页参数
12
13 public function index() {
14 // hook tag_control_index_before.php
15
16 $this->_cfg = $this->runtime->xget();
17
18 $mid = max(2, (int)R('mid'));
19 $table = isset($this->_cfg['table_arr'][$mid]) ? $this->_cfg['table_arr'][$mid] : 'article';
20
21 $name = R('name');
22 empty($name) && core::error404();
23
24 $name = substr(urldecode($name), 0, 30);
25 $name = safe_str($name); // 牺牲一点性能
26 $this->cms_content_tag->table = 'cms_'.$table.'_tag';
27 $tags = $this->cms_content_tag->find_fetch(array('name'=>$name), array(), 0, 1);
28 empty($tags) && core::error404();
29 $tags = current($tags);
30
31 $this->_cfg['titles'] = $tags['name'];
32 $this->_var['topcid'] = -1;
33
34 $this->assign('tw', $this->_cfg);
35 $this->assign('tw_var', $this->_var);
36
37 $GLOBALS['run'] = &$this;
38 $GLOBALS['tags'] = &$tags;
39 $GLOBALS['mid'] = &$mid;
40 $GLOBALS['table'] = &$table;
41
42 // hook tag_control_index_after.php
43
44 $_ENV['_theme'] = &$this->_cfg['theme'];
45 $this->display('tag_list.htm');
46 }
47
48 // 热门标签
49 public function top() {
50 // hook tag_control_top_before.php
51
52 $this->_cfg = $this->runtime->xget();
53 $this->_cfg['titles'] = '热门标签';
54 $this->_var['topcid'] = -1;
55
56 $this->assign('tw', $this->_cfg);
57 $this->assign('tw_var', $this->_var);
58
59 $GLOBALS['run'] = &$this;
60
61 // hook tag_control_top_after.php
62
63 $_ENV['_theme'] = &$this->_cfg['theme'];
64 $this->display('tag_top.htm');
65 }
66}
67