@@ -32,13 +32,6 @@ abstract class Action {
32
32
*/
33
33
private $ name = '' ;
34
34
35
- /**
36
- * 模板变量
37
- * @var tVar
38
- * @access protected
39
- */
40
- protected $ tVar = array ();
41
-
42
35
/**
43
36
* 控制器参数
44
37
* @var config
@@ -52,6 +45,8 @@ abstract class Action {
52
45
*/
53
46
public function __construct () {
54
47
tag ('action_begin ' ,$ this ->config );
48
+ //实例化视图类
49
+ $ this ->view = Think::instance ('View ' );
55
50
//控制器初始化
56
51
if (method_exists ($ this ,'_initialize ' ))
57
52
$ this ->_initialize ();
@@ -97,7 +92,6 @@ protected function isAjax() {
97
92
* @return void
98
93
*/
99
94
protected function display ($ templateFile ='' ,$ charset ='' ,$ contentType ='' ,$ content ='' ,$ prefix ='' ) {
100
- $ this ->initView ();
101
95
$ this ->view ->display ($ templateFile ,$ charset ,$ contentType ,$ content ,$ prefix );
102
96
}
103
97
@@ -111,7 +105,6 @@ protected function display($templateFile='',$charset='',$contentType='',$content
111
105
* @return mixed
112
106
*/
113
107
protected function show ($ content ,$ charset ='' ,$ contentType ='' ,$ prefix ='' ) {
114
- $ this ->initView ();
115
108
$ this ->view ->display ('' ,$ charset ,$ contentType ,$ content ,$ prefix );
116
109
}
117
110
@@ -126,22 +119,9 @@ protected function show($content,$charset='',$contentType='',$prefix='') {
126
119
* @return string
127
120
*/
128
121
protected function fetch ($ templateFile ='' ,$ content ='' ,$ prefix ='' ) {
129
- $ this ->initView ();
130
122
return $ this ->view ->fetch ($ templateFile ,$ content ,$ prefix );
131
123
}
132
124
133
- /**
134
- * 初始化视图
135
- * @access private
136
- * @return void
137
- */
138
- private function initView (){
139
- //实例化视图类
140
- if (!$ this ->view ) $ this ->view = Think::instance ('View ' );
141
- // 模板变量传值
142
- if ($ this ->tVar ) $ this ->view ->assign ($ this ->tVar );
143
- }
144
-
145
125
/**
146
126
* 创建静态页面
147
127
* @access protected
@@ -171,11 +151,8 @@ protected function buildHtml($htmlfile='',$htmlpath='',$templateFile='') {
171
151
* @return void
172
152
*/
173
153
protected function assign ($ name ,$ value ='' ) {
174
- if (is_array ($ name )) {
175
- $ this ->tVar = array_merge ($ this ->tVar ,$ name );
176
- }else {
177
- $ this ->tVar [$ name ] = $ value ;
178
- }
154
+ $ this ->view ->assign ($ name ,$ value );
155
+ return $ this ;
179
156
}
180
157
181
158
public function __set ($ name ,$ value ) {
@@ -189,10 +166,7 @@ public function __set($name,$value) {
189
166
* @return mixed
190
167
*/
191
168
public function get ($ name ='' ) {
192
- if ('' === $ name ) {
193
- return $ this ->tVar ;
194
- }
195
- return isset ($ this ->tVar [$ name ])?$ this ->tVar [$ name ]:false ;
169
+ return $ this ->view ->get ($ name );
196
170
}
197
171
198
172
public function __get ($ name ) {
@@ -206,7 +180,7 @@ public function __get($name) {
206
180
* @return boolean
207
181
*/
208
182
public function __isset ($ name ) {
209
- return isset ( $ this ->tVar [ $ name] );
183
+ return $ this ->get ( $ name );
210
184
}
211
185
212
186
/**
@@ -254,9 +228,8 @@ public function __call($method,$args) {
254
228
default :
255
229
$ input = $ _GET ;
256
230
}
257
- if (C ('VAR_URL_PARAMS ' )){
258
- $ params = $ _GET [C ('VAR_URL_PARAMS ' )];
259
- $ input = array_merge ($ input ,$ params );
231
+ if (C ('VAR_URL_PARAMS ' ) && isset ($ _GET [C ('VAR_URL_PARAMS ' )])){
232
+ $ input = array_merge ($ input ,$ _GET [C ('VAR_URL_PARAMS ' )]);
260
233
}
261
234
break ;
262
235
case '_request ' : $ input =& $ _REQUEST ; break ;
@@ -283,6 +256,7 @@ public function __call($method,$args) {
283
256
}else { // 变量默认值
284
257
$ data = isset ($ args [2 ])?$ args [2 ]:NULL ;
285
258
}
259
+ Log::record ('建议使用I方法替代 ' .$ method ,Log::NOTICE );
286
260
return $ data ;
287
261
}
288
262
}
@@ -295,7 +269,7 @@ public function __call($method,$args) {
295
269
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
296
270
* @return void
297
271
*/
298
- protected function error ($ message ,$ jumpUrl ='' ,$ ajax =false ) {
272
+ protected function error ($ message= '' ,$ jumpUrl ='' ,$ ajax =false ) {
299
273
$ this ->dispatchJump ($ message ,0 ,$ jumpUrl ,$ ajax );
300
274
}
301
275
@@ -307,7 +281,7 @@ protected function error($message,$jumpUrl='',$ajax=false) {
307
281
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
308
282
* @return void
309
283
*/
310
- protected function success ($ message ,$ jumpUrl ='' ,$ ajax =false ) {
284
+ protected function success ($ message= '' ,$ jumpUrl ='' ,$ ajax =false ) {
311
285
$ this ->dispatchJump ($ message ,1 ,$ jumpUrl ,$ ajax );
312
286
}
313
287
@@ -420,8 +394,6 @@ private function dispatchJump($message,$status=1,$jumpUrl='',$ajax=false) {
420
394
* @access public
421
395
*/
422
396
public function __destruct () {
423
- // 保存日志
424
- if (C ('LOG_RECORD ' )) Log::save ();
425
397
// 执行后续操作
426
398
tag ('action_end ' );
427
399
}
0 commit comments