Ticket #545: init.diff

File init.diff, 3.2 kB (added by Lipki, 9 months ago)
  • init.php

    old new  
    167167        protected $_cachePath; 
    168168        protected $_compiler = null; 
    169169        protected $_compilerPath; 
     170        protected $_dyn = false; 
    170171        protected $_useMultiSourceCompiler=false; 
    171172        function __construct($sel){ 
    172173                if(preg_match("/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_\.]+)$/", $sel, $m)){ 
     
    545546           $this->_cachePath = JELIX_APP_TEMP_PATH.'compiled/templates/'.$this->_where.'_'.$this->outputType.($this->trusted?'_t':'').$this->_cacheSuffix; 
    546547        } 
    547548} 
     549class jSelectorVTpl extends jSelectorModule { 
     550    protected $type = 'tpl'; 
     551    protected $_dirname = 'classes/'; 
     552    protected $_suffix = '.tpl'; 
     553    protected $_where; 
     554    public $outputType=''; 
     555    public $trusted=true; 
     556    public $_dyn = true; 
     557        function __construct($sel, $outputtype='', $trusted=true) { 
     558        if($outputtype == ''){ 
     559            if($GLOBALS['gJCoord']->response) 
     560                $this->outputType = $GLOBALS['gJCoord']->response->getFormatType(); 
     561            else 
     562                $this->outputType = $GLOBALS['gJCoord']->request->defaultResponseType; 
     563        } else 
     564            $this->outputType = $outputtype; 
     565        $this->trusted = $trusted; 
     566        $this->_compiler='jVTplCompiler'; 
     567        $this->_compilerPath=JELIX_LIB_PATH.'tpl/jTplCompiler.class.php'; 
     568        parent::__construct($sel); 
     569    } 
     570    protected function _createPath(){ 
     571        global $gJConfig; 
     572        if(!isset($gJConfig->_modulesPathList[$this->module])){ 
     573            throw new jExceptionSelector('jelix~errors.selector.module.unknow', $this->toString()); 
     574        } 
     575                $path = $this->module.'/'.$this->resource; 
     576                // pas d'overload via themes/ 
     577                // pas de local 
     578        $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.'dynTpl.class.php'; 
     579        if(is_readable($this->_path)){ 
     580            $this->_where = 'modules/'.$path; 
     581            return; 
     582        } 
     583                throw new jExceptionSelector('jelix~errors.selector.invalid.target', array($this->toString(), "dyn template")); 
     584    } 
     585    protected function _createCachePath(){ 
     586       $this->_cachePath = JELIX_APP_TEMP_PATH.'compiled/templates/'.$this->_where.'_'.$this->outputType.($this->trusted?'_t':'').$this->_cacheSuffix; 
     587    } 
     588} 
    548589class jSelectorZone extends jSelectorModule{ 
    549590        protected $type = 'zone'; 
    550591        protected $_dirname = 'zones/'; 
     
    13741415                } 
    13751416                $mustCompile = $gJConfig->compilation['force'] || !file_exists($cachefile); 
    13761417                $sourcefile = $aSelector->getPath(); 
    1377                 if($sourcefile == '' || !file_exists($sourcefile)){ 
     1418                if( ( $sourcefile == '' || !file_exists($sourcefile) ) && !$aSelector->_dyn ){ 
    13781419                        throw new jException('jelix~errors.includer.source.missing',array( $aSelector->toString(true))); 
    13791420                } 
    13801421                if($gJConfig->compilation['checkCacheFiletime'] && !$mustCompile){ 
     
    13851426                $compileok=true; 
    13861427                if($mustCompile){ 
    13871428                        $compiler = $aSelector->getCompiler(); 
    1388                         if($compiler && $compileok=$compiler->compile($aSelector))
     1429                        if($compiler && $compileok=$compiler->compile($aSelector))
    13891430                                require_once($cachefile); 
    13901431                                jIncluder::$_includedFiles[$cachefile]=true; 
    13911432                        } 
Download in other formats: Original Format