Source for file jSelectorAct.class.php

Documentation is available at jSelectorAct.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. @contributor Thibault Piront (nuKs)
  8. @copyright   2005-2012 Laurent Jouanneau
  9. @copyright   2007 Thibault Piront
  10. @link        http://www.jelix.org
  11. @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
  12. */
  13.  
  14. /**
  15.  * Generic Action selector
  16.  *
  17.  * main syntax: "module~action@requestType". module should be a valid module name or # (#=says to get
  18.  * the module of the current request). action should be an action name (controller:method or controller_method).
  19.  * all part are optional, but it should have one part at least.
  20.  * @package    jelix
  21.  * @subpackage core_selector
  22.  */
  23. class jSelectorAct extends jSelectorActFast {
  24.  
  25.     protected $forUrl = false;
  26.  
  27.     /**
  28.      * @param string $sel  the selector
  29.      * @param boolean $enableRequestPart true if the selector can contain the request part
  30.      */
  31.     function __construct($sel$enableRequestPart false$toRetrieveUrl false){
  32.         $coord jApp::coord();
  33.         $this->forUrl = $toRetrieveUrl;
  34.         if(preg_match("/^(?:([a-zA-Z0-9_\.]+|\#)~)?([a-zA-Z0-9_:]+|\#)?(?:@([a-zA-Z0-9_]+))?$/"$sel$m)){
  35.             $m=array_pad($m,4,'');
  36.             if($m[1]!=''){
  37.                 if($m[1== '#')
  38.                     $this->module = $coord->moduleName;
  39.                 else
  40.                     $this->module = $m[1];
  41.             }else{
  42.                 $this->module = jContext::get ();
  43.             }
  44.             if($m[2== '#')
  45.                 $this->resource = $coord->actionName;
  46.             else
  47.                 $this->resource = $m[2];
  48.             $r explode(':',$this->resource);
  49.             if(count($r== 1){
  50.                 $this->controller = 'default';
  51.                 $this->method = $r[0]==''?'index':$r[0];
  52.             }else{
  53.                 $this->controller = $r[0]=='' 'default':$r[0];
  54.                 $this->method = $r[1]==''?'index':$r[1];
  55.             }
  56.             $this->resource = $this->controller.':'.$this->method;
  57.  
  58.             if($m[3!= '' && $enableRequestPart)
  59.                 $this->request = $m[3];
  60.             else
  61.                 $this->request = $coord->request->type;
  62.             $this->_createPath();
  63.         }else{
  64.             throw new jExceptionSelector('jelix~errors.selector.invalid.syntax'array($sel,$this->type));
  65.         }
  66.     }
  67.  
  68.     protected function _createPath(){
  69.         $conf jApp::config();
  70.         if (isset($conf->_modulesPathList[$this->module])) {
  71.             $p $conf->_modulesPathList[$this->module];
  72.         else if ($this->forUrl && isset($conf->_externalModulesPathList[$this->module])) {
  73.             $p $conf->_externalModulesPathList[$this->module];
  74.         }
  75.         else
  76.             throw new jExceptionSelector('jelix~errors.selector.module.unknown'$this->toString());
  77.  
  78.         $this->_path = $p.'controllers/'.$this->controller.'.'.$this->request.'.php';
  79.     }
  80. }

Documentation generated on Mon, 26 Oct 2015 21:56:03 +0100 by phpDocumentor 1.4.3