Esempio n. 1
0
 /**
  * Launch the compilation of a template
  *
  * Store the result (a php content) into a cache file given by the selector.
  * @param jSelectorTpl $selector the template selector
  * @return boolean true if ok
  */
 public function compile($selector)
 {
     $this->_sourceFile = $selector->getPath();
     $cachefile = $selector->getCompiledFilePath();
     $this->outputType = $selector->outputType;
     $this->trusted = $selector->trusted;
     $this->_modifier = array_merge($this->_modifier, $selector->userModifiers);
     $this->_userFunctions = $selector->userFunctions;
     jContext::push($selector->module);
     if (!file_exists($this->_sourceFile)) {
         $this->doError0('errors.tpl.not.found');
     }
     $result = $this->compileContent(file_get_contents($this->_sourceFile));
     $header = "<?php \n";
     foreach ($this->_pluginPath as $path => $ok) {
         $header .= ' require_once(\'' . $path . "');\n";
     }
     $header .= 'function template_meta_' . md5($selector->module . '_' . $selector->resource . '_' . $this->outputType . ($this->trusted ? '_t' : '')) . '($t){';
     $header .= "\n" . $this->_metaBody . "\n}\n";
     $header .= 'function template_' . md5($selector->module . '_' . $selector->resource . '_' . $this->outputType . ($this->trusted ? '_t' : '')) . '($t){' . "\n?>";
     $result = $header . $result . "<?php \n}\n?>";
     jFile::write($cachefile, $result);
     jContext::pop();
     return true;
 }
Esempio n. 2
0
 /**
  * Launch the compilation of a template
  *
  * Store the result (a php content) into a cache file given by the selector.
  * @param jSelectorTpl $selector the template selector
  * @return boolean true if ok
  */
 public function compile($selector)
 {
     $this->_sourceFile = $selector->getPath();
     $this->outputType = $selector->outputType;
     $this->trusted = $selector->trusted;
     $md5 = md5($selector->module . '_' . $selector->resource . '_' . $this->outputType . ($this->trusted ? '_t' : ''));
     jApp::pushCurrentModule($selector->module);
     if (!file_exists($this->_sourceFile)) {
         $this->doError0('errors.tpl.not.found');
     }
     $header = "if (jApp::config()->compilation['checkCacheFiletime'] &&\n";
     $header .= "filemtime('" . $this->_sourceFile . '\') > ' . filemtime($this->_sourceFile) . "){ return false;\n} else {\n";
     $footer = "return true;}\n";
     $this->compileString(file_get_contents($this->_sourceFile), $selector->getCompiledFilePath(), $selector->userModifiers, $selector->userFunctions, $md5, $header, $footer);
     jApp::popCurrentModule();
     return true;
 }