Source for file jSelectorClass.class.php

Documentation is available at jSelectorClass.class.php

  1. <?php
  2. /**
  3. * see jISelector.iface.php for documentation about selectors.
  4. @package     jelix
  5. @subpackage  core_selector
  6. @author      Laurent Jouanneau
  7. @copyright   2005-2012 Laurent Jouanneau
  8. @link        http://www.jelix.org
  9. @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
  10. */
  11.  
  12. /**
  13.  * selector for business class
  14.  *
  15.  * business class is a class stored in classname.class.php file in the classes/ module directory
  16.  * or one of its subdirectory.
  17.  * syntax : "module~classname" or "module~classname.
  18.  * @package    jelix
  19.  * @subpackage core_selector
  20.  */
  21. class jSelectorClass extends jSelectorModule {
  22.     protected $type = 'class';
  23.     protected $_dirname = 'classes/';
  24.     protected $_suffix = '.class.php';
  25.  
  26.     /**
  27.     * subpath part in the resource content
  28.     * @since 1.0b2
  29.     */
  30.     public $subpath ='';
  31.     /**
  32.     * the class name specified in the selector
  33.     * @since 1.0b2
  34.     */
  35.     public $className = '';
  36.  
  37.     function __construct($sel){
  38.         if(jelix_scan_class_sel($sel$this)){
  39.             if($this->module ==''){
  40.                 $this->module = jApp::getCurrentModule ();
  41.             }
  42.             $this->_createPath();
  43.             $this->_createCachePath();
  44.         }else{
  45.             throw new jExceptionSelector('jelix~errors.selector.invalid.syntax'array($sel,$this->type));
  46.         }
  47.     }
  48.  
  49.     protected function _createPath(){
  50.         if (!isset(jApp::config()->_modulesPathList[$this->module])) {
  51.             throw new jExceptionSelector('jelix~errors.selector.module.unknown'$this->toString());
  52.         }
  53.         $this->_path = jApp::config()->_modulesPathList[$this->module].$this->_dirname.$this->subpath.$this->className.$this->_suffix;
  54.  
  55.         if (!file_exists($this->_path|| strpos($this->subpath,'..'!== false // second test for security issues
  56.             throw new jExceptionSelector('jelix~errors.selector.invalid.target'array($this->toString()$this->type));
  57.         }
  58.     }
  59.  
  60.     protected function _createCachePath(){
  61.         $this->_cachePath = '';
  62.     }
  63.  
  64.     public function toString($full=false){
  65.         if($full)
  66.             return $this->type.':'.$this->module.'~'.$this->subpath.$this->className;
  67.         else
  68.             return $this->module.'~'.$this->subpath.$this->className;
  69.     }
  70. }

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