/** * @load the controller */ public function loader($route) { $this->route = $route; /*** check the route ***/ $this->getController($route); /*** a new controller class instance ***/ $class = $this->controller; $controller = new $class(); /*** check if the action is callable ***/ if (!is_callable(array($controller, $this->action))) { $action = self::INDEX; } else { $action = $this->action; } if ($this->checkAccessRules($controller->accessRules(), $action)) { /*** run the action ***/ $controller->{$action}($this->args); } else { $sr = SessionRegistry::getInstance(); $sr->route = $route; $this->redirect(URL_PATH . '/auth/'); } }
public function loadLocale($locale = null) { $reg = \penguin\mvc\SessionRegistry::getInstance(); $reg->locale = 'en-US'; if (!$locale && $this->defaultLocale == 'auto' && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $languages = explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']); foreach ($languages as $lang) { list($locale) = explode(',', $lang); if (file_exists(self::I18N . $locale . '.ini')) { $reg->locale = $locale; break; } } } else { if (file_exists(self::I18N . $locale . '.ini')) { $reg->locale = $locale; } } if ($reg->locale != 'en-US') { $reg->translation = parse_ini_file(self::I18N . $locale . '.ini'); } else { $reg->translation = array(); } }