예제 #1
0
 /**
  * returns currently displaying language key
  * @return string
  */
 public static function getDisplayLanguage()
 {
     try {
         if (strlen(self::$displayLanguage) > 0) {
             return self::$displayLanguage;
         }
         $defaultLang = LBoxConfigSystem::getInstance()->getParamByPath("multilang/default_language");
         // check domain or return default
         try {
             $host = str_replace(".localhost", "", LBOX_REQUEST_URL_HOST);
             $host = str_replace("www.", "", $host);
             if (strlen($lang = LBoxConfigManagerLangdomains::getInstance()->getLangByDomain($host)) > 0) {
                 self::$displayLanguage = $lang;
             } else {
                 self::$displayLanguage = $defaultLang;
             }
             if (LBoxConfigManagerFront::gpcn('langchoose') == 'cookie') {
                 $cookies = self::getDataCookies();
                 if (strlen($cookies['lbox']['front']['lng']) > 0) {
                     self::$displayLanguage = $cookies['lbox']['front']['lng'];
                 }
                 if (strlen($_SESSION['lbox']['front']['lng']) > 0) {
                     self::$displayLanguage = $_SESSION['lbox']['front']['lng'];
                 }
             }
         } catch (LBoxExceptionConfig $e) {
             if ($e->getCode() == LBoxExceptionConfig::CODE_TYPE_NOT_FOUND) {
                 self::$displayLanguage = $defaultLang;
             }
         }
         return self::$displayLanguage;
     } catch (Exception $e) {
         throw $e;
     }
 }