@@ -22,18 +22,6 @@ class Controller extends \think\Controller
2222 protected $ action = null ;
2323 // 当前template
2424 protected $ template ;
25- // 模板配置信息
26- protected $ config = [
27- 'type ' => 'Think ' ,
28- 'view_path ' => '' ,
29- 'view_suffix ' => 'html ' ,
30- 'strip_space ' => true ,
31- 'view_depr ' => DS ,
32- 'tpl_begin ' => '{ ' ,
33- 'tpl_end ' => '} ' ,
34- 'taglib_begin ' => '{ ' ,
35- 'taglib_end ' => '} ' ,
36- ];
3725
3826 /**
3927 * 无需登录的方法,同时也就不需要鉴权了
@@ -49,13 +37,13 @@ class Controller extends \think\Controller
4937
5038 /**
5139 * 权限Auth
52- * @var Auth
40+ * @var Auth
5341 */
5442 protected $ auth = null ;
55-
43+
5644 /**
5745 * 布局模板
58- * @var string
46+ * @var string
5947 */
6048 protected $ layout = null ;
6149
@@ -72,12 +60,9 @@ public function __construct(Request $request = null)
7260 }
7361 // 生成request对象
7462 $ this ->request = $ request ;
75-
63+
7664 //移除HTML标签
7765 $ this ->request ->filter ('strip_tags ' );
78-
79- // 初始化配置信息
80- $ this ->config = Config::get ('template ' ) ?: $ this ->config ;
8166
8267 // 是否自动转换控制器和操作名
8368 $ convert = Config::get ('url_convert ' );
@@ -106,23 +91,19 @@ public function __construct(Request $request = null)
10691 $ this ->controller = $ controller ? call_user_func ($ filter , $ controller ) : 'index ' ;
10792 $ this ->action = $ action ? call_user_func ($ filter , $ action ) : 'index ' ;
10893
109- // 生成view_path
110- $ view_path = $ this ->config ['view_path ' ] ?: 'view ' ;
111-
11294 // 重置配置
113- Config::set ('template.view_path ' , ADDON_PATH . $ this ->addon . DS . $ view_path . DS );
95+ Config::set ('template.view_path ' , ADDON_PATH . $ this ->addon . DS . ' view ' . DS );
11496
11597 // 父类的调用必须放在设置模板路径之后
11698 parent ::__construct ($ this ->request );
117-
11899 }
119-
100+
120101 protected function _initialize ()
121102 {
122103 // 渲染配置到视图中
123104 $ config = get_addon_config ($ this ->addon );
124105 $ this ->view ->assign ("config " , $ config );
125-
106+
126107 // 加载系统语言包
127108 Lang::load ([
128109 ADDON_PATH . $ this ->addon . DS . 'lang ' . DS . $ this ->request ->langset () . EXT ,
@@ -131,7 +112,7 @@ protected function _initialize()
131112 // 设置替换字符串
132113 $ cdnurl = Config::get ('site.cdnurl ' );
133114 $ this ->view ->replace ('__ADDON__ ' , $ cdnurl . "/assets/addons/ " . $ this ->addon );
134-
115+
135116 $ this ->auth = Auth::instance ();
136117 // token
137118 $ token = $ this ->request ->server ('HTTP_TOKEN ' , $ this ->request ->request ('token ' , \think \Cookie::get ('token ' )));
@@ -167,13 +148,13 @@ protected function _initialize()
167148 $ this ->auth ->init ($ token );
168149 }
169150 }
170-
151+
171152 // 如果有使用模板布局
172153 if ($ this ->layout )
173154 {
174155 $ this ->view ->engine ->layout ('layout/ ' . $ this ->layout );
175156 }
176-
157+
177158 $ this ->view ->assign ('user ' , $ this ->auth ->getUser ());
178159
179160 $ site = Config::get ("site " );
@@ -200,9 +181,9 @@ protected function _initialize()
200181 protected function fetch ($ template = '' , $ vars = [], $ replace = [], $ config = [])
201182 {
202183 $ controller = Loader::parseName ($ this ->controller );
203- if ('think ' == strtolower ($ this -> config [ ' type '] ) && $ controller && 0 !== strpos ($ template , '/ ' ))
184+ if ('think ' == strtolower (Config:: get ( ' template. type ') ) && $ controller && 0 !== strpos ($ template , '/ ' ))
204185 {
205- $ depr = $ this -> config [ ' view_depr '] ;
186+ $ depr = Config:: get ( ' template. view_depr ') ;
206187 $ template = str_replace (['/ ' , ': ' ], $ depr , $ template );
207188 if ('' == $ template )
208189 {
0 commit comments