/** * @covers common\classes\Request::uri */ public function test_uri() { self::assertEquals('', Request::uri()); $_SERVER['REQUEST_URI'] = '/test.com?asd=dsa'; self::assertEquals('/test.com', Request::uri()); $_SERVER['REQUEST_URI'] = '/test.com/'; self::assertEquals('/test.com', Request::uri()); }
public function navigate(PageModel $page, $params) { if (strpos(Request::uri(), 'admin_panel') !== false) { (new AdminPanelActionRouter())->navigate($page, $params); } else { (new SiteActionRouter())->navigate($page, $params); } }
private function get_route() { $request_uri = Request::uri(); if (isset($this->routes[$request_uri])) { return $this->routes[$request_uri]; } else { $keys = array_keys($this->routes); foreach ($keys as $key) { if (strpos($key, ':') !== false) { $parts = explode('/', $key); $parts_keys = array_keys($parts); foreach ($parts_keys as $part_key) { $part = $parts[$part_key]; $pos = strpos($part, ':'); if ($pos !== false) { $sub_str = substr($part, $pos + 1); switch ($sub_str) { case 'number': $parts[$part_key] = str_replace([$sub_str, ':'], ['(\\d+)', ''], $part); break; case 'string': default: $parts[$part_key] = str_replace([$sub_str, ':'], ['(\\w+)', ''], $part); break; } } } $parts = implode('\\/', $parts); preg_match_all("/^{$parts}\$/iU", $request_uri, $result, PREG_SET_ORDER); if (!empty($result[0]) && count($result)) { $this->route_params = array_slice($result[0], 1); return $this->routes[$key]; } } } foreach ($keys as $key) { if (strpos($key, '*') !== false) { return $this->routes[$key]; } } return null; } }
protected function show_result(GetResponse $response) { /** * @var $template Template */ $template = Application::get_class(\Starter::class); $smarty = new \Smarty(); $bundle_file = ROOT_PATH . DS . 'static_builder' . DS . 'bundle.result.json'; $bundle_result = json_decode(file_get_contents($bundle_file), true); $smarty->assign('bundle_result', $bundle_result); if (strpos(Request::uri(), 'admin_panel') !== false) { $smarty->setTemplateDir($template->get_path() . DS . 'templates' . DS . 'admin_panel'); } else { $smarty->setTemplateDir($template->get_path() . DS . 'templates' . DS . 'site'); } $smarty->setCompileDir($template->get_path() . DS . 'templates_c'); $smarty->assign($response->blocks); $smarty->assign('title', new PageTitle()); echo $smarty->getTemplate('index' . DS . 'index.tpl.html'); }
public function render() { $this->assign('uri', Request::uri()); return $this->get_template($this->template_name); }
private function load_data() { $file = ROOT_PATH . DS . 'resource' . DS . CURRENT_LANG . '_titles.json'; $area = strpos(Request::uri(), 'admin_panel') === false ? 'site' : 'admin_panel'; $this->titles = json_decode(file_get_contents($file), true)[$area]; }
public function get_data() { return ['url' => Request::uri()]; }