public function init() { $this->module = _array($this->path, 0); $this->command = _array($this->path, 1); if ($this->module && $this->command) { return true; } return false; }
public function init() { $command = _array($this->path, 0); if ($command == 'signin') { $this->signIn(); } elseif ($command == 'signout') { $this->signOut(); } return true; }
/** * Parse input uri, init Request vars * * @return void */ public static function parse() { self::parseRequestHeaders(); $requestUri = self::server('REQUEST_URI'); self::$uri = self::server('REDIRECT_URL', $requestUri); if ($u = parse_url(self::$uri)) { self::$path = _array($u, 'path', '/'); self::$query = _array($u, 'query'); self::$fragment = _array($u, 'fragment'); } else { throw new \Exception('wrong URI'); } }
function _array(array $arr) { $i = -1; $php = '['; foreach ($arr as $k => $v) { if (++$i) { $php .= ', '; } if (!is_numeric($k)) { $php .= var_export($k, true) . ' => '; } $php .= is_array($v) ? _array($v) : var_export($v, true); } $php .= ']'; return $php; }
/** * Search for use-command like {{ use "inc/button" title="some_title" }} * Replace 'use' macros in template by call of Use function with parameters, parsed from replaced string * * @param string $source * @return string */ private function parseUse($source) { return preg_replace_callback('/{{ use "([\\w\\/\\.\\-\\_]+)" (.*?)}}/', function ($matches) { $useArgs = ''; if ($args = _array($matches, 2)) { if (preg_match_all('/(\\w+)=((\\w[\\w\\.]*)|(".*?"))/', $args, $m)) { $names = $m[1]; $vars = $m[3]; $strings = $m[4]; $useArgs = []; foreach ($names as $i => $name) { $value = ''; if ($strings[$i]) { $value = $strings[$i]; } elseif ($vars[$i]) { $value = '$this->getvar(\'' . $vars[$i] . '\')'; } $useArgs[] = '"' . $name . '"=>' . $value; } $useArgs = ",[" . implode(',', $useArgs) . "]"; } } return '<?=$this->useTemplate(\'' . $matches[1] . '\'' . $useArgs . ')?>'; }, $source); }
public function init() { $this->command = _array($this->path, 0); return true; }
/** * Get the values of an array * * @param array $array The array to work on * @return array The values of the original array */ function _values($array) { return array_values(_array($array)); }
function _call() { return $_REQUEST[_array()]; }