/** * */ 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; }
/** * 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; }
/** * get the controller corresponding to the selector * @param jSelectorAct $selector */ protected function getController($selector) { $ctrlpath = $selector->getPath(); if (isset($_SERVER['HTTP_REFERER'])) { $referer = ' REFERER:' . $_SERVER['HTTP_REFERER']; } else { $referer = ''; } if (!file_exists($ctrlpath)) { throw new jException('jelix~errors.ad.controller.file.unknown', array($this->actionName, $ctrlpath . $referer)); } 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 . $referer)); } $ctrl = new $class($this->request); if ($ctrl instanceof jIRestController) { $selector->method = strtolower($_SERVER['REQUEST_METHOD']); } elseif (!is_callable(array($ctrl, $selector->method))) { throw new jException('jelix~errors.ad.controller.method.unknown', array($this->actionName, $selector->method, $class, $ctrlpath . $referer)); } return $ctrl; }