Fix issues when validation integer condition inputs
authorMatthias Schmidt <gravatronics@live.com>
Tue, 8 Jul 2014 15:25:54 +0000 (17:25 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 8 Jul 2014 15:25:54 +0000 (17:25 +0200)
wcfsetup/install/files/lib/system/condition/AbstractIntegerCondition.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index e380d8f6836a8bc57e5af861a507e4a704c5a9dd..12bd1902240a3621ca640a63981cdc1dfe3f8f1a 100644 (file)
@@ -79,6 +79,11 @@ abstract class AbstractIntegerCondition extends AbstractSingleFieldCondition {
                        $errorMessage = '';
                        switch ($this->errorMessage) {
                                case 'wcf.condition.greaterThan.error.maxValue':
+                                       $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array(
+                                               'maxValue' => $this->maxValue - 1
+                                       ));
+                               break;
+                               
                                case 'wcf.condition.lessThan.error.maxValue':
                                        $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array(
                                                'maxValue' => $this->maxValue
@@ -86,12 +91,17 @@ abstract class AbstractIntegerCondition extends AbstractSingleFieldCondition {
                                break;
                                
                                case 'wcf.condition.greaterThan.error.minValue':
-                               case 'wcf.condition.lessThan.error.minValue':
                                        $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array(
                                                'minValue' => $this->minValue
                                        ));
                                break;
                                
+                               case 'wcf.condition.lessThan.error.minValue':
+                                       $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array(
+                                               'minValue' => $this->minValue + 1
+                                       ));
+                               break;
+                               
                                default:
                                        $errorMessage = WCF::getLanguage()->get($this->errorMessage);
                                break;
@@ -111,8 +121,8 @@ abstract class AbstractIntegerCondition extends AbstractSingleFieldCondition {
                $lessThanPlaceHolder = WCF::getLanguage()->get('wcf.condition.lessThan');
                
                return <<<HTML
-<input type="number" name="greaterThan_{$this->getIdentifier()}" value="{$this->greaterThan}" placeholder="{$greaterThanPlaceHolder}"{$this->getMinMaxAttributes('greaterThan')} />
-<input type="number" name="lessThan_{$this->getIdentifier()}" value="{$this->lessThan}" placeholder="{$lessThanPlaceHolder}"{$this->getMinMaxAttributes('lessThan')} />
+<input type="number" name="greaterThan_{$this->getIdentifier()}" value="{$this->greaterThan}" placeholder="{$greaterThanPlaceHolder}"{$this->getMinMaxAttributes('greaterThan')} class="medium" />
+<input type="number" name="lessThan_{$this->getIdentifier()}" value="{$this->lessThan}" placeholder="{$lessThanPlaceHolder}"{$this->getMinMaxAttributes('lessThan')} class="medium" />
 HTML;
        }
        
@@ -155,7 +165,7 @@ HTML;
                        $attributes .= ' min="'.($this->getMinValue() + ($type == 'lessThan' ? 1 : 0)).'"';
                }
                if ($this->getMaxValue() !== null) {
-                       $attributes .= ' max="'.($this->getMaxValue() - ($type == 'lessThan' ? 1 : 0)).'"';
+                       $attributes .= ' max="'.($this->getMaxValue() - ($type == 'greaterThan' ? 1 : 0)).'"';
                }
                
                return $attributes;
@@ -214,19 +224,19 @@ HTML;
                                throw new UserInputException('lessThan', 'minValue');
                        }
                        else if ($this->getMaxValue() !== null && $this->lessThan > $this->getMaxValue()) {
-                               $this->errorMessages['lessThan'] = 'wcf.condition.lessThan.error.maxValue';
+                               $this->errorMessage = 'wcf.condition.lessThan.error.maxValue';
                                
                                throw new UserInputException('lessThan', 'maxValue');
                        }
                }
                if ($this->greaterThan !== null) {
                        if ($this->getMinValue() !== null && $this->greaterThan < $this->getMinValue()) {
-                               $this->errorMessages['greaterThan'] = 'wcf.condition.greaterThan.error.minValue';
+                               $this->errorMessage = 'wcf.condition.greaterThan.error.minValue';
                                
                                throw new UserInputException('greaterThan', 'minValue');
                        }
                        else if ($this->getMaxValue() !== null && $this->greaterThan >= $this->getMaxValue()) {
-                               $this->errorMessages['greaterThan'] = 'wcf.condition.greaterThan.error.maxValue';
+                               $this->errorMessage = 'wcf.condition.greaterThan.error.maxValue';
                                
                                throw new UserInputException('greaterThan', 'maxValue');
                        }
index a8486e735112c236c6f8c7b8b0187b9ffb56b4ab..c7e491c3dc29c87fc41f3e076b19e34344f6c7dd 100644 (file)
@@ -1756,12 +1756,12 @@ Fehler sind beispielsweise:
        
        <category name="wcf.condition">
                <item name="wcf.condition.greaterThan"><![CDATA[mehr als]]></item>
-               <item name="wcf.condition.greaterThan.error.lessThan"><![CDATA[Der Minimalwert und der Maximalwert sind widersprüchlich.]]></item>
-               <item name="wcf.condition.greaterThan.error.maxValue"><![CDATA[Der Maximalwert darf nicht größer sein als {#$maxValue}.]]></item>
-               <item name="wcf.condition.greaterThan.error.minValue"><![CDATA[Der Maximalwert darf nicht kleiner sein als {#$minValue}.]]></item>
+               <item name="wcf.condition.greaterThan.error.lessThan"><![CDATA[Der „weniger als“-Wert und der „mehr als“-Wert sind widersprüchlich.]]></item>
+               <item name="wcf.condition.greaterThan.error.maxValue"><![CDATA[Der „mehr als“-Wert darf nicht größer sein als {#$maxValue}.]]></item>
+               <item name="wcf.condition.greaterThan.error.minValue"><![CDATA[Der „mehr als“-Wert darf nicht kleiner sein als {#$minValue}.]]></item>
                <item name="wcf.condition.lessThan"><![CDATA[weniger als]]></item>
-               <item name="wcf.condition.lessThan.error.maxValue"><![CDATA[Der Minimalwert darf nicht größer sein als {#$maxValue}.]]></item>
-               <item name="wcf.condition.lessThan.error.minValue"><![CDATA[Der Minimalwert darf nicht kleiner sein als {#$minValue}.]]></item>
+               <item name="wcf.condition.lessThan.error.maxValue"><![CDATA[Der „weniger als“-Wert darf nicht größer sein als {#$maxValue}.]]></item>
+               <item name="wcf.condition.lessThan.error.minValue"><![CDATA[Der „weniger als“-Wert darf nicht kleiner sein als {#$minValue}.]]></item>
        </category>
        
        <category name="wcf.dashboard">
index 44cf656dcb52f60a69c8c48243378d93843b0e7f..170636d033f5c85dd4438b08a1d63a4ad4600cc4 100644 (file)
@@ -1724,12 +1724,12 @@ Errors are:
        
        <category name="wcf.condition">
                <item name="wcf.condition.greaterThan"><![CDATA[greater than]]></item>
-               <item name="wcf.condition.greaterThan.error.lessThan"><![CDATA[The minimal value and the maximum value are conflicting.]]></item>
-               <item name="wcf.condition.greaterThan.error.maxValue"><![CDATA[The maximum value may not be greater than {#$maxValue}.]]></item>
-               <item name="wcf.condition.greaterThan.error.minValue"><![CDATA[The maximum value may not be less than {#$minValue}.]]></item>
+               <item name="wcf.condition.greaterThan.error.lessThan"><![CDATA[The “less than” value and the “greater than” value are conflicting.]]></item>
+               <item name="wcf.condition.greaterThan.error.maxValue"><![CDATA[The “greater than” value may not be greater than {#$maxValue}.]]></item>
+               <item name="wcf.condition.greaterThan.error.minValue"><![CDATA[The “greater than” value may not be less than {#$minValue}.]]></item>
                <item name="wcf.condition.lessThan"><![CDATA[less than]]></item>
-               <item name="wcf.condition.lessThan.error.maxValue"><![CDATA[The minimal value may not be greater than {#$maxValue}.]]></item>
-               <item name="wcf.condition.lessThan.error.minValue"><![CDATA[The minimal value may not be less than {#$minValue}.]]></item>
+               <item name="wcf.condition.lessThan.error.maxValue"><![CDATA[The “less than” value may not be greater than {#$maxValue}.]]></item>
+               <item name="wcf.condition.lessThan.error.minValue"><![CDATA[The “less than” value may not be less than {#$minValue}.]]></item>
        </category>
        
        <category name="wcf.dashboard">