Пример #1
0
 protected static function LoadJezyki()
 {
     //var_dump(self::$_cache);
     if (self::$_cache == null) {
         if (Config::$UseLanguageDiskCache && file_exists(WEB_API_DIR . "/jezyki_cache.bin")) {
             $h = fopen(WEB_API_DIR . "/jezyki_cache.bin", "r");
             $buf = fread($h, filesize(WEB_API_DIR . "/jezyki_cache.bin"));
             fclose($h);
             self::$_cache = unserialize($buf);
         } else {
             $result = DataBase::GetDbInstance()->ExecuteQuery("SELECT * FROM #S#jezyki");
             self::$_cache = array();
             while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
                 $jt = self::BuildJezyk($row);
                 if (!array_key_exists($jt->GetKlucz(), self::$_cache)) {
                     self::$_cache[$jt->GetKlucz()] = array();
                 }
                 self::$_cache[$jt->GetKlucz()][$jt->GetIdJezyk()] = $jt->GetWartosc();
             }
         }
     }
 }
Пример #2
0
 /**
  * Get a list of language text to be added or remove. Write the language text to database.
  * @return int
  */
 public function GetJezyki()
 {
     if (!$this->WS()) {
         return null;
     }
     try {
         $params = array('sid' => $this->_sid);
         $result = $this->WS()->getSC()->__soapCall("GetJezyki", array($params));
         if ($result->GetJezykiResult->Status != 0) {
             Errors::LogError("WebService:GetJezyki", "Response: " . $result->GetJezykiResult->Message);
             return 0;
         }
         $xml = simplexml_load_string($result->GetJezykiResult->XMLContent);
         $cnt = 0;
         foreach ($xml->children() as $node) {
             $jt = new JezykTekst(strtolower($node["klucz"]), $node["jezyk"], $node->wartosc);
             JezykiTeksty::AddEditJezyk($jt);
             echo DataBase::GetDbInstance()->LastError();
             $cnt++;
         }
         return $cnt;
     } catch (Exception $ex) {
         Errors::LogError("WebService:GetJezyki", $ex->getMessage());
         return 0;
     }
 }
Пример #3
0
 /**
  * Create cache file with all language text.
  */
 public function ClearLanguageCache()
 {
     $buf = serialize(JezykiTeksty::GetJezyki());
     $cwd = getcwd();
     chdir(WEB_API_DIR);
     $h = fopen("jezyki_cache.bin", "w");
     fwrite($h, $buf);
     fclose($h);
     chdir($cwd);
 }