Source for file jCmdLineRequest.class.php

Documentation is available at jCmdLineRequest.class.php

  1. <?php
  2. /**
  3. @package     jelix
  4. @subpackage  core_request
  5. @author      Laurent Jouanneau
  6. @contributor Loic Mathaud
  7. @contributor Thibault PIRONT < nuKs >
  8. @copyright   2005-2006 Laurent Jouanneau, 2006-2007 Loic Mathaud
  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.  * a request object for scripts used in a command line
  16.  * @package     jelix
  17.  * @subpackage  core_request
  18.  */
  19. class jCmdLineRequest extends jRequest {
  20.  
  21.     public $type = 'cmdline';
  22.  
  23.     public $defaultResponseType = 'text';
  24.  
  25.     protected function _initUrlDatas()
  26.         global $gJConfig
  27.         $this->url_script_path = $this->urlScriptPath = '/'
  28.         $this->url_script_name = $this->urlScriptName = $this->urlScript = $_SERVER['SCRIPT_NAME']
  29.         $this->url_path_info = $this->urlPathInfo = ''
  30.     }
  31.  
  32.     protected function _initParams(){
  33.         global $gJConfig;
  34.  
  35.         $argv $_SERVER['argv'];
  36.         $scriptName array_shift($argv)// shift the script name
  37.  
  38.         // note: we cannot use jSelectorAct to parse the action
  39.         // because in the opt edition, jSelectorAct needs an initialized jCoordinator
  40.         // and this is not the case here. see bug #725.
  41.  
  42.         if ($_SERVER['argc'== 1{
  43.             $mod $gJConfig->startModule;
  44.             $act $gJConfig->startAction;
  45.         else {
  46.             $argsel array_shift($argv)// get the module~action selector
  47.             if ($argsel == 'help'{
  48.                 $mod 'jelix';
  49.                 $act 'help:index';
  50.             }else if (($pos strpos($argsel,'~')) !== false{
  51.                 $mod substr($argsel,0,$pos);
  52.                 $act substr($argsel,$pos+1);
  53.             }else {
  54.                 $mod$gJConfig->startModule;
  55.                 $act$argsel;
  56.             }
  57.         }
  58.         
  59.         $this->params = $argv;
  60.         $this->params['module'$mod;
  61.         $this->params['action'$act;
  62.     }
  63. }
  64. ?>

Documentation generated on Wed, 07 Sep 2011 13:46:44 +0200 by phpDocumentor 1.4.3