Exemplo n.º 1
0
 /**
  * 	method:	setLanguageKey
  *
  *	Will retrieve the lang_key from the configuration and set it into the static data, ready to use when required
  *	Then if the old key exists in the session, it will upgrade all the existing keys to the new language key, keeping
  *	everything clean and tidy
  */
 public function setLanguageKey()
 {
     $k = current(Amslib_Array::filter(Amslib_Array::valid($this->data["value"]), "name", "lang_key", true));
     //	key wasn't found, do nothing
     if (empty($k)) {
         return;
     }
     //	key was found, attempt to upgrade old keys to new keys
     $old = self::$langKey;
     self::$langKey = $k["value"];
     //	loop through session, find matching keys against the old key, replace with the new keys
     foreach ($_SESSION as $key => $value) {
         if (strpos($key, $old) !== false) {
             unset($_SESSION[$key]);
             $key = str_replace($old, self::$langKey, $key);
             Amslib_SESSION::set(Amslib_File::reduceSlashes($key), $value);
         }
     }
 }