Source for file jSelectorTpl.class.php

Documentation is available at jSelectorTpl.class.php

  1. <?php
  2. /**
  3. * see jISelector.iface.php for documentation about selectors. Here abstract class for many selectors
  4. *
  5. @package     jelix
  6. @subpackage  core_selector
  7. @author      Laurent Jouanneau
  8. @copyright   2005-2007 Laurent Jouanneau
  9. @link        http://www.jelix.org
  10. @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
  11. */
  12.  
  13.  
  14. /**
  15.  * Template selector
  16.  *
  17.  * syntax : "module~tplName".
  18.  * file : templates/tplName.tpl .
  19.  * @package    jelix
  20.  * @subpackage core_selector
  21.  */
  22. class jSelectorTpl extends jSelectorModule {
  23.     protected $type = 'tpl';
  24.     protected $_dirname = 'templates/';
  25.     protected $_suffix = '.tpl';
  26.     protected $_where;
  27.     public $outputType='';
  28.     public $trusted=true;
  29.     public $userModifiers = array();
  30.     public $userFunctions = array();
  31.  
  32.     /**
  33.      * @param string $sel the template selector
  34.      * @param string $outputtype  the type of output (html, text..) By default, it takes the response type
  35.      * @param boolean $trusted  says if the template file is trusted or not
  36.      */
  37.     function __construct($sel$outputtype=''$trusted=true){
  38.         if($outputtype == ''{
  39.             if($GLOBALS['gJCoord']->response)
  40.                 $this->outputType = $GLOBALS['gJCoord']->response->getFormatType();
  41.             else
  42.                 $this->outputType = $GLOBALS['gJCoord']->request->defaultResponseType;
  43.         else
  44.             $this->outputType = $outputtype;
  45.         $this->trusted = $trusted;
  46.         $this->_compiler='jTplCompiler';
  47.         $this->_compilerPath=JELIX_LIB_PATH.'tpl/jTplCompiler.class.php';
  48.         parent::__construct($sel);
  49.     }
  50.  
  51.     protected function _createPath(){
  52.         global $gJConfig;
  53.         if(!isset($gJConfig->_modulesPathList[$this->module])){
  54.             throw new jExceptionSelector('jelix~errors.selector.module.unknown'$this->toString());
  55.         }
  56.  
  57.         $path $this->module.'/'.$this->resource;
  58.         $lpath $this->module.'/'.$gJConfig->locale.'/'.$this->resource;
  59.  
  60.         if($gJConfig->theme != 'default'){
  61.             // check if there is a redefined template for the current theme
  62.             $this->_where = 'themes/'.$gJConfig->theme.'/'.$lpath;
  63.             $this->_path = jApp::varPath($this->_where.'.tpl');
  64.             if (is_readable ($this->_path)){
  65.                 return;
  66.             }
  67.             // check if there is a redefined template for the current localized theme
  68.             $this->_where = 'themes/'.$gJConfig->theme.'/'.$path;
  69.             $this->_path = jApp::varPath($this->_where.'.tpl');
  70.             if (is_readable ($this->_path)){
  71.                 return;
  72.             }
  73.         }
  74.  
  75.        // check if there is a redefined template for the default theme
  76.         $this->_where = 'themes/default/'.$lpath;
  77.         $this->_path = jApp::varPath($this->_where.'.tpl');
  78.         if (is_readable ($this->_path)){
  79.             return;
  80.         }
  81.  
  82.         $this->_where = 'themes/default/'.$path;
  83.         $this->_path = jApp::varPath($this->_where.'.tpl');
  84.         if (is_readable ($this->_path)){
  85.             return;
  86.         }
  87.  
  88.         // else check if the template exists in the current module
  89.         $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$gJConfig->locale.'/'.$this->resource.'.tpl';
  90.         if (is_readable ($this->_path)){
  91.             $this->_where = 'modules/'.$lpath;
  92.             return;
  93.         }
  94.  
  95.         $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$this->resource.'.tpl';
  96.         if (is_readable ($this->_path)){
  97.             $this->_where = 'modules/'.$path;
  98.             return;
  99.         }
  100.  
  101.         throw new jExceptionSelector('jelix~errors.selector.invalid.target'array($this->toString()"template"));
  102.  
  103.     }
  104.  
  105.     protected function _createCachePath(){
  106.        // don't share the same cache for all the possible dirs
  107.        // in case of overload removal
  108.        $this->_cachePath = jApp::tempPath('compiled/templates/'.$this->_where.'_'.$this->outputType.($this->trusted?'_t':'').$this->_cacheSuffix);
  109.     }
  110. }

Documentation generated on Wed, 24 Sep 2014 22:02:04 +0200 by phpDocumentor 1.4.3