/** * @param $name * @param array $params */ public static function parse($template_name, $params = array()) { if (is_array($GLOBALS)) { extract($GLOBALS); } if (is_array($params)) { extract($params); } $session = Mvc::getSession(); $request = Mvc::getRequest(); $response = Mvc::getResponse(); $config = Mvc::getConfig(); $router = Mvc::getRouter(); $dispatcher = Mvc::getDispatcher(); foreach ($params as $varname => $value) { $response->setData($varname, $value); } unset($varname, $value, $params); foreach (array(LP_APP_DIRECTORY, LP_DEFAULT_APP_DIRECTORY, LP_ROOT_DIRECTORY) as $_dir) { $template_path = "{$_dir}/templates/{$template_name}.php"; if (is_file($template_path)) { // Execute the template require $template_path; return; } } throw new \Exception("Template not found: /templates/{$template_name}.php"); }
/** * @param $action * @param null $controller * @param array $params * @return null */ protected function forward($action, $controller = null, $params = array()) { /** @var Dispatcher $dispatcher */ $dispatcher = Mvc::getDispatcher(); // Get controller list($current_controller, ) = $dispatcher->getCurrentToken(); // Create token $token = array($controller === null ? $current_controller : $controller, $action, $params); // Add token $dispatcher->addToken($token); return null; }
function change_locale_url($locale) { $url = LP_BASE_URL; $config = \LandingPages\Mvc::getConfig(); if (in_array('url', explode(',', $config->getData('locale.detect_methods')))) { $locale_map = array_search($locale, get_locale_url_map()); if (!$locale_map) { $locale_map = $locale; } $url .= $locale_map . '/'; } list($controller, $action, $params) = \LandingPages\Mvc::getDispatcher()->getCurrentToken(); if (!LP_IS_HOME && $controller == 'landing' && $action == 'view') { $i18n = new \LandingPages\Mvc\I18n(); $url .= $i18n->translateUrl($params['template'], $locale) . '.html'; } return $url; }