Ejemplo n.º 1
0
 /**
  * vrati instanci configu stranky podle URL
  * @param string $url
  * @return LBoxConfigItemStructure
  */
 protected function getPageCFGByURL($url = "")
 {
     try {
         if (strlen($url) < 1) {
             $url = substr(LBOX_REQUEST_URL, -1) == "/" ? LBOX_REQUEST_URL : LBOX_REQUEST_URL . "/";
             $url = str_replace("?/", "/", $url);
             $url = str_replace("//", "/", $url);
         }
         // vycistime URL od parametru a hostu
         $url = preg_replace("/" . LBOX_REQUEST_URL_SCHEME . ":(\\/+)/", "", $url);
         $url = substr($url, strpos($url, "/"));
         $url = preg_replace("/(\\?|\\:)(.+)/", "", $url);
         $displayLanguage = LBoxFront::getDisplayLanguage();
         foreach (LBoxConfigManagerLangdomains::getInstance()->getLangsDomains() as $lang => $domain) {
             try {
                 LBoxFront::setDisplayLanguage($lang);
                 $configItemStructure = LBoxConfigManagerStructure::getInstance()->getPageByUrl($url);
                 if ($configItemStructure instanceof LBoxConfigItemStructure) {
                     break;
                 }
             } catch (Exception $e) {
                 $exception = $e;
             }
         }
         LBoxFront::setDisplayLanguage($displayLanguage);
         return $configItemStructure;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 2
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;
     }
 }