Esempio n. 1
0
 /**
  *
  */
 public function index()
 {
     global $gJConfig;
     $rep = $this->getResponse();
     $cmd_name = $this->param('cmd_name');
     if (empty($cmd_name)) {
         $rep->addContent("\nGeneral purpose:\n    php cmdline.php help [COMMAND]\n\n    COMMAND : name of the command to launch\n               'module~controller:action' or more simply\n               'controller:action' or 'action', depending of the app configuration\n");
     } else {
         if (!preg_match('/(?:([\\w\\.]+)~)/', $cmd_name)) {
             $cmd_name = $gJConfig->startModule . '~' . $cmd_name;
         }
         $selector = new jSelectorAct($cmd_name);
         include $selector->getPath();
         $ctrl = $selector->getClass();
         $ctrl = new $ctrl(null);
         $help = $ctrl->help;
         $rep->addContent("\nUse of the command " . $selector->method . " :\n");
         if (isset($help[$selector->method]) && $help[$selector->method] != '') {
             $rep->addContent($help[$selector->method] . "\n\n");
         } else {
             $rep->addContent("\tNo availabled help for this command\n\n");
         }
     }
     return $rep;
 }
Esempio n. 2
0
 /**
  * says if the currently executed action is the original one
  * @return boolean  true if yes
  */
 public function execOriginalAction()
 {
     if (!$this->originalAction) {
         return false;
     }
     return $this->originalAction->isEqualTo($this->action);
 }
Esempio n. 3
0
 /**
  * get the controller corresponding to the selector
  * @param jSelectorAct $selector
  */
 protected function getController($selector)
 {
     jLog::log("getController for " . $selector->toString());
     $ctrl = parent::getController($selector);
     jLog::log("getController: " . get_class($ctrl));
     return $ctrl;
 }
Esempio n. 4
0
 /**
  * get the controller corresponding to the selector
  * @param jSelectorAct $selector
  */
 private function getController($selector)
 {
     $ctrlpath = $selector->getPath();
     if (!file_exists($ctrlpath)) {
         throw new jException('jelix~errors.ad.controller.file.unknown', array($this->actionName, $ctrlpath));
     }
     require_once $ctrlpath;
     $class = $selector->getClass();
     if (!class_exists($class, false)) {
         throw new jException('jelix~errors.ad.controller.class.unknown', array($this->actionName, $class, $ctrlpath));
     }
     $ctrl = new $class($this->request);
     if ($ctrl instanceof jIRestController) {
         $method = $selector->method = strtolower($_SERVER['REQUEST_METHOD']);
     } elseif (!method_exists($ctrl, $selector->method)) {
         throw new jException('jelix~errors.ad.controller.method.unknown', array($this->actionName, $selector->method, $class, $ctrlpath));
     }
     return $ctrl;
 }