From efe67cf49ecebca600d0904c4209822aa6749230 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 8 Jul 2014 17:25:54 +0200 Subject: [PATCH] Fix issues when validation integer condition inputs --- .../AbstractIntegerCondition.class.php | 24 +++++++++++++------ wcfsetup/install/lang/de.xml | 10 ++++---- wcfsetup/install/lang/en.xml | 10 ++++---- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/wcfsetup/install/files/lib/system/condition/AbstractIntegerCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractIntegerCondition.class.php index e380d8f683..12bd190224 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractIntegerCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractIntegerCondition.class.php @@ -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 <<getMinMaxAttributes('greaterThan')} /> -getMinMaxAttributes('lessThan')} /> +getMinMaxAttributes('greaterThan')} class="medium" /> +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'); } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index a8486e7351..c7e491c3dc 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1756,12 +1756,12 @@ Fehler sind beispielsweise: - - - + + + - - + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 44cf656dcb..170636d033 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1724,12 +1724,12 @@ Errors are: - - - + + + - - + + -- 2.20.1