/** * @param String $url * @param array $param * @param Boolean $autodispatch */ public function __construct($url, $param = null) { $toreplace = array("{base_url}" => Path::getInstance()->getBaseUrl()); if ($param != null && is_array($param)) { $toreplace = array_merge($toreplace, $param); } foreach ($toreplace as $k => $v) { $url = str_replace($k, $v, $url); } // $this->url = $url; $this->param = $param != null ? $param : array(); }
protected function set() { //Set path $this->path = Path::getInstance(); $this->path->set(); //Set Config if (!file_exists($this->path->file->config)) { throw new ErrorException("Config file is missing!"); } $config = file_get_contents($this->path->file->config); $config = json_decode($config); $this->config = $config; if (count($config->lang->list) == 0) { $this->lang = ""; } else { //print_r($this->path->getCurrentUrl()." / ".$this->path->getBaseUrl());exit; if ($this->path->getCurrentUrl() != $this->path->getBaseUrl()) { if ($this->path->getBaseUrl() != "/") { $this->lang = str_replace($this->path->getBaseUrl(), "", $this->path->getCurrentUrl()); $this->lang = explode("/", $this->lang); $this->lang = $this->lang[0]; } else { $this->lang = explode("/", $this->path->getCurrentUrl()); $this->lang = $this->lang[1]; } } else { $user_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); $this->lang = $user_lang; } //print_r($this->lang);exit; if (strstr($this->lang, "?")) { $this->lang = explode("?", $this->lang); $this->lang = $this->lang[0]; } //print_r(var_dump($this->lang));exit; if (!in_array($this->lang, $config->lang->list)) { $this->lang = $config->lang->default; header('Location: ' . $this->path->getBaseUrl() . $config->lang->default); } } if ($this->lang != "") { $this->lang .= "/"; } $path_local = $this->path->file->php . "local" . DS . $this->lang . "local.php"; }
public static function search($what) { $url = Path::getInstance()->getApiUrl() . "search/" . $what; $caller = new Caller($url); return $caller->dispatch()->response; }
<?php $assetUrl = Path::getInstance()->getAssetUrl(); ?> <link rel="apple-touch-icon" sizes="57x57" href="<?php echo $assetUrl; ?> img/favicon/apple-touch-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="<?php echo $assetUrl; ?> img/favicon/apple-touch-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="<?php echo $assetUrl; ?> img/favicon/apple-touch-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="<?php echo $assetUrl; ?> img/favicon/apple-touch-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="<?php echo $assetUrl; ?> img/favicon/apple-touch-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="<?php echo $assetUrl; ?> img/favicon/apple-touch-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="<?php echo $assetUrl; ?>
protected function setCurrentPage() { $this->view = new \stdClass(); $this->view->param = array(); $this->view->local = null; $find = false; $server_uri = $_SERVER["REQUEST_URI"]; $server_uri = str_replace($this->main->lang, "", $server_uri . "/"); $server_uri = str_replace("//", "/", $server_uri); if ($this->main->path->getBaseUrl() != "/") { $tocheck = str_replace($this->main->path->getBaseUrl(), "", $server_uri); } else { $tocheck = $server_uri; $tocheck = explode("/", $tocheck); $check = ""; foreach ($tocheck as $k => $v) { if ($k > 0 && $v != "") { $check .= $v . "/"; } } $tocheck = $check; $tocheck = $tocheck === "/" ? "" : $tocheck; } if (strstr($tocheck, "?")) { $tocheck = explode("?", $tocheck); $tocheck = $tocheck[0] . "/"; } //print_r($tocheck);exit; foreach ($this->routes as $k => $route) { if ($tocheck == "" && $route->url_sem == "" || $tocheck == $this->main->lang && $route->url_sem == "") { $find = $route; $this->view->name = $k; break; } if ($route->url_sem == "") { continue; } $tabToCheck = explode("/", $tocheck); $tabRoute = explode("/", $route->url_sem); //if (count($tabToCheck) != count($tabRoute)) continue; if ($tabToCheck[0] == $tabRoute[0] && $tabToCheck[1] == $tabRoute[1] || $tabToCheck[0] == $tabRoute[0] && strstr($tabRoute[1], "{")) { $find = $route; $this->view->name = $k; foreach ($tabRoute as $p => $param) { if ($param != "" && $p > 0) { $param = str_replace("{", "", $param); $param = str_replace("}", "", $param); $this->view->param[$param] = isset($tabToCheck[$p]) ? $tabToCheck[$p] : ""; } } break; } } $path = \Path::getInstance(); $this->view->controller = null; if (!$find) { header("Status: 404 NOT FOUND", false, 404); $this->view->path = $path->getPagePath() . "page404.php"; $this->view->name = "page404"; include_once $path->file->local . $this->main->lang . DS . $this->view->name . ".php"; $classname = ucfirst($this->view->name); $this->view->local = new $classname(); return; } header("Status: 200 OK", false, 200); //Include local include_once $path->file->local . $this->main->lang . DS . $this->view->name . ".php"; $classname = ucfirst($this->view->name); $this->view->local = new $classname(); $this->view->path = $path->getPagePath() . $find->tpl; if (!file_exists($this->view->path)) { throw new \ErrorException("View doesn't exist : " . $find->tpl); } $this->view->tpl = file_get_contents($this->view->path); }