Exemplo n.º 1
0
 /**
  * destroys singleton instance from cache
  */
 public static function resetInstance()
 {
     try {
         self::$instances = array();
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemplo n.º 2
0
 /**
  * zjisti, zda je dostupna hodnota key a pripadne ji vraci
  * @param string $key
  * @param bool $htmlescape
  * @return string
  */
 public function translate($key, $htmlescape = true)
 {
     try {
         if (strlen($key) < 1) {
             throw new LBoxExceptionConfig(LBoxExceptionConfig::MSG_PARAM_STRING_NOTNULL, LBoxExceptionConfig::CODE_BAD_PARAM);
         }
         $out = "";
         foreach ($this->getLanguageFilePaths() as $lngIndex => $path) {
             if (!file_exists($path)) {
                 continue;
             }
             try {
                 return LBoxI18NDataManager::getInstance($path)->getTextById($key)->getContent();
             } catch (LBoxException $e) {
                 switch ($e->getCode()) {
                     case LBoxExceptionConfig::CODE_NODE_BYID_NOT_FOUND:
                         // v pripade, ze jsme nenalezli lang text v konkretni definici, hledame jeste v globalni
                         if ($lngIndex < 1) {
                             continue;
                         }
                         throw new LBoxExceptionI18N("{$path}::{$key}: " . LBoxExceptionI18N::MSG_LNG_ITEM_NOTEXISTS, LBoxExceptionI18N::CODE_LNG_ITEM_NOTEXISTS);
                         break;
                     default:
                         throw $e;
                 }
             }
         }
         throw new LBoxExceptionI18N(LBoxFront::getDisplayLanguage() . ": " . LBoxExceptionI18N::MSG_LNG_NOTEXISTS, LBoxExceptionI18N::CODE_LNG_NOTEXISTS);
     } catch (Exception $e) {
         throw $e;
     }
 }