Index: trunk/extensions/Validator/Validator.class.php |
— | — | @@ -161,9 +161,12 @@ |
162 | 162 | if ( count( $parts ) == 1 ) { |
163 | 163 | // Default parameter assignment is only possible when there are default parameters! |
164 | 164 | if ( count( $defaultParams ) > 0 ) { |
165 | | - $defaultParam = array_shift( $defaultParams ); |
166 | | - $parameters[strtolower( $defaultParam )] = array( |
167 | | - 'original-value' => trim( $toLower ? strtolower( $parts[0] ) : $parts[0] ), |
| 165 | + $defaultParam = strtolower( array_shift( $defaultParams ) ); |
| 166 | + |
| 167 | + $this->lowerCaseIfNeeded( $parts[0], $defaultParam, $parameterInfo, $toLower ); |
| 168 | + |
| 169 | + $parameters[$defaultParam] = array( |
| 170 | + 'original-value' => trim( $parts[0] ), |
168 | 171 | 'default' => $defaultNr, |
169 | 172 | 'position' => $nr |
170 | 173 | ); |
— | — | @@ -175,8 +178,10 @@ |
176 | 179 | } else { |
177 | 180 | $paramName = trim( strtolower( $parts[0] ) ); |
178 | 181 | |
| 182 | + $this->lowerCaseIfNeeded( $parts[1], $paramName, $parameterInfo, $toLower ); |
| 183 | + |
179 | 184 | $parameters[$paramName] = array( |
180 | | - 'original-value' => trim( $toLower ? strtolower( $parts[1] ) : $parts[1] ), |
| 185 | + 'original-value' => trim( $parts[1] ), |
181 | 186 | 'default' => false, |
182 | 187 | 'position' => $nr |
183 | 188 | ); |
— | — | @@ -230,7 +235,7 @@ |
231 | 236 | else { |
232 | 237 | if ( is_string( $paramData ) ) { |
233 | 238 | $paramData = trim( $paramData ); |
234 | | - if ( $toLower ) $paramData = strtolower( $paramData ); |
| 239 | + $this->lowerCaseIfNeeded( $paramData, $mainName, $this->mParameterInfo, $toLower ); |
235 | 240 | } |
236 | 241 | |
237 | 242 | $this->mParameters[$mainName] = array( |
— | — | @@ -251,6 +256,21 @@ |
252 | 257 | } |
253 | 258 | |
254 | 259 | /** |
| 260 | + * Lowercases the provided $paramValue if needed. |
| 261 | + * |
| 262 | + * @since 0.3.6 |
| 263 | + * |
| 264 | + * @param $paramValue String |
| 265 | + * @param $paramName String |
| 266 | + * @param $parameterInfo Array |
| 267 | + * @param $globalDefault Boolean |
| 268 | + */ |
| 269 | + protected function lowerCaseIfNeeded( &$paramValue, $paramName, array $parameterInfo, $globalDefault ) { |
| 270 | + $lowerCase = array_key_exists( 'tolower', $parameterInfo[$paramName] ) ? $parameterInfo[$paramName]['tolower'] : $globalDefault; |
| 271 | + if ( $lowerCase ) $paramValue = strtolower( $paramValue ); |
| 272 | + } |
| 273 | + |
| 274 | + /** |
255 | 275 | * Returns the main parameter name for a given parameter or alias, or false |
256 | 276 | * when it is not recognized as main parameter or alias. |
257 | 277 | * |
— | — | @@ -258,7 +278,7 @@ |
259 | 279 | * |
260 | 280 | * @return string or false |
261 | 281 | */ |
262 | | - private function getMainParamName( $paramName ) { |
| 282 | + protected function getMainParamName( $paramName ) { |
263 | 283 | $result = false; |
264 | 284 | |
265 | 285 | if ( array_key_exists( $paramName, $this->mParameterInfo ) ) { |