Changeset 601

Show
Ignore:
Timestamp:
09/29/07 22:26:30 (1 year ago)
Author:
laurentj
Message:

Ticket #289: added the possibility to overload a jforms form

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/core/jSelector.class.php

    r598 r601  
    497497        if (is_readable ($overloadedPath)){ 
    498498           $this->_path = $overloadedPath; 
    499            $this->_where = 1
     499           $this->_where = 'overloaded/'
    500500           return; 
    501501        } 
     
    506506            throw new jExceptionSelector('jelix~errors.selector.invalid.target', array($this->toString(), "dao")); 
    507507        } 
    508         $this->_where = 0
     508        $this->_where = 'modules/'
    509509    } 
    510510 
    511511    protected function _createCachePath(){ 
    512         $d = array('modules/','overloaded/'); 
    513512        // on ne partage pas le même cache pour tous les emplacements possibles 
    514513        // au cas où un overload était supprimé 
    515         $this->_cachePath = JELIX_APP_TEMP_PATH.'compiled/daos/'.$d[$this->_where].$this->module.'~'.$this->resource.'~'.$this->driver.$this->_cacheSuffix; 
     514        $this->_cachePath = JELIX_APP_TEMP_PATH.'compiled/daos/'.$this->_where.$this->module.'~'.$this->resource.'~'.$this->driver.$this->_cacheSuffix; 
    516515    } 
    517516 
     
    562561        } 
    563562 
     563        $path = $this->module.'/'.$this->resource; 
     564        $lpath = $this->module.'/'.$gJConfig->locale.'/'.$this->resource; 
     565 
    564566        if($gJConfig->theme != 'default'){ 
    565567            // on regarde si il y a un template redéfinie pour le theme courant 
    566             $this->_where = 'themes/'.$gJConfig->theme.'/'.$this->module.'/'.$gJConfig->locale.'/'.$this->resource
     568            $this->_where = 'themes/'.$gJConfig->theme.'/'.$lpath
    567569            $this->_path = JELIX_APP_VAR_PATH.$this->_where.'.tpl'; 
    568570            if (is_readable ($this->_path)){ 
     
    570572            } 
    571573            // on regarde si il y a un template redéfinie pour le theme courant 
    572             $this->_where = 'themes/'.$gJConfig->theme.'/'.$this->module.'/'.$this->resource
     574            $this->_where = 'themes/'.$gJConfig->theme.'/'.$path
    573575            $this->_path = JELIX_APP_VAR_PATH.$this->_where.'.tpl'; 
    574576            if (is_readable ($this->_path)){ 
     
    578580 
    579581        // on regarde si il y a un template redéfinie dans le theme par defaut 
    580         $this->_where = 'themes/default/'.$this->module.'/'.$gJConfig->locale.'/'.$this->resource
     582        $this->_where = 'themes/default/'.$lpath
    581583        $this->_path = JELIX_APP_VAR_PATH.$this->_where.'.tpl'; 
    582584        if (is_readable ($this->_path)){ 
     
    584586        } 
    585587 
    586         $this->_where = 'themes/default/'.$this->module.'/'.$this->resource
     588        $this->_where = 'themes/default/'.$path
    587589        $this->_path = JELIX_APP_VAR_PATH.$this->_where.'.tpl'; 
    588590        if (is_readable ($this->_path)){ 
     
    593595        $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$gJConfig->locale.'/'.$this->resource.'.tpl'; 
    594596        if (is_readable ($this->_path)){ 
    595             $this->_where = 'modules/'.$this->module.'/'.$gJConfig->locale.'/'.$this->resource
     597            $this->_where = 'modules/'.$lpath
    596598            return; 
    597599        } 
     
    599601        $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$this->resource.'.tpl'; 
    600602        if (is_readable ($this->_path)){ 
    601             $this->_where = 'modules/'.$this->module.'/'.$this->resource
     603            $this->_where = 'modules/'.$path
    602604            return; 
    603605        } 
     
    642644class jSelectorForm extends jSelectorModule { 
    643645    protected $type = 'form'; 
    644  
     646    protected $_where; 
     647    protected $_dirname = 'forms/'; 
     648    protected $_suffix = '.form.xml'; 
     649     
    645650    function __construct($sel){ 
    646651 
    647         $this->_dirname =  'forms/'; 
    648         $this->_suffix = '.form.xml'; 
    649         $this->_cacheSuffix = '.php'; 
    650652        $this->_compiler='jFormsCompiler'; 
    651653        $this->_compilerPath=JELIX_LIB_FORMS_PATH.'jFormsCompiler.class.php'; 
     
    658660    } 
    659661 
     662    
     663    protected function _createPath(){ 
     664        global $gJConfig; 
     665        if(!isset($gJConfig->_modulesPathList[$this->module])){ 
     666            throw new jExceptionSelector('jelix~errors.selector.module.unknow', $this->toString(true)); 
     667        } 
     668         
     669        // we see if the forms have been redefined 
     670        $overloadedPath = JELIX_APP_VAR_PATH.'overloads/'.$this->module.'/'.$this->_dirname.$this->resource.$this->_suffix; 
     671        if (is_readable ($overloadedPath)){ 
     672           $this->_path = $overloadedPath; 
     673           $this->_where = 'overloaded/'; 
     674           return; 
     675        } 
     676 
     677        $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$this->resource.$this->_suffix; 
     678        if (!is_readable ($this->_path)){ 
     679            throw new jExceptionSelector('jelix~errors.selector.invalid.target', array($this->toString(), $this->type)); 
     680        } 
     681        $this->_where = 'modules/'; 
     682    } 
     683     
     684    protected function _createCachePath(){ 
     685        // on ne partage pas le même cache pour tous les emplacements possibles 
     686        // au cas où un overload était supprimé 
     687        $this->_cachePath = JELIX_APP_TEMP_PATH.'compiled/'.$this->_dirname.$this->_where.$this->module.'~'.$this->resource.$this->_cacheSuffix; 
     688    } 
     689     
    660690    public function getCompiledBuilderFilePath ($type){ 
    661         return JELIX_APP_TEMP_PATH.'compiled/'.$this->_dirname.$this->module.'~'.$this->resource.'_builder_'.$type.$this->_cacheSuffix; 
    662     } 
     691        return JELIX_APP_TEMP_PATH.'compiled/'.$this->_dirname.$this->_where.$this->module.'~'.$this->resource.'_builder_'.$type.$this->_cacheSuffix; 
     692    } 
     693     
    663694} 
    664695 
  • trunk/lib/jelix/core/jSelector.class.php

    r598 r601  
    497497        if (is_readable ($overloadedPath)){ 
    498498           $this->_path = $overloadedPath; 
    499            $this->_where = 1
     499           $this->_where = 'overloaded/'
    500500           return; 
    501501        } 
     
    506506            throw new jExceptionSelector('jelix~errors.selector.invalid.target', array($this->toString(), "dao")); 
    507507        } 
    508         $this->_where = 0
     508        $this->_where = 'modules/'
    509509    } 
    510510 
    511511    protected function _createCachePath(){ 
    512         $d = array('modules/','overloaded/'); 
    513512        // on ne partage pas le même cache pour tous les emplacements possibles 
    514513        // au cas où un overload était supprimé 
    515         $this->_cachePath = JELIX_APP_TEMP_PATH.'compiled/daos/'.$d[$this->_where].$this->module.'~'.$this->resource.'~'.$this->driver.$this->_cacheSuffix; 
     514        $this->_cachePath = JELIX_APP_TEMP_PATH.'compiled/daos/'.$this->_where.$this->module.'~'.$this->resource.'~'.$this->driver.$this->_cacheSuffix; 
    516515    } 
    517516 
     
    562561        } 
    563562 
     563        $path = $this->module.'/'.$this->resource; 
     564        $lpath = $this->module.'/'.$gJConfig->locale.'/'.$this->resource; 
     565 
    564566        if($gJConfig->theme != 'default'){ 
    565567            // on regarde si il y a un template redéfinie pour le theme courant 
    566             $this->_where = 'themes/'.$gJConfig->theme.'/'.$this->module.'/'.$gJConfig->locale.'/'.$this->resource
     568            $this->_where = 'themes/'.$gJConfig->theme.'/'.$lpath
    567569            $this->_path = JELIX_APP_VAR_PATH.$this->_where.'.tpl'; 
    568570            if (is_readable ($this->_path)){ 
     
    570572            } 
    571573            // on regarde si il y a un template redéfinie pour le theme courant 
    572             $this->_where = 'themes/'.$gJConfig->theme.'/'.$this->module.'/'.$this->resource
     574            $this->_where = 'themes/'.$gJConfig->theme.'/'.$path
    573575            $this->_path = JELIX_APP_VAR_PATH.$this->_where.'.tpl'; 
    574576            if (is_readable ($this->_path)){ 
     
    578580 
    579581        // on regarde si il y a un template redéfinie dans le theme par defaut 
    580         $this->_where = 'themes/default/'.$this->module.'/'.$gJConfig->locale.'/'.$this->resource
     582        $this->_where = 'themes/default/'.$lpath
    581583        $this->_path = JELIX_APP_VAR_PATH.$this->_where.'.tpl'; 
    582584        if (is_readable ($this->_path)){ 
     
    584586        } 
    585587 
    586         $this->_where = 'themes/default/'.$this->module.'/'.$this->resource
     588        $this->_where = 'themes/default/'.$path
    587589        $this->_path = JELIX_APP_VAR_PATH.$this->_where.'.tpl'; 
    588590        if (is_readable ($this->_path)){ 
     
    593595        $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$gJConfig->locale.'/'.$this->resource.'.tpl'; 
    594596        if (is_readable ($this->_path)){ 
    595             $this->_where = 'modules/'.$this->module.'/'.$gJConfig->locale.'/'.$this->resource
     597            $this->_where = 'modules/'.$lpath
    596598            return; 
    597599        } 
     
    599601        $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$this->resource.'.tpl'; 
    600602        if (is_readable ($this->_path)){ 
    601             $this->_where = 'modules/'.$this->module.'/'.$this->resource
     603            $this->_where = 'modules/'.$path
    602604            return; 
    603605        } 
     
    642644class jSelectorForm extends jSelectorModule { 
    643645    protected $type = 'form'; 
    644  
     646    protected $_where; 
     647    protected $_dirname = 'forms/'; 
     648    protected $_suffix = '.form.xml'; 
     649     
    645650    function __construct($sel){ 
    646651 
    647         $this->_dirname =  'forms/'; 
    648         $this->_suffix = '.form.xml'; 
    649         $this->_cacheSuffix = '.php'; 
    650652        $this->_compiler='jFormsCompiler'; 
    651653        $this->_compilerPath=JELIX_LIB_FORMS_PATH.'jFormsCompiler.class.php'; 
     
    658660    } 
    659661 
     662    
     663    protected function _createPath(){ 
     664        global $gJConfig; 
     665        if(!isset($gJConfig->_modulesPathList[$this->module])){ 
     666            throw new jExceptionSelector('jelix~errors.selector.module.unknow', $this->toString(true)); 
     667        } 
     668         
     669        // we see if the forms have been redefined 
     670        $overloadedPath = JELIX_APP_VAR_PATH.'overloads/'.$this->module.'/'.$this->_dirname.$this->resource.$this->_suffix; 
     671        if (is_readable ($overloadedPath)){ 
     672           $this->_path = $overloadedPath; 
     673           $this->_where = 'overloaded/'; 
     674           return; 
     675        } 
     676 
     677        $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$this->resource.$this->_suffix; 
     678        if (!is_readable ($this->_path)){ 
     679            throw new jExceptionSelector('jelix~errors.selector.invalid.target', array($this->toString(), $this->type)); 
     680        } 
     681        $this->_where = 'modules/'; 
     682    } 
     683     
     684    protected function _createCachePath(){ 
     685        // on ne partage pas le même cache pour tous les emplacements possibles 
     686        // au cas où un overload était supprimé 
     687        $this->_cachePath = JELIX_APP_TEMP_PATH.'compiled/'.$this->_dirname.$this->_where.$this->module.'~'.$this->resource.$this->_cacheSuffix; 
     688    } 
     689     
    660690    public function getCompiledBuilderFilePath ($type){ 
    661         return JELIX_APP_TEMP_PATH.'compiled/'.$this->_dirname.$this->module.'~'.$this->resource.'_builder_'.$type.$this->_cacheSuffix; 
    662     } 
     691        return JELIX_APP_TEMP_PATH.'compiled/'.$this->_dirname.$this->_where.$this->module.'~'.$this->resource.'_builder_'.$type.$this->_cacheSuffix; 
     692    } 
     693     
    663694} 
    664695 
Download in other formats: Unified Diff Zip Archive