public function __construct($method, $path, $callback) { $reqMethod = $method; $this->Method = $reqMethod; $this->Path = $path; $this->Callback = $callback; $this->data = Arguments::Request(); $this->Referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $this->IsSecureConnection = isset($_SERVER['HTTPS']) ? (bool) $_SERVER['HTTPS'] : false; $this->RemoteAddr = $_SERVER['REMOTE_ADDR']; $this->RemoteHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; $this->RemotePort = $_SERVER['REMOTE_PORT']; $this->MyAddr = $_SERVER['SERVER_ADDR']; $this->MyPort = $_SERVER['SERVER_PORT']; $this->MyProtocol = $_SERVER['SERVER_PROTOCOL']; if ($this->Method == "ALL") { $this->Method = "GET"; Application::GetInstance()->Requests[$this->Method][] = clone $this; $this->Method = "POST"; Application::GetInstance()->Requests[$this->Method][] = clone $this; $this->Method = "PUT"; Application::GetInstance()->Requests[$this->Method][] = clone $this; $this->Method = "DELETE"; Application::GetInstance()->Requests[$this->Method][] = clone $this; $this->Method = "AJAX"; Application::GetInstance()->Requests[$this->Method][] = clone $this; } else { $this->Method = $reqMethod; Application::GetInstance()->Requests[$this->Method][] = $this; } }
/** * List all available command * @param Arguments arguments */ public function executeIndex(Arguments $arguments) { $group = $arguments->get('group', false); if ($group === '') { $choices = array(); $this->manager->eachCommand(function ($command, array $definition) use(&$choices) { if ($this->manager->isHidden($command)) { return; } $namespace = $definition['namespace']; $choices[$namespace] = $namespace; }); $group = $this->askChoices('Select namespace.', $choices); } $choices = array(); $this->manager->eachCommand(function ($command, array $definition) use(&$choices, $group) { if ($group && strpos($command, $group . ':') !== 0) { return; } if ($this->manager->isHidden($command)) { return; } $choices[$command] = $definition['description'] . ' (' . $command . ')'; }); if ($needHelp = $arguments->get('help', false)) { $command = $this->askChoices('Which command do you need help with?', $choices); } else { $command = $this->askChoices('At your command, sire.', $choices); } if ($needHelp) { $this->manager->showHelp($command); } else { $this->manager->command($command); } $this->say(); if ($arguments->get('help', false)) { $text = 'Continue with the help? [y/n]'; $args = new Arguments(array('help' => true)); } else { $text = 'Do you need anything else? [y/n]'; $args = new Arguments(); } if (in_array($this->ask($text), array('y', ''))) { return $this->executeIndex($args); } }
public function Application() { $this->session = new Session(); if (Arguments::getAction() == 'Login') { $this->dispatch('Login'); } if (!$this->session->isLoggedIn()) { // redirect('/login'); } }
/** * String representation of the FOP cli command. * * @return string * * @throws \InvalidArgumentException */ public function __toString() { if ($this->args->hasArgumentFo()) { $cmd = sprintf('fop %s -fo %s -pdf %s', (string) $this->opts, $this->args['fo'], $this->args['pdf']); } elseif ($this->args->hasXmlInputFiles()) { $xml = $this->args['xml']; $xsl = $this->args['xsl']; $pdf = $this->args['pdf']; $cmd = sprintf('fop %s -xml %s -xls %s -pdf %s', (string) $this->opts, $xml, $xsl, $pdf); } else { throw new \InvalidArgumentException('Please specify a fo file or xml/xsl files.'); } return $cmd; }
public function Arguments() { if (Arguments::$instance == true) { return; } Arguments::$instance = true; if (DEVELOPMENT) { // SITA REIKIA PAKEISTI PAGAL KIEKVIENO KONFIGURACIJA // pvz. http://localhost/penen.eu/public_html/ // TODO: padaryti kad automatiskai atsektu, kur URL`e yra subfolderis $working_uri = '/penen.eu/public_html/'; Arguments::$args = explode('/', str_replace($working_uri, '', $_SERVER['REQUEST_URI'])); } else { Arguments::$args = explode('/', substr($_SERVER['REQUEST_URI'], 1)); } //- keiciam argumentu pirmasias raides i didziasias //- kadangi musu urlas bus penen.eu/action, o veiksmo klase vadinsis Action foreach (Arguments::$args as $k => $i) { Arguments::$args[$k] = ucfirst($i); } }
/** * Break an argument string into an array of strings * * @param string $string Argument String as passed to a helper * * @throws \RuntimeException * @return array the argument list as an array */ public function parseArguments($string) { if ($string instanceof Arguments) { // This code is needed only for backward compatibility $args = $string; } else { $args = new Arguments($string); } return $args->getPositionalArguments(); }
/** * Execute given command * @param string command * @param array arguments */ public function command($command, array $arguments = array()) { if (!isset($this->commands[$command])) { throw new \Exedra\Exception\NotFoundException('Command [' . $command . '] does not exists'); } $definition = $this->commands[$command]; if (!isset($this->wizards[$definition['class']])) { $this->wizards[$definition['class']] = $wizard = new $definition['class']($this, $this->app); } else { $wizard = $this->wizards[$definition['class']]; } $arguments = new Arguments($arguments); try { $arguments->validate($definition['arguments']); } catch (\Exedra\Exception\InvalidArgumentException $e) { $wizard->say($e->getMessage()); return $this->showHelp($command); } @(list($namespace, $command) = explode(':', $command)); if (!$command) { $command = $namespace; } $method = 'execute' . ucfirst($command); return $wizard->{$method}($arguments); }