<?php
namespace wcf\system\cache\builder;
use wcf\data\language\category\LanguageCategoryList;
+use wcf\data\language\LanguageList;
use wcf\system\WCF;
/**
$data['packages'][$row['packageID']] = array();
}
$data['packages'][$row['packageID']][] = $row['languageID'];
-
- // language to packages
- if (!isset($languageToPackages[$row['languageID']])) {
- $languageToPackages[$row['languageID']] = array();
- }
- $languageToPackages[$row['languageID']][] = $row['packageID'];
}
// get languages
- $sql = "SELECT *
- FROM wcf".WCF_N."_language";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute();
- while ($row = $statement->fetchArray()) {
- // language data
- $data['languages'][$row['languageID']] = $row;
-
- // language to packages
- if (!isset($languageToPackages[$row['languageID']])) {
- $languageToPackages[$row['languageID']] = array();
- }
- $data['languages'][$row['languageID']]['packages'] = $languageToPackages[$row['languageID']];
-
+ $languageList = new LanguageList();
+ $languageList->sqlLimit = 0;
+ $languageList->readObjects();
+ $data['languages'] = $languageList->getObjects();
+ foreach ($languageList->getObjects() as $language) {
// default language
- if ($row['isDefault']) {
- $data['default'] = $row['languageID'];
+ if ($language->isDefault) {
+ $data['default'] = $language->languageID;
}
// language code to language id
- $data['codes'][$row['languageCode']] = $row['languageID'];
+ $data['codes'][$language->languageCode] = $language->languageID;
}
// get language categories
*/
public function getLanguage($languageID) {
if (!isset($this->languages[$languageID])) {
- $language = new Language($languageID);
- if (!$language->languageID) {
+ if (!isset($this->cache['languages'][$languageID])) {
return null;
}
- $this->languages[$language->languageID] = $language;
+ $this->languages[$languageID] = $this->cache['languages'][$languageID];
}
return $this->languages[$languageID];
}
// get default language
- $defaultLanguageCode = $this->cache['languages'][$this->cache['default']]['languageCode'];
+ $defaultLanguageCode = $this->cache['languages'][$this->cache['default']]->languageCode;
// get preferred language
$languageCode = self::getPreferredLanguage($availableLanguageCodes, $defaultLanguageCode);
// get language id of preferred language
foreach ($this->cache['languages'] as $key => $language) {
- if ($language['languageCode'] == $languageCode) {
+ if ($language->languageCode == $languageCode) {
return $key;
}
}
$availableLanguages = array();
if (isset($this->cache['packages'][$packageID])) {
foreach ($this->cache['packages'][$packageID] as $availableLanguageID) {
- if ($this->cache['languages'][$availableLanguageID]['hasContent']) {
+ if ($this->cache['languages'][$availableLanguageID]->hasContent) {
$availableLanguages[$availableLanguageID] = $this->getLanguage($availableLanguageID);
}
}