forked from FeeiCN/grw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplateParse.php
executable file
·129 lines (112 loc) · 3.3 KB
/
TemplateParse.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* 模板解析
* Class TemplateParse
*/
class TemplateParse
{
/**
* 模板引擎实例
*/
public $engine = NULL;
/**
* 模板是否已输出
*/
public $displayed = FALSE;
/**
* 网站信息
*/
public $site = NULL;
/**
* 构造函数,进行模板引擎的实例化操作
*/
public function __construct()
{
if (FALSE == $GLOBALS['G_Fei']['view']['enabled']) return FALSE;
if (FALSE != $GLOBALS['G_Fei']['view']['auto_ob_start']) ob_start();
$this->engine = FeiClass($GLOBALS['G_Fei']['view']['engine_name'], NULL, $GLOBALS['G_Fei']['view']['engine_path']);
if ($GLOBALS['G_Fei']['view']['config'] && is_array($GLOBALS['G_Fei']['view']['config'])) {
$engine_vars = get_class_vars(get_class($this->engine));
foreach ($GLOBALS['G_Fei']['view']['config'] as $key => $value) {
if (array_key_exists($key, $engine_vars)) $this->engine->{$key} = $value;
}
}
if (!empty($GLOBALS['G_Fei']['Fei_app_id']) && isset($this->engine->compile_id)) $this->engine->compile_id = $GLOBALS['G_Fei']['Fei_app_id'];
// 检查编译目录是否可写
if (empty($this->engine->no_compile_dir) && (!is_dir($this->engine->compile_dir) || !is_writable($this->engine->compile_dir))) __mkdirs($this->engine->compile_dir);
FeiAddViewFunction('Copyright', array('TemplateParse', '__template_Copyright'));
FeiAddViewFunction('Title', array('TemplateParse', '__template_Title'));
FeiAddViewFunction('Keywords', array('TemplateParse', '__template_Keywords'));
FeiAddViewFunction('Description', array('TemplateParse', '__template_Description'));
FeiAddViewFunction('Author', array('TemplateParse', '__template_Author'));
FeiAddViewFunction('Category', array('TemplateParse', '__template_Category'));
$this->site = FeiClass('model_site')->find();
$this->contact = FeiClass('model_contact')->find();
}
/**
* SITE INFO
*/
public function __template_Copyright()
{
return 'Copyright 2004-2012 <a href=\'http://www.feei.cn\'>Feei.</a> All Rights Reserved';
}
public function __template_Title()
{
return $this->site['title'];
}
public function __template_Keywords()
{
return $this->site['keywords'];
}
public function __template_Description()
{
return $this->site['description'];
}
public function __template_Author()
{
return $this->site['author'];
}
public function __template_Icp()
{
return $this->site['icp'];
}
/**
* CONTACT INFO
*/
public function __template_Company()
{
return $this->contact['company'];
}
public function __template_Linkman()
{
return $this->contact['linkman'];
}
public function __template_Phone()
{
return $this->contact['phone'];
}
public function __template_Tel()
{
return $this->contact['tel'];
}
public function __template_Fax()
{
return $this->contact['fax'];
}
public function __template_address()
{
return $this->contact['address'];
}
public function __template_email()
{
return $this->contact['email'];
}
public function __template_Category($params)
{
$category = FeiClass(model_category);
$result = $category->findBy('letter', $params[letter]);
$conditions = array('parentid' => $result[catid]);
$result = $category->findAll($conditions);
return $result;
}
}