From 5d754374c5ebcfffa7472856c02bb59f6f7484df Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 5 Dec 2012 21:16:48 +0100 Subject: [PATCH] Fixed LanguageFactory --- .../builder/LanguageCacheBuilder.class.php | 3 ++ .../system/language/LanguageFactory.class.php | 31 +++++-------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php index 0330034b44..cd1fd89f32 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php @@ -2,6 +2,7 @@ namespace wcf\system\cache\builder; use wcf\data\language\category\LanguageCategoryList; use wcf\data\language\LanguageList; +use wcf\data\DatabaseObject; use wcf\system\WCF; /** @@ -46,6 +47,8 @@ class LanguageCacheBuilder implements ICacheBuilder { $data['countryCode'][$language->languageID] = $language->countryCode; } + DatabaseObject::sort($data['languages'], 'languageName'); + // get language categories $languageCategoryList = new LanguageCategoryList(); $languageCategoryList->sqlLimit = 0; diff --git a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php index a79adf986c..bc6585fcba 100644 --- a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php +++ b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php @@ -2,7 +2,6 @@ namespace wcf\system\language; use wcf\data\language\Language; use wcf\data\language\LanguageEditor; -use wcf\data\DatabaseObject; use wcf\system\cache\CacheHandler; use wcf\system\template\TemplateScriptingCompiler; use wcf\system\SingletonFactory; @@ -142,7 +141,7 @@ class LanguageFactory extends SingletonFactory { protected function findPreferredLanguage() { // get available language codes $availableLanguageCodes = array(); - foreach ($this->getLanguages(PACKAGE_ID) as $language) { + foreach ($this->getLanguages() as $language) { $availableLanguageCodes[] = $language->languageCode; } @@ -240,41 +239,27 @@ class LanguageFactory extends SingletonFactory { } /** - * Returns all available languages for package with the given id. + * Returns all available languages. * - * @param integer $packageID * @return array */ - public function getLanguages($packageID = PACKAGE_ID) { - // get list of all available languages - $availableLanguages = array(); - if (isset($this->cache['packages'][$packageID])) { - foreach ($this->cache['packages'][$packageID] as $availableLanguageID) { - $availableLanguages[$availableLanguageID] = $this->getLanguage($availableLanguageID); - } - } - - DatabaseObject::sort($availableLanguages, 'languageName'); - return $availableLanguages; + public function getLanguages() { + return $this->cache['languages']; } /** * Returns all available content languages for given package. * - * @param integer $packageID * @return array */ - public function getContentLanguages($packageID = PACKAGE_ID) { + public function getContentLanguages() { $availableLanguages = array(); - if (isset($this->cache['packages'][$packageID])) { - foreach ($this->cache['packages'][$packageID] as $availableLanguageID) { - if ($this->cache['languages'][$availableLanguageID]->hasContent) { - $availableLanguages[$availableLanguageID] = $this->getLanguage($availableLanguageID); - } + foreach ($this->getLanguages() as $languageID => $language) { + if ($language->hasContent) { + $availableLanguages[$languageID] = $language; } } - DatabaseObject::sort($availableLanguages, 'languageName'); return $availableLanguages; } -- 2.20.1