forked from hetao29/slightphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTpl.php
More file actions
93 lines (91 loc) · 2.67 KB
/
STpl.php
File metadata and controls
93 lines (91 loc) · 2.67 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
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
<?php
/*{{{LICENSE
+-----------------------------------------------------------------------+
| SlightPHP Framework |
+-----------------------------------------------------------------------+
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation. You should have received a copy of the |
| GNU General Public License along with this program. If not, see |
| http://www.gnu.org/licenses/. |
| Copyright (C) 2008-2009. All Rights Reserved. |
+-----------------------------------------------------------------------+
| Supports: http://www.slightphp.com |
+-----------------------------------------------------------------------+
}}}*/
if(!defined("SLIGHTPHP_PLUGINS_DIR"))define("SLIGHTPHP_PLUGINS_DIR",dirname(__FILE__));
require_once(SLIGHTPHP_PLUGINS_DIR."/tpl/Tpl.php");
/**
* @package SlightPHP
*/
class STpl extends SlightPHP\Tpl{
/**
* 设置强制编译
*/
public static function setForceCompile($force_compile=false){
parent::$force_compile=$force_compile;
}
/**
* 安全模式,禁止编译php代码
*/
public static function setSafeMode($safe_mode=true){
parent::$safe_mode=$safe_mode;
}
/**
* 设置模板代码的左右分割符号
*/
public static function setDelimter($left="{", $right="}"){
parent::$left_delimiter=$left;
parent::$right_delimiter=$right;
}
/**
* 设置模板编译路径
*/
public static function setCompileDir($path=""){
if($path==""){
parent::$compile_dir = SlightPHP::$appDir.DIRECTORY_SEPARATOR."templates_c";
}else{
parent::$compile_dir = $path;
}
}
/**
* 设置模板文件路径
*/
public static function setTemplateDir($path=""){
if($path==""){
parent::$template_dir= SlightPHP::$appDir.DIRECTORY_SEPARATOR."templates";
}else{
parent::$template_dir= $path;
}
}
/**
* 渲染模板
*/
public function render($tpl,$parames=array()){
if(parent::$template_dir==""){
self::setTemplateDir();
}
if(parent::$compile_dir==""){
self::setCompileDir();
}
if(parent::$left_delimiter=="" || parent::$right_delimiter==""){
self::setDelimter();
}
parent::assign($parames);
return parent::fetch("$tpl");
}
/**
* 别名 render
*/
public function display($tpl,$parames=array()){
return $this->render($tpl, $parames);
}
/**
* 302 redirect
*/
public function redirect($url) {
header('Location:'.$url);
exit;
}
}
?>