public function raw() { Manager::currentRoute() && Manager::getLang('suffix') ? str_replace('_' . Manager::getLang('suffix'), '', Manager::currentRoute()) : null; }
/** * */ protected function _buildRoutes($block, $routes, array $filters = array()) { $controller_id = $this->_controllerID; foreach ($routes as $route) { if (!$route->map) { trigger_error('Please add a map tag to route ' . $route->attributes()->url . '!', E_USER_ERROR); return false; } if (array_key_exists('before', $filters)) { $route->before = ($b = (string) $route->attributes()->before) ? $filters['before'] . '|' . $b : $filters['before']; } else { if ($b = (string) $route->attributes()->before) { $route->before = $b; } } if (array_key_exists('after', $filters)) { $route->after = ($a = (string) $route->attributes()->after) ? $filters['after'] . '|' . $a : $filters['after']; } else { if ($a = (string) $route->attributes()->after) { $route->after = $a; } } $map = (string) $route->map[0]; $callback = function () use($route, $controller_id, $map) { \helpers\Website\Manager::currentController($controller_id); \helpers\Website\Manager::currentRoute($map); \helpers\Website\Manager::setLang($controller_id); $metatags = $route->metatags ? (array) $route->metatags[0] : array(); \helpers\Website\Manager::setMetaTags((string) $route->page[0], $metatags); return \helpers\Website\Manager::page((string) $route->page[0]); }; $url = $route->attributes()->url; if ($this->_prefix) { $url = '/' === substr($url, 0, 1) ? substr($url, 1) : $url; $this->_prefix = '/' !== substr($this->_prefix, -1) ? $this->_prefix . '/' : $this->_prefix; $url = $this->_prefix . $url; } $params = array($url, $callback); $requests = ($r = (string) $route->attributes()->request) ? explode('|', $r) : array('get'); $a = 0; foreach ($requests as $request) { $router = call_user_func_array('\\Router::' . $request, $params); foreach (Manager::getUrlPatterns() as $k => $v) { if (preg_match('<{' . $k . '}|{' . $k . '\\?}>', $url)) { $router->where($k, $v); } } $router->map((string) $route->map[0]); $router->set('controller', $controller_id); if ($route->protocol || $this->_protocol) { $prot = ($p = (string) $route->protocol) ? $p : $this->_protocol; $router->protocol($prot); } if ($route->domain || $this->_domain) { $dom = ($d = (string) $route->domain) ? $d : $this->_domain; $router->domain($dom); } if ($route->before) { $router->before((string) $route->before); } if ($route->after) { $router->after((string) $route->after); } ++$a; } } return true; }