| | 381 | |
|---|
| | 382 | class jVTplCompiler extends jTplCompiler { |
|---|
| | 383 | private $_pluginPath=array(); |
|---|
| | 384 | private $_metaBody = ''; |
|---|
| | 385 | |
|---|
| | 386 | public function compile($selector){ |
|---|
| | 387 | |
|---|
| | 388 | $this->dynFile = $selector->getPath(); |
|---|
| | 389 | $cachefile = $selector->getCompiledFilePath(); |
|---|
| | 390 | $this->outputType = $selector->outputType; |
|---|
| | 391 | $this->trusted = $selector->trusted; |
|---|
| | 392 | jContext::push($selector->module); |
|---|
| | 393 | |
|---|
| | 394 | require_once($this->dynFile); |
|---|
| | 395 | $dyn = new dynTpl(); |
|---|
| | 396 | if( !is_callable(array($dyn, $selector->resource)) ) { |
|---|
| | 397 | $this->doError0('errors.tpl.not.found'); |
|---|
| | 398 | } |
|---|
| | 399 | |
|---|
| | 400 | $result = $this->compileContent($dyn->{$selector->resource}()); |
|---|
| | 401 | |
|---|
| | 402 | $header ="<?php \n"; |
|---|
| | 403 | foreach($this->_pluginPath as $path=>$ok){ |
|---|
| | 404 | $header.=' require_once(\''.$path."');\n"; |
|---|
| | 405 | } |
|---|
| | 406 | $header.='function template_meta_'.md5($selector->module.'_'.$selector->resource.'_'.$this->outputType.($this->trusted?'_t':'')).'($t){'; |
|---|
| | 407 | $header .="\n".$this->_metaBody."\n}\n"; |
|---|
| | 408 | $header.='function template_'.md5($selector->module.'_'.$selector->resource.'_'.$this->outputType.($this->trusted?'_t':'')).'($t){'."\n?>"; |
|---|
| | 409 | $result = $header.$result."<?php \n}\n?>"; |
|---|
| | 410 | jFile::write($cachefile, $result); |
|---|
| | 411 | jContext::pop(); |
|---|
| | 412 | return true; |
|---|
| | 413 | } |
|---|
| | 414 | } |
|---|