Source for file jSelectorModule.class.php

Documentation is available at jSelectorModule.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-2012 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.  * base class for all selector concerning module files
  15.  *
  16.  * General syntax for them : "module~resource".
  17.  * Syntax of resource depend on the selector type.
  18.  * module is optional.
  19.  * @package    jelix
  20.  * @subpackage core_selector
  21.  */
  22. abstract class jSelectorModule implements jISelector {
  23.     public $module = null;
  24.     public $resource = null;
  25.  
  26.     protected $type = '_module';
  27.     protected $_dirname='';
  28.     protected $_suffix='';
  29.     protected $_cacheSuffix='.php';
  30.     protected $_path;
  31.     protected $_cachePath;
  32.     protected $_compiler = null;
  33.     protected $_compilerPath;
  34.     protected $_useMultiSourceCompiler=false;
  35.  
  36.     function __construct ($sel{
  37.         if(jelix_scan_module_sel($sel$this)){
  38.             if($this->module ==''){
  39.                 $this->module = jApp::getCurrentModule ();
  40.             }
  41.             $this->_createPath();
  42.             $this->_createCachePath();
  43.         }else{
  44.             throw new jExceptionSelector('jelix~errors.selector.invalid.syntax'array($sel,$this->type));
  45.         }
  46.     }
  47.  
  48.     public function getPath (){
  49.         return $this->_path;
  50.     }
  51.  
  52.     public function getCompiledFilePath (){
  53.         return $this->_cachePath;
  54.     }
  55.  
  56.     public function getCompiler(){
  57.         if($this->_compiler == nullreturn null;
  58.         $n $this->_compiler;
  59.         require_once($this->_compilerPath);
  60.         $o new $n();
  61.         return $o;
  62.     }
  63.  
  64.     public function useMultiSourceCompiler(){
  65.         return $this->_useMultiSourceCompiler;
  66.     }
  67.  
  68.     public function toString($full=false){
  69.         if($full)
  70.             return $this->type.':'.$this->module.'~'.$this->resource;
  71.         else
  72.             return $this->module.'~'.$this->resource;
  73.     }
  74.  
  75.     protected function _createPath(){
  76.  
  77.         if(!isset(jApp::config()->_modulesPathList[$this->module])){
  78.             throw new jExceptionSelector('jelix~errors.selector.module.unknown'$this->toString(true));
  79.         }
  80.         $this->_path = jApp::config()->_modulesPathList[$this->module].$this->_dirname.$this->resource.$this->_suffix;
  81.         if (!is_readable ($this->_path)){
  82.             if($this->type == 'loc'){
  83.                 throw new Exception('(202) The file of the locale key "'.$this->toString().'" (charset '.$this->charset.', lang '.$this->locale.') does not exist');
  84.             }elseif($this->toString(== 'jelix~errors.selector.invalid.target'){
  85.                 throw new Exception("Jelix Panic ! don't find localization files to show you an other error message !");
  86.             }else{
  87.                 throw new jExceptionSelector('jelix~errors.selector.invalid.target'array($this->toString()$this->type));
  88.             }
  89.         }
  90.     }
  91.  
  92.     protected function _createCachePath(){
  93.         $this->_cachePath = jApp::tempPath('compiled/'.$this->_dirname.$this->module.'~'.$this->resource.$this->_cacheSuffix);
  94.     }
  95. }

Documentation generated on Wed, 04 Jan 2017 22:56:44 +0100 by phpDocumentor 1.4.3