public function get($name, $value = array()) { $name = (string) $name; if (isset($this->_routes[$name])) { $configs = Gio_Core_Config_Xml::getConfig('web'); $request = Gio_Core_Request::getInstance(); $configs->url = $request->getBaseUrl(); $localization = Gio_Core_Config_Xml::getConfig('localization'); $rewrite = $configs->rewrite == 'true' ? '' : '_no_rewrite'; $csrfString = null; $url = null; if (isset($this->_routes[$name]['csrf']) && (string) ($this->_routes[$name]['csrf']['enable'] = 'true' && strtolower($this->_routes[$name]['csrf']['retrive']) == 'get')) { $csrf = new Gio_Core_Csrf($name); $csrfString = $csrf->getTokenName() . '=' . $csrf->getToken(); } switch ($this->_routes[$name]['type']) { case 'static': $url = ltrim($this->_routes[$name]['url' . $rewrite], '/'); break; case 'regex': $maps = (array) $this->_routes[$name]['params']; if (null == $maps) { return; } else { $data = array(); foreach ($maps as $k => $v) { $temp = isset($value[$v]) ? $value[$v] : null; $data[] = str_replace(' ', '+', $temp); } $url = vsprintf($this->_routes[$name]['reverse' . $rewrite], $data); $url = ltrim($url, '/'); } break; } $router = $this->_routes[$name]; if (isset($router['localization']['enable']) && 'true' == $router['localization']['enable'] && 'true' == (string) $localization->enable) { $lang = isset($value['language']) ? $value['language'] : Gio_Core_Request::getInstance()->getParam('lang'); if ($lang != $localization->languages->default) { $configs->url = rtrim($configs->url, '/') . '/' . $lang; } } $url = rtrim($configs->url, '/') . '/' . $url; if ($csrfString && strpos($url, '?') !== false) { $csrfString = '&' . $csrfString; } elseif ($csrfString) { $csrfString = '?' . $csrfString; } $url = $url . $csrfString; $url = str_replace('###admin_url_prefix###', $configs->admin->url_prefix, $url); return rtrim($url, '/'); } }
public function run() { /** * Run Permalink Plugin */ $permalink = new Modules_Core_Controllers_Plugins_Permalink(); call_user_func(array($permalink, 'run')); /** * Run LocalizationRoute Plugin */ $localizationRoute = new Gio_Core_Plugins_LocalizationRoute(); call_user_func(array($localizationRoute, 'run')); /** * Run Install Checker */ $currentRoute = Gio_Core_Route::getCurrentRoute(); self::$_route = $currentRoute; $controllerFront = Gio_Core_Controller::getIntance(); if ($currentRoute && $currentRoute['name'] != 'core_install_step1' && self::_initInstallChecker() === false) { $controllerFront->redirect($this->_view->url('core_install_step1')); return; } if (isset($currentRoute['module']) && isset($currentRoute['controller']) && isset($currentRoute['action'])) { if (self::_initInstallChecker() == true) { $csrf = new Gio_Core_Csrf($currentRoute['name']); if (!$csrf->authentication()) { return; } $csrf->appendElement(); } $controllerFront->setModuleName($currentRoute['module'])->setControllerName($currentRoute['controller'])->setActionName($currentRoute['action']); /** * Run Plugins First */ if (self::_initInstallChecker() == true) { $this->_runPlugin(); } $this->_view->CURRENT_ROUTE = $currentRoute['name']; $content = $controllerFront->dispatch(); $this->_view->setLayoutContent($content); if (!Gio_Core_Controller::getIntance()->getDisableLayout()) { $layout = isset($this->_view->APP_LAYOUT) && $this->_view->APP_LAYOUT ? $this->_view->APP_LAYOUT : $controllerFront->getLayout(); $layoutFile = TEMPLATE_DIR . DS . $this->_view->APP_TEMPLATE . DS . 'layouts' . DS . $layout . '.phtml'; $this->_view->fetch($layoutFile); } else { $this->_view->content($content); } } }