/** * Runs every function in {MODULE}\BootStrap.php function which end with 'Init' or starts with 'pre_' in function's name * @param Request $request */ protected function RunBootstarp(request &$request) { # both possible naming for bootstrap $bsfiles_path = array(); # we really don't want to confuse our selves # $bsfiles_path[] = array($request->module->full_name, $request->module->GetPath()."/{$request->module->full_name}Bootstrap.php"); $bsfiles_path[] = array($request->module->name, $request->module->GetPath() . "/{$request->module->name}Bootstrap.php"); foreach ($bsfiles_path as $bs) { $bs[1] = \zinux\kernel\utilities\fileSystem::resolve_path($bs[1]); if (file_exists($bs[1])) { require_once $bs[1]; $cname = "{$request->module->GetNameSpace()}\\{$bs[0]}Bootstrap"; if (class_exists($cname)) { $c = new $cname(); $m = get_class_methods($c); foreach ($m as $method) { if (\zinux\kernel\utilities\string::endsWith(strtoupper($method), "INIT") || \zinux\kernel\utilities\string::startsWith(strtoupper($method), "PRE_")) { if (!is_callable(array($c, $method))) { trigger_error("The method {$method} found in bootstrap file `{$bs[1]}` but is not callable"); } else { $c->{$method}($request); } } } } } } }
public function RunPoststrap(&$request) { foreach (self::$_boostraps as $c) { $m = get_class_methods($c); foreach ($m as $method) { if (\zinux\kernel\utilities\string::startsWith(strtoupper($method), "POST_")) { if (!is_callable(array($c, $method))) { trigger_error("The method {$method} found in bootstrap instance `{$c}` but is not callable"); } else { $c->{$method}($request); } } } } }
/** * Depart and normalize the requested URI */ protected function TokenizeURI() { $this->_parts = array_filter(\explode('?', $this->requested_uri)); if (count($this->_parts) === 0) { $this->_parts = array(); return; } $this->_parts = \explode('/', $this->_parts[0]); /* * Normalizing the $this->_parts arrays */ \zinux\kernel\utilities\_array::array_normalize($this->_parts); # fetch page type if (count($this->_parts) && \zinux\kernel\utilities\string::Contains($this->_parts[count($this->_parts) - 1], ".")) { $dpos = strpos($this->_parts[count($this->_parts) - 1], "."); $this->type = substr($this->_parts[count($this->_parts) - 1], $dpos + 1); $this->_parts[count($this->_parts) - 1] = substr($this->_parts[count($this->_parts) - 1], 0, $dpos); } }
/** * Prepares the params for sending requests */ protected function __normalize_params() { if (!\zinux\kernel\utilities\string::Contains($this->uri, "?")) { $this->uri .= "?"; } $get_str = http_build_query($this->GET); if (strlen($get_str)) { $this->uri .= "&{$get_str}"; } if (count($this->COOKIE)) { $this->COOKIE = str_replace("&", "; ", http_build_query($this->COOKIE)); } else { $this->COOKIE = ""; } if (count($this->POST)) { $this->POST = http_build_query($this->POST); } else { $this->POST = ""; } }