/**
  * Before render an action ...
  * 1. Check that the controller exists
  * 2. Check that the action exists and is callable (_process() method)
  * 3. Check the authentication
  * 4. Set Locales
  *
  * @return int
  */
 private function _beforeRender()
 {
     $config = Config::getInstance();
     $pluginPath = (string) $config->getParam("pluginPath");
     $this->_pluginFile = $pluginPath . "/" . $this->_name . "/plugin.php";
     if (!$this->_process()) {
         return 0;
     }
     if ($this->_authentication) {
         if (!Session::issetData("status", "login") || Session::get("status", "login") === false) {
             return -1;
         } else {
             if (!in_array(Session::get("role", "login"), $this->_authentication)) {
                 return -1;
             }
         }
     }
     $this->_setLocales();
     return 1;
 }
Example #2
0
 /**
  * Sets a locale to the framework
  *
  * @param $locale string Language code
  * @return void
  */
 public static function setLocale($locale = null)
 {
     if (!self::$_init) {
         self::init();
     }
     switch ($locale) {
         case "es":
             $locale = 'es_ES';
             break;
         case "ca":
             $locale = 'ca_ES';
             break;
         case "en":
             $locale = 'en_GB';
             break;
         case "de":
             $locale = "de_DE";
             break;
         case "fr":
             $locale = "fr_FR";
             break;
         default:
             if (Session::issetData("currentLocale", "locale")) {
                 $locale = Session::get("currentLocale", "locale");
             } else {
                 $locale = self::$_config->getParam("defaultLocale");
             }
             break;
     }
     Session::set("currentLocale", $locale, "locale");
     $localeHack = self::$_config->getParam("localeHack");
     if ($localeHack != null) {
         $locale = "{$locale}{$localeHack}";
     }
     $env = "LC_ALL={$locale}";
     putenv($env);
     setlocale(LC_ALL, $locale);
     bindtextdomain("messages", self::$_localeDir);
     textdomain("messages");
 }
 /**
  * Before render an action ...
  * 1. Check that the controller exists
  * 2. Check that the action exists and is callable (_process() method)
  * 3. Check the authentication
  * 4. Set Locales
  *
  * @return int
  */
 private function _beforeRender()
 {
     $config = Config::getInstance();
     $modulePath = (string) $config->getParam("modulePath");
     $controllerPath = (string) $config->getParam("controllerPath");
     $modelPath = (string) $config->getParam("modelPath");
     $this->_controllerName = $this->_controller . "Controller";
     $this->_modulePath = $modulePath . DS . $this->_module;
     $this->_controllerPath = $this->_modulePath . DS . $controllerPath;
     $this->_controllerFile = $this->_modulePath . DS . $controllerPath . DS . $this->_controllerName . ".php";
     $this->_modelPath = $this->_modulePath . DS . $modelPath . DS . $this->_controller . "Model";
     if (!$this->_process()) {
         return 0;
     }
     if ($this->_authentication) {
         if (!Session::issetData("status", "login") || Session::get("status", "login") === false) {
             return -1;
         } else {
             if (!in_array(Session::get("role", "login"), $this->_authentication)) {
                 return -1;
             }
         }
     }
     $this->_setLocales();
     return 1;
 }