@@ -184,26 +184,33 @@ function checkNeedRecompile($service = false) {
184
184
$ templateFile = $ templatePath . $ template ;
185
185
$ html = DIR_TEMPLATE . $ this ->tplFile ;
186
186
187
- if (strpos ($ this ->template , 'plugins ' . DS ) === 0 ) {
188
- $ templatePath = DIR_PUBLIC . 'plugins ' . DS ;
189
- //$templatePath = $this->templatePath = DIR_PUBLIC . 'plugins' . DS;
190
-
191
- $ template = str_replace ('plugins ' . DS , '' , $ template );
192
- $ p = strpos ($ template , DS );
193
- $ pluginName = substr ($ template , 0 , $ p );
194
- $ nameSpace = substr ($ template , $ p + 1 );
187
+ //absolute path
188
+ if ($ this ->template [0 ] == '/ ' ) {
189
+ $ templatePath = dirname ($ this ->template ) . '/ ' ;
190
+ $ template = basename ($ this ->template );
191
+ $ templateFile = $ this ->template ;
192
+ } else {
193
+ if (strpos ($ this ->template , 'plugins ' . DS ) === 0 ) {
194
+ $ templatePath = DIR_PUBLIC . 'plugins ' . DS ;
195
+ //$templatePath = $this->templatePath = DIR_PUBLIC . 'plugins' . DS;
196
+
197
+ $ template = str_replace ('plugins ' . DS , '' , $ template );
198
+ $ p = strpos ($ template , DS );
199
+ $ pluginName = substr ($ template , 0 , $ p );
200
+ $ nameSpace = substr ($ template , $ p + 1 );
201
+
202
+ if (APP == 'admin ' ) {
203
+ $ tpl = $ pluginName . DS . join (DS , [APP , 'template ' ]) . DS . $ nameSpace ;
204
+ $ template = $ pluginName . DS . APP . DS . $ nameSpace ;
205
+ } else {
206
+ $ tpl = $ pluginName . DS . join (DS , [APP , 'template ' ]) . DS . $ nameSpace ;
207
+ $ template = $ pluginName . DS . $ nameSpace ;
208
+ }
195
209
196
- if (APP == 'admin ' ) {
197
- $ tpl = $ pluginName . DS . join (DS , [APP , 'template ' ]) . DS . $ nameSpace ;
198
- $ template = $ pluginName . DS . APP . DS . $ nameSpace ;
199
- } else {
200
- $ tpl = $ pluginName . DS . join (DS , [APP , 'template ' ]) . DS . $ nameSpace ;
201
- $ template = $ pluginName . DS . $ nameSpace ;
210
+ $ this ->tplFile = str_replace ('.html ' , '.tpl ' , $ tpl );
211
+ $ html = DIR_PLUGINS . $ this ->tplFile ;
212
+ $ templateFile = $ templatePath . $ template ;
202
213
}
203
-
204
- $ this ->tplFile = str_replace ('.html ' , '.tpl ' , $ tpl );
205
- $ html = DIR_PLUGINS . $ this ->tplFile ;
206
- $ templateFile = $ templatePath . $ template ;
207
214
}
208
215
209
216
if (! file_exists ($ templatePath . $ template )) {
@@ -255,40 +262,45 @@ private function compile($filename, $file, $service = false) {
255
262
}
256
263
257
264
list ($ this ->template , $ filename , $ this ->tplFile ) =
258
- Event :: trigger (__CLASS__ ,__FUNCTION__ , $ this ->template , $ filename , $ this ->tplFile , $ this ->templateEngine , $ this );
265
+ Event :: trigger (__CLASS__ ,__FUNCTION__ , $ this ->template , $ filename , $ this ->tplFile , $ this ->templateEngine , $ this );
259
266
$ errors = $ this ->templateEngine ->loadHtmlTemplate ($ filename );
260
267
261
268
//if no template defined use the default
262
- if (strpos ($ this ->template , 'plugins ' . DS ) === 0 ) {
263
- //$template = str_replace('plugins' . DS, '', $this->template);
264
- $ template = $ this ->tplFile ;
265
- $ p = strpos ($ template , DS );
266
- $ pluginName = substr ($ template , 0 , $ p );
267
- $ nameSpace = substr ($ template , $ p + 1 );
268
-
269
- if (file_exists (DIR_PLUGINS . $ this ->tplFile )) {
270
- $ this ->tplFile = DIR_PLUGINS . $ this ->tplFile ;
271
- } else {
272
- $ this ->tplFile = DIR_TEMPLATE . 'common.tpl ' ;
273
- }
274
-
275
- //$this->tplFile = $pluginName . DS . APP . DS . 'template' . DS . $nameSpace;
269
+ if ($ this ->tplFile [0 ] == '/ ' ) {
270
+ $ this ->tplFile = DIR_TEMPLATE . 'common.tpl ' ;
276
271
$ this ->templateEngine ->loadTemplateFile ($ this ->tplFile );
277
- /*
278
- if (APP == 'admin') {
279
- $this->tplFile = $pluginName . DS . APP ."/template/$nameSpace";
280
- } else {
281
- $this->tplFile = "$pluginName/admin/template/$nameSpace";
282
- }*/
283
272
} else {
284
- if (! file_exists (DIR_TEMPLATE . $ this ->tplFile )) {
285
- $ this ->tplFile = 'common.tpl ' ;
273
+ if (strpos ($ this ->template , 'plugins ' . DS ) === 0 ) {
274
+ //$template = str_replace('plugins' . DS, '', $this->template);
275
+ $ template = $ this ->tplFile ;
276
+ $ p = strpos ($ template , DS );
277
+ $ pluginName = substr ($ template , 0 , $ p );
278
+ $ nameSpace = substr ($ template , $ p + 1 );
279
+
280
+ if (file_exists (DIR_PLUGINS . $ this ->tplFile )) {
281
+ $ this ->tplFile = DIR_PLUGINS . $ this ->tplFile ;
282
+ } else {
283
+ $ this ->tplFile = DIR_TEMPLATE . 'common.tpl ' ;
284
+ }
285
+
286
+ //$this->tplFile = $pluginName . DS . APP . DS . 'template' . DS . $nameSpace;
287
+ $ this ->templateEngine ->loadTemplateFile ($ this ->tplFile );
288
+ /*
289
+ if (APP == 'admin') {
290
+ $this->tplFile = $pluginName . DS . APP ."/template/$nameSpace";
291
+ } else {
292
+ $this->tplFile = "$pluginName/admin/template/$nameSpace";
293
+ }*/
294
+ } else {
295
+ if (! file_exists (DIR_TEMPLATE . $ this ->tplFile )) {
296
+ $ this ->tplFile = 'common.tpl ' ;
297
+ }
298
+ $ this ->templateEngine ->loadTemplateFileFromPath ($ this ->tplFile );
286
299
}
287
- $ this ->templateEngine ->loadTemplateFileFromPath ($ this ->tplFile );
288
300
}
289
301
290
302
list ($ this ->template , $ filename , $ this ->tplFile ) =
291
- Event :: trigger (__CLASS__ ,__FUNCTION__ . ':after ' , $ this ->template , $ filename , $ this ->tplFile , $ this ->templateEngine , $ this );
303
+ Event :: trigger (__CLASS__ ,__FUNCTION__ . ':after ' , $ this ->template , $ filename , $ this ->tplFile , $ this ->templateEngine , $ this );
292
304
$ this ->templateEngine ->saveCompiledTemplate ($ file );
293
305
}
294
306
@@ -333,7 +345,7 @@ function setType($type) {
333
345
$ this ->_type = $ type ;
334
346
}
335
347
336
- function getType ($ type ) {
348
+ function getType () {
337
349
return $ this ->_type ;
338
350
}
339
351
0 commit comments