Ejemplo n.º 1
0
 /**
  * @see	\wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
  */
 public function rebuild(array $parameters)
 {
     $data = array('codes' => array(), 'countryCodes' => array(), 'languages' => array(), 'default' => 0, 'categories' => array(), 'categoryIDs' => array(), 'multilingualismEnabled' => false);
     // get languages
     $languageList = new LanguageList();
     $languageList->readObjects();
     $data['languages'] = $languageList->getObjects();
     foreach ($languageList->getObjects() as $language) {
         // default language
         if ($language->isDefault) {
             $data['default'] = $language->languageID;
         }
         // multilingualism
         if ($language->hasContent) {
             $data['multilingualismEnabled'] = true;
         }
         // language code to language id
         $data['codes'][$language->languageCode] = $language->languageID;
         // country code to language id
         $data['countryCode'][$language->languageID] = $language->countryCode;
     }
     DatabaseObject::sort($data['languages'], 'languageName');
     // get language categories
     $languageCategoryList = new LanguageCategoryList();
     $languageCategoryList->readObjects();
     foreach ($languageCategoryList->getObjects() as $languageCategory) {
         $data['categories'][$languageCategory->languageCategory] = $languageCategory;
         $data['categoryIDs'][$languageCategory->languageCategoryID] = $languageCategory->languageCategory;
     }
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * @see wcf\system\cache\ICacheBuilder::getData()
  */
 public function getData(array $cacheResource)
 {
     $data = array('codes' => array(), 'countryCodes' => array(), 'languages' => array(), 'packages' => array(), 'default' => 0, 'categories' => array());
     // get language to packages
     $sql = "SELECT \t\tpackage.languageID, package.packageID\n\t\t\tFROM\t\twcf" . WCF_N . "_language_to_package package\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_language language\n\t\t\tON\t\t(language.languageID = package.languageID)\n\t\t\tORDER BY\tlanguage.isDefault DESC,\n\t\t\t\t\tlanguage.languageCode ASC";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute();
     while ($row = $statement->fetchArray()) {
         // package to languages
         if (!isset($data['packages'][$row['packageID']])) {
             $data['packages'][$row['packageID']] = array();
         }
         $data['packages'][$row['packageID']][] = $row['languageID'];
     }
     // get languages
     $languageList = new LanguageList();
     $languageList->sqlLimit = 0;
     $languageList->readObjects();
     $data['languages'] = $languageList->getObjects();
     foreach ($languageList->getObjects() as $language) {
         // default language
         if ($language->isDefault) {
             $data['default'] = $language->languageID;
         }
         // language code to language id
         $data['codes'][$language->languageCode] = $language->languageID;
         // country code to language id
         $data['countryCode'][$language->languageID] = $language->countryCode;
     }
     // get language categories
     $languageCategoryList = new LanguageCategoryList();
     $languageCategoryList->sqlLimit = 0;
     $languageCategoryList->readObjects();
     foreach ($languageCategoryList->getObjects() as $languageCategory) {
         $data['categories'][$languageCategory->languageCategory] = $languageCategory;
     }
     return $data;
 }
Ejemplo n.º 3
0
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // get languages
     $this->availableLanguages = LanguageFactory::getInstance()->getLanguages();
     // get categories
     $languageCategoryList = new LanguageCategoryList();
     $languageCategoryList->readObjects();
     $this->availableLanguageCategories = $languageCategoryList->getObjects();
     // check parameters
     if (!isset($this->availableLanguages[$this->languageID])) {
         $this->languageID = key($this->availableLanguages);
     }
     if ($this->languageCategoryID && !isset($this->availableLanguageCategories[$this->languageCategoryID])) {
         $this->languageCategoryID = 0;
     }
     // get items
     $this->languageItemList = new LanguageItemList();
     $this->languageItemList->getConditionBuilder()->add('languageID = ?', array($this->languageID));
     if ($this->languageCategoryID) {
         $this->languageItemList->getConditionBuilder()->add('languageCategoryID = ?', array($this->languageCategoryID));
     }
     if ($this->languageItem) {
         $this->languageItemList->getConditionBuilder()->add('languageItem LIKE ?', array('%' . $this->languageItem . '%'));
     }
     if ($this->languageItemValue) {
         $this->languageItemList->getConditionBuilder()->add('((languageUseCustomValue = 0 AND languageItemValue LIKE ?) OR languageCustomItemValue LIKE ?)', array('%' . $this->languageItemValue . '%', '%' . $this->languageItemValue . '%'));
     }
     if ($this->hasCustomValue) {
         $this->languageItemList->getConditionBuilder()->add("languageCustomItemValue IS NOT NULL");
     }
     $this->languageItemList->sqlLimit = 100;
     if (!empty($_POST)) {
         $this->count = $this->languageItemList->countObjects();
         $maxPages = ceil($this->count / 100);
         $this->pageNo = max(min($this->pageNo, $maxPages), 1);
         if ($this->pageNo > 1) {
             $this->languageItemList->sqlOffset = ($this->pageNo - 1) * 100;
         }
     }
     $this->languageItemList->readObjects();
 }