i18n handler now properly validates all languages
authorAlexander Ebert <ebert@woltlab.com>
Fri, 10 Feb 2012 15:08:27 +0000 (16:08 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 10 Feb 2012 15:08:27 +0000 (16:08 +0100)
Fixes #418

wcfsetup/install/files/lib/system/language/I18nHandler.class.php

index 1699e24d452f2f719ca526d00d791286967bbb63..5ed59ada00be46482ce3f5d5b350bf9214273223 100644 (file)
@@ -23,6 +23,12 @@ class I18nHandler extends SingletonFactory {
         */
        protected $assignValueVariablesDisabled = false;
        
+       /**
+        * list of available languages
+        * @var array<wcf\data\language\Language>
+        */
+       protected $availableLanguages = array();
+       
        /**
         * list of element ids
         * @var array<string>
@@ -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
                ));