i18n handler no longer enforce values for plain input
authorAlexander Ebert <ebert@woltlab.com>
Fri, 10 Feb 2012 15:18:17 +0000 (16:18 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 10 Feb 2012 15:18:17 +0000 (16:18 +0100)
Fixes #426

wcfsetup/install/files/lib/system/language/I18nHandler.class.php
wcfsetup/install/files/lib/system/option/TextI18nOptionType.class.php
wcfsetup/install/files/lib/system/option/TextareaI18nOptionType.class.php

index 5ed59ada00be46482ce3f5d5b350bf9214273223..d9a9dcee176beb88d6c75772ab227463b9bd6979 100644 (file)
@@ -141,10 +141,16 @@ class I18nHandler extends SingletonFactory {
         * 
         * @param       string          $elementID
         * @param       boolean         $requireI18n
+        * @param       boolean         $permitEmptyValue
         * @return      boolean
         */
-       public function validateValue($elementID, $requireI18n = false) {
+       public function validateValue($elementID, $requireI18n = false, $permitEmptyValue = false) {
                if ($this->isPlainValue($elementID)) {
+                       // plain values may be left empty
+                       if ($permitEmptyValue) {
+                               return true;
+                       }
+                       
                        if ($requireI18n || $this->getValue($elementID) == '') {
                                return false;
                        }
index dee53c4c8cedf3f0aefaf9c6224ea3f175d37138..db02e6a4404bcd41997521d962c845007dcbaa8d 100644 (file)
@@ -40,7 +40,7 @@ class TextI18nOptionType extends TextOptionType {
         * @see wcf\system\option\IOptionType::validate()
         */
        public function validate(Option $option, $newValue) {
-               if (!I18nHandler::getInstance()->validateValue($option->optionName, $option->requireI18n)) {
+               if (!I18nHandler::getInstance()->validateValue($option->optionName, $option->requireI18n, true)) {
                        throw new UserInputException($option->optionName, 'validationFailed');
                }
        }
index 50eb0a9abb23b71b37024bd9097d1f2ac12a387d..71bb4ac62e78147c63dc3827940c1e33e0ae60bb 100644 (file)
@@ -39,7 +39,7 @@ class TextareaI18nOptionType extends TextareaOptionType {
         * @see wcf\system\option\IOptionType::validate()
         */
        public function validate(Option $option, $newValue) {
-               if (!I18nHandler::getInstance()->validateValue($option->optionName, $option->requireI18n)) {
+               if (!I18nHandler::getInstance()->validateValue($option->optionName, $option->requireI18n, true)) {
                        throw new UserInputException($option->optionName, 'validationFailed');
                }
        }