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.      * @param boolean $toRetrieveUrl  true if the goal to have this selector is to generate an url
  31.      */
  32.     function __construct($sel$enableRequestPart false$toRetrieveUrl false){
  33.         $coord jApp::coord();
  34.         $this->forUrl = $toRetrieveUrl;
  35.  
  36.         // jSelectorAct is called by the significant url engine parser, before
  37.         // jcoordinator set its properties, so we set a value to avoid a
  38.         // parameter error on jelix_scan_action_sel. the value doesn't matter
  39.         // since the significant parser call jSelectorAct only for 404 page
  40.         if ($coord->actionName === null)
  41.             $coord->actionName 'default:index';
  42.  
  43.         if (jelix_scan_action_sel($sel$this$coord->actionName)) {
  44.  
  45.             if ($this->module == '#'{
  46.                 $this->module = $coord->moduleName;
  47.             }
  48.             elseif ($this->module ==''{
  49.                 $this->module = jApp::getCurrentModule ();
  50.             }
  51.  
  52.             if ($this->request == '' || !$enableRequestPart)
  53.                 $this->request = $coord->request->type;
  54.  
  55.             $this->_createPath();
  56.         }else{
  57.             throw new jExceptionSelector('jelix~errors.selector.invalid.syntax'array($sel,$this->type));
  58.         }
  59.     }
  60.  
  61.     protected function _createPath(){
  62.         $conf jApp::config();
  63.         if (isset($conf->_modulesPathList[$this->module])) {
  64.             $p $conf->_modulesPathList[$this->module];
  65.         else if ($this->forUrl && isset($conf->_externalModulesPathList[$this->module])) {
  66.             $p $conf->_externalModulesPathList[$this->module];
  67.         }
  68.         else
  69.             throw new jExceptionSelector('jelix~errors.selector.module.unknown'$this->toString());
  70.  
  71.         $this->_path = $p.'controllers/'.$this->controller.'.'.$this->request.'.php';
  72.     }
  73. }

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