From 470e23e35d22ac11f1853273713f5fc6918bf003 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 10 Feb 2012 16:08:27 +0100 Subject: [PATCH] i18n handler now properly validates all languages Fixes #418 --- .../lib/system/language/I18nHandler.class.php | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php index 1699e24d45..5ed59ada00 100644 --- a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php +++ b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php @@ -23,6 +23,12 @@ class I18nHandler extends SingletonFactory { */ protected $assignValueVariablesDisabled = false; + /** + * list of available languages + * @var array + */ + protected $availableLanguages = array(); + /** * list of element ids * @var array @@ -47,6 +53,13 @@ class I18nHandler extends SingletonFactory { */ protected $elementOptions = array(); + /** + * @see wcf\system\SingletonFactory::init() + */ + protected function init() { + $this->availableLanguages = LanguageFactory::getInstance()->getLanguages(); + } + /** * Registers a new element id, returns false if element id is already set. * @@ -140,8 +153,12 @@ class I18nHandler extends SingletonFactory { return false; } else { - foreach ($this->i18nValues[$elementID] as $value) { - if (empty($value)) { + foreach ($this->availableLanguages as $language) { + if (!isset($this->i18nValues[$elementID][$language->languageID])) { + return false; + } + + if (empty($this->i18nValues[$elementID][$language->languageID])) { return false; } } @@ -327,7 +344,7 @@ class I18nHandler extends SingletonFactory { } WCF::getTPL()->assign(array( - 'availableLanguages' => LanguageFactory::getInstance()->getLanguages(), + 'availableLanguages' => $this->availableLanguages, 'i18nPlainValues' => $elementValues, 'i18nValues' => $elementValuesI18n )); -- 2.20.1