r64991 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64990‎ | r64991 | r64992 >
Date:15:19, 13 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.3 - added fatal error level and support for default parameters. ALso refactored some stuff to follow mw conventions and fixed some issues with required parameters.
Modified paths:
  • /trunk/extensions/Validator/INSTALL (modified) (history)
  • /trunk/extensions/Validator/Validator.class.php (modified) (history)
  • /trunk/extensions/Validator/Validator.php (modified) (history)
  • /trunk/extensions/Validator/Validator_Manager.php (modified) (history)
  • /trunk/extensions/Validator/Validator_Settings.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/Validator.class.php
@@ -19,6 +19,8 @@
2020 * @ingroup Validator
2121 *
2222 * @author Jeroen De Dauw
 23+ *
 24+ * TODO: add native suport for default parameters as present in Maps 0.6.
2325 */
2426 final class Validator {
2527
@@ -49,7 +51,7 @@
5052 /**
5153 * @var array Holder for the validation functions.
5254 */
53 - private static $validationFunctions = array(
 55+ private static $mValidationFunctions = array(
5456 'in_array' => array( 'ValidatorFunctions', 'in_array' ),
5557 'in_range' => array( 'ValidatorFunctions', 'in_range' ),
5658 'is_numeric' => 'is_numeric',
@@ -62,7 +64,7 @@
6365 /**
6466 * @var array Holder for the list validation functions.
6567 */
66 - private static $listValidationFunctions = array(
 68+ private static $mListValidationFunctions = array(
6769 'item_count' => array( 'ValidatorFunctions', 'has_item_count' ),
6870 'unique_items' => array( 'ValidatorFunctions', 'has_unique_items' ),
6971 );
@@ -70,7 +72,7 @@
7173 /**
7274 * @var array Holder for the formatting functions.
7375 */
74 - private static $outputFormats = array(
 76+ private static $mOutputFormats = array(
7577 'array' => array( 'ValidatorFormats', 'format_array' ),
7678 'list' => array( 'ValidatorFormats', 'format_list' ),
7779 'boolean' => array( 'ValidatorFormats', 'format_boolean' ),
@@ -80,23 +82,25 @@
8183 'filtered_array' => array( 'ValidatorFormats', 'format_filtered_array' ),
8284 );
8385
84 - private $parameterInfo;
85 - private $rawParameters = array();
 86+ private $mParameterInfo;
 87+
 88+ private $mRawParameters = array();
8689
87 - private $parameters = array();
88 - private $valid = array();
89 - private $invalid = array();
90 - private $unknown = array();
 90+ private $mParameters = array();
 91+ private $mValidParams = array();
 92+ private $mInvalidParams = array();
 93+ private $mUnknownParams = array();
9194
92 - private $errors = array();
 95+ private $mErrors = array();
9396
9497 /**
9598 * Sets the parameter criteria, used to valiate the parameters.
9699 *
97100 * @param array $parameterInfo
 101+ * @param array $defaultParams
98102 */
99103 public function setParameterInfo( array $parameterInfo ) {
100 - $this->parameterInfo = $parameterInfo;
 104+ $this->mParameterInfo = $parameterInfo;
101105 }
102106
103107 /**
@@ -105,53 +109,79 @@
106110 * @param array $parameters
107111 */
108112 public function setParameters( array $parameters ) {
109 - $this->rawParameters = $parameters;
 113+ $this->mRawParameters = $parameters;
110114 }
111115
112116 /**
 117+ * Determine all parameter names and value, and take care of default (nameless)
 118+ * parameters, by turning them into named ones.
 119+ *
 120+ * @param array $rawParams
 121+ * @param array $defaultParams
 122+ */
 123+ public function parseAndSetParams( array $rawParams, array $defaultParams = array() ) {
 124+ $parameters = array();
 125+
 126+ foreach( $rawParams as $arg ) {
 127+ $parts = explode( '=', $arg );
 128+ if ( count( $parts ) == 1 ) {
 129+ if ( count( $defaultParams ) > 0 ) {
 130+ $defaultParam = array_shift( $defaultParams );
 131+ $parameters[$defaultParam] = trim( $parts[0] );
 132+ }
 133+ } else {
 134+ $name = strtolower( trim( array_shift( $parts ) ) );
 135+ $parameters[$name] = trim( implode( $parts ) );
 136+ }
 137+ }
 138+
 139+ $this->setParameters( $parameters );
 140+ }
 141+
 142+ /**
113143 * Valides the raw parameters, and allocates them as valid, invalid or unknown.
114144 * Errors are collected, and can be retrieved via getErrors.
115145 *
116 - * @return boolean Indicates whether there where no errors.
 146+ * @return boolean Indicates whether there where NO errors.
117147 */
118148 public function validateParameters() {
119149 // Loop through all the user provided parameters, and destinguise between those that are allowed and those that are not.
120 - foreach ( $this->rawParameters as $paramName => $paramValue ) {
 150+ foreach ( $this->mRawParameters as $paramName => $paramValue ) {
121151 // Attempt to get the main parameter name (takes care of aliases).
122 - $mainName = self::getMainParamName( $paramName, $this->parameterInfo );
123 - // If the parameter is found in the list of allowed ones, add it to the $parameters array.
 152+ $mainName = self::getMainParamName( $paramName );
 153+ // If the parameter is found in the list of allowed ones, add it to the $mParameters array.
124154 if ( $mainName ) {
125155 // Check for parameter overriding. In most cases, this has already largely been taken care off,
126156 // in the form of later parameters overriding earlier ones. This is not true for different aliases though.
127 - if ( ! array_key_exists( $mainName, $this->parameters ) || self::$acceptOverriding ) {
128 - $this->parameters[$mainName] = $paramValue;
 157+ if ( !array_key_exists( $mainName, $this->mParameters ) || self::$acceptOverriding ) {
 158+ $this->mParameters[$mainName] = $paramValue;
129159 }
130160 else {
131 - $this->errors[] = array( 'type' => 'unknown', 'name' => $mainName );
 161+ $this->errors[] = array( 'type' => 'override', 'name' => $mainName );
132162 }
133163 }
134 - else { // If the parameter is not found in the list of allowed ones, add an item to the $this->errors array.
135 - if ( self::$storeUnknownParameters ) $this->unknown[$paramName] = $paramValue;
136 - $this->errors[] = array( 'type' => 'unknown', 'name' => $paramName );
 164+ else { // If the parameter is not found in the list of allowed ones, add an item to the $this->mErrors array.
 165+ if ( self::$storeUnknownParameters ) $this->mUnknownParams[$paramName] = $paramValue;
 166+ $this->mErrors[] = array( 'type' => 'unknown', 'name' => $paramName );
137167 }
138168 }
139169
140170 // Loop through the list of allowed parameters.
141 - foreach ( $this->parameterInfo as $paramName => $paramInfo ) {
 171+ foreach ( $this->mParameterInfo as $paramName => $paramInfo ) {
142172 // If the user provided a value for this parameter, validate and handle it.
143 - if ( array_key_exists( $paramName, $this->parameters ) ) {
 173+ if ( array_key_exists( $paramName, $this->mParameters ) ) {
144174
145 - $paramValue = $this->parameters[$paramName];
 175+ $paramValue = $this->mParameters[$paramName];
146176 $this->cleanParameter( $paramName, $paramValue );
147177
148178 if ( $this->validateParameter( $paramName, $paramValue ) ) {
149179 // If the validation succeeded, add the parameter to the list of valid ones.
150 - $this->valid[$paramName] = $paramValue;
151 - $this->setOutputTypes( $this->valid[$paramName], $paramInfo );
 180+ $this->mValidParams[$paramName] = $paramValue;
 181+ $this->setOutputTypes( $this->mValidParams[$paramName], $paramInfo );
152182 }
153183 else {
154184 // If the validation failed, add the parameter to the list of invalid ones.
155 - $this->invalid[$paramName] = $paramValue;
 185+ $this->mInvalidParams[$paramName] = $paramValue;
156186 }
157187 }
158188 else {
@@ -161,13 +191,13 @@
162192 }
163193 else {
164194 // Set the default value (or default 'default value' if none is provided), and ensure the type is correct.
165 - $this->valid[$paramName] = array_key_exists( 'default', $paramInfo ) ? $paramInfo['default'] : '';
166 - $this->setOutputTypes( $this->valid[$paramName], $paramInfo );
 195+ $this->mValidParams[$paramName] = array_key_exists( 'default', $paramInfo ) ? $paramInfo['default'] : '';
 196+ $this->setOutputTypes( $this->mValidParams[$paramName], $paramInfo );
167197 }
168198 }
169199 }
170200
171 - return count( $this->errors ) == 0;
 201+ return count( $this->mErrors ) == 0;
172202 }
173203
174204 /**
@@ -175,23 +205,20 @@
176206 * when it is not recognized as main parameter or alias.
177207 *
178208 * @param string $paramName
179 - * @param array $allowedParms
180209 *
181210 * @return string
182211 */
183 - private function getMainParamName( $paramName, array $allowedParms ) {
 212+ private function getMainParamName( $paramName ) {
184213 $result = false;
185214
186 - if ( array_key_exists( $paramName, $allowedParms ) ) {
 215+ if ( array_key_exists( $paramName, $this->mParameterInfo ) ) {
187216 $result = $paramName;
188217 }
189218 else {
190 - foreach ( $allowedParms as $name => $data ) {
191 - if ( array_key_exists( 'aliases', $data ) ) {
192 - if ( in_array( $paramName, $data['aliases'] ) ) {
193 - $result = $name;
194 - break;
195 - }
 219+ foreach ( $this->mParameterInfo as $name => $data ) {
 220+ if ( array_key_exists( 'aliases', $data ) && in_array( $paramName, $data['aliases'] ) ) {
 221+ $result = $name;
 222+ break;
196223 }
197224 }
198225 }
@@ -207,29 +234,34 @@
208235 */
209236 private function cleanParameter( $name, &$value ) {
210237 // Ensure there is a criteria array.
211 - if ( ! array_key_exists( 'criteria', $this->parameterInfo[$name] ) ) {
212 - $this->parameterInfo[$name]['criteria'] = array();
 238+ if ( ! array_key_exists( 'criteria', $this->mParameterInfo[$name] ) ) {
 239+ $this->mParameterInfo[$name]['criteria'] = array();
213240 }
214241
215242 // Ensure the type is set in array form.
216 - if ( ! array_key_exists( 'type', $this->parameterInfo[$name] ) ) {
217 - $this->parameterInfo[$name]['type'] = array( 'string' );
 243+ if ( ! array_key_exists( 'type', $this->mParameterInfo[$name] ) ) {
 244+ $this->mParameterInfo[$name]['type'] = array( 'string' );
218245 }
219 - elseif ( ! is_array( $this->parameterInfo[$name]['type'] ) ) {
220 - $this->parameterInfo[$name]['type'] = array( $this->parameterInfo[$name]['type'] );
 246+ elseif ( ! is_array( $this->mParameterInfo[$name]['type'] ) ) {
 247+ $this->mParameterInfo[$name]['type'] = array( $this->mParameterInfo[$name]['type'] );
221248 }
222249
223 - if ( array_key_exists( 'type', $this->parameterInfo[$name] ) ) {
 250+ if ( array_key_exists( 'type', $this->mParameterInfo[$name] ) ) {
224251 // Add type specific criteria.
225 - switch( strtolower( $this->parameterInfo[$name]['type'][0] ) ) {
 252+ switch( strtolower( $this->mParameterInfo[$name]['type'][0] ) ) {
226253 case 'integer':
227254 $this->addTypeCriteria( $name, 'is_integer' );
228255 break;
229 - case 'number':
 256+ case 'float':
 257+ // FIXME: only accept floats, not the weird crap is_numeric also accepts
230258 $this->addTypeCriteria( $name, 'is_numeric' );
231 - break;
 259+ break;
 260+ case 'number': // Note: This accepts non-decimal notations!
 261+ $this->addTypeCriteria( $name, 'is_numeric' );
 262+ break;
232263 case 'boolean':
233264 // TODO: work with list of true and false values.
 265+ // TODO: i18n
234266 $this->addTypeCriteria( $name, 'in_array', array( 'yes', 'no', 'on', 'off' ) );
235267 break;
236268 case 'char':
@@ -238,13 +270,13 @@
239271 }
240272 }
241273
242 - if ( count( $this->parameterInfo[$name]['type'] ) > 1 && $this->parameterInfo[$name]['type'][1] == 'list' ) {
 274+ if ( count( $this->mParameterInfo[$name]['type'] ) > 1 && $this->mParameterInfo[$name]['type'][1] == 'list' ) {
243275 // Trimming and splitting of list values.
244 - $delimiter = count( $this->parameterInfo[$name]['type'] ) > 2 ? $this->parameterInfo[$name]['type'][2] : ',';
 276+ $delimiter = count( $this->mParameterInfo[$name]['type'] ) > 2 ? $this->mParameterInfo[$name]['type'][2] : ',';
245277 $value = preg_replace( '/((\s)*' . $delimiter . '(\s)*)/', $delimiter, $value );
246278 $value = explode( $delimiter, $value );
247279 }
248 - elseif ( count( $this->parameterInfo[$name]['type'] ) > 1 && $this->parameterInfo[$name]['type'][1] == 'array' && is_array( $value ) ) {
 280+ elseif ( count( $this->mParameterInfo[$name]['type'] ) > 1 && $this->mParameterInfo[$name]['type'][1] == 'array' && is_array( $value ) ) {
249281 // Trimming of array values.
250282 for ( $i = count( $value ); $i > 0; $i-- ) $value[$i] = trim ( $value[$i] );
251283 }
@@ -255,7 +287,7 @@
256288 }
257289
258290 private function addTypeCriteria( $paramName, $criteriaName, $criteriaArgs = array() ) {
259 - $this->parameterInfo[$paramName]['criteria'] = array_merge( array( $criteriaName => $criteriaArgs ), $this->parameterInfo[$paramName]['criteria'] );
 291+ $this->mParameterInfo[$paramName]['criteria'] = array_merge( array( $criteriaName => $criteriaArgs ), $this->mParameterInfo[$paramName]['criteria'] );
260292 }
261293
262294 /**
@@ -270,11 +302,11 @@
271303 $hasNoErrors = true;
272304 $checkItemCriteria = true;
273305
274 - if ( array_key_exists( 'list-criteria', $this->parameterInfo[$name] ) ) {
275 - foreach ( $this->parameterInfo[$name]['list-criteria'] as $criteriaName => $criteriaArgs ) {
 306+ if ( array_key_exists( 'list-criteria', $this->mParameterInfo[$name] ) ) {
 307+ foreach ( $this->mParameterInfo[$name]['list-criteria'] as $criteriaName => $criteriaArgs ) {
276308 // Get the validation function. If there is no matching function, throw an exception.
277 - if ( array_key_exists( $criteriaName, self::$listValidationFunctions ) ) {
278 - $validationFunction = self::$listValidationFunctions[$criteriaName];
 309+ if ( array_key_exists( $criteriaName, self::$mListValidationFunctions ) ) {
 310+ $validationFunction = self::$mListValidationFunctions[$criteriaName];
279311 $isValid = $this->doCriteriaValidation( $validationFunction, $value, $criteriaArgs );
280312
281313 // Add a new error when the validation failed, and break the loop if errors for one parameter should not be accumulated.
@@ -313,10 +345,10 @@
314346 $hasNoErrors = true;
315347
316348 // Go through all item criteria.
317 - foreach ( $this->parameterInfo[$name]['criteria'] as $criteriaName => $criteriaArgs ) {
 349+ foreach ( $this->mParameterInfo[$name]['criteria'] as $criteriaName => $criteriaArgs ) {
318350 // Get the validation function. If there is no matching function, throw an exception.
319 - if ( array_key_exists( $criteriaName, self::$validationFunctions ) ) {
320 - $validationFunction = self::$validationFunctions[$criteriaName];
 351+ if ( array_key_exists( $criteriaName, self::$mValidationFunctions ) ) {
 352+ $validationFunction = self::$mValidationFunctions[$criteriaName];
321353
322354 if ( is_array( $value ) ) {
323355 // Handling of list parameters
@@ -362,8 +394,8 @@
363395 // Add a new error when the validation failed, and break the loop if errors for one parameter should not be accumulated.
364396 if ( ! $isValid ) {
365397 $isList = is_array( $value );
366 - if ( $isList ) $value = $this->rawParameters[$name];
367 - $this->errors[] = array( 'type' => $criteriaName, 'args' => $criteriaArgs, 'name' => $name, 'list' => $isList, 'value' => $value );
 398+ if ( $isList ) $value = $this->mRawParameters[$name];
 399+ $this->mErrors[] = array( 'type' => $criteriaName, 'args' => $criteriaArgs, 'name' => $name, 'list' => $isList, 'value' => $value );
368400 $hasNoErrors = false;
369401 if ( ! self::$accumulateParameterErrors ) break;
370402 }
@@ -395,19 +427,18 @@
396428 * Changes the invalid parameters to their default values, and changes their state to valid.
397429 */
398430 public function correctInvalidParams() {
399 - foreach ( $this->invalid as $paramName => $paramValue ) {
400 - unset( $this->invalid[$paramName] );
401 - $this->valid[$paramName] = array_key_exists( 'default', $this->parameterInfo[$paramName] ) ? $this->parameterInfo[$paramName]['default'] : '';
402 - $this->setOutputTypes( $this->valid[$paramName], $this->parameterInfo[$paramName] );
 431+ foreach ( $this->mInvalidParams as $paramName => $paramValue ) {
 432+ unset( $this->mInvalidParams[$paramName] );
 433+ $this->mValidParams[$paramName] = array_key_exists( 'default', $this->mParameterInfo[$paramName] ) ? $this->mParameterInfo[$paramName]['default'] : '';
 434+ $this->setOutputTypes( $this->mValidParams[$paramName], $this->mParameterInfo[$paramName] );
403435 }
404436 }
405437
406438 /**
407439 * Ensures the output type values are arrays, and then calls setOutputType.
408440 *
409 - * @param array $value
410 - * @param $info
411 - * @return unknown_type
 441+ * @param $value
 442+ * @param array $info
412443 */
413444 private function setOutputTypes( &$value, array $info ) {
414445 if ( array_key_exists( 'output-types', $info ) ) {
@@ -434,9 +465,9 @@
435466 // The remaining ones will be any extra arguments.
436467 $outputType = strtolower( array_shift( $typeInfo ) );
437468
438 - if ( array_key_exists( $outputType, self::$outputFormats ) ) {
 469+ if ( array_key_exists( $outputType, self::$mOutputFormats ) ) {
439470 // Call the formatting function with as first parameter the value, followed by the extra arguments.
440 - call_user_func_array( self::$outputFormats[$outputType], array_merge( array( &$value ), $typeInfo ) );
 471+ call_user_func_array( self::$mOutputFormats[$outputType], array_merge( array( &$value ), $typeInfo ) );
441472 }
442473 else {
443474 throw new Exception( 'There is no formatting function for output format ' . $outputType );
@@ -449,7 +480,7 @@
450481 * @return array
451482 */
452483 public function getValidParams() {
453 - return $this->valid;
 484+ return $this->mValidParams;
454485 }
455486
456487 /**
@@ -458,7 +489,7 @@
459490 * @return array
460491 */
461492 public static function getUnknownParams() {
462 - return $this->unknown;
 493+ return $this->mUnknownParams;
463494 }
464495
465496 /**
@@ -467,7 +498,7 @@
468499 * @return array
469500 */
470501 public function getErrors() {
471 - return $this->errors;
 502+ return $this->mErrors;
472503 }
473504
474505 /**
@@ -479,7 +510,7 @@
480511 * if it's in a class, first the class name, then the method name.
481512 */
482513 public static function addValidationFunction( $criteriaName, array $functionName ) {
483 - self::$validationFunctions[$criteriaName] = $functionName;
 514+ self::$mValidationFunctions[$criteriaName] = $functionName;
484515 }
485516
486517 /**
@@ -491,7 +522,7 @@
492523 * if it's in a class, first the class name, then the method name.
493524 */
494525 public static function addListValidationFunction( $criteriaName, array $functionName ) {
495 - self::$listValidationFunctions[$criteriaName] = $functionName;
 526+ self::$mListValidationFunctions[$criteriaName] = $functionName;
496527 }
497528
498529 /**
@@ -503,6 +534,6 @@
504535 * if it's in a class, first the class name, then the method name.
505536 */
506537 public static function addOutputFormat( $formatName, array $functionName ) {
507 - self::$outputFormats[$formatName] = $functionName;
 538+ self::$mOutputFormats[$formatName] = $functionName;
508539 }
509540 }
\ No newline at end of file
Index: trunk/extensions/Validator/Validator_Manager.php
@@ -19,6 +19,10 @@
2020 * @ingroup Validator
2121 *
2222 * @author Jeroen De Dauw
 23+ *
 24+ * FIXME: missing params should result in a no-go, no matter of the error level, as they can/are not defaulted.
 25+ *
 26+ * TODO: make a distinction between fatal errors and regular errors by using 2 seperate error levels.
2327 */
2428 final class ValidatorManager {
2529
@@ -29,44 +33,64 @@
3034 *
3135 * @param array $rawParameters The raw parameters, as provided by the user.
3236 * @param array $parameterInfo Array containing the parameter definitions, which are needed for validation and defaulting.
33 - *
 37+ * @param array $defaultParams
3438 * @return array or false The valid parameters or false when the output should not be shown.
3539 */
36 - public function manageMapparameters( array $rawParameters, array $parameterInfo ) {
 40+ public function manageMapparameters( array $rawParameters, array $parameterInfo, array $defaultParams = array() ) {
3741 global $egValidatorErrorLevel;
3842
3943 $validator = new Validator();
4044
4145 $validator->setParameterInfo( $parameterInfo );
42 - $validator->setParameters( $rawParameters );
 46+ $validator->parseAndSetParams( $rawParameters, $defaultParams );
4347
44 - if ( ! $validator->validateParameters() ) {
45 - if ( $egValidatorErrorLevel != Validator_ERRORS_STRICT ) $validator->correctInvalidParams();
 48+ $hasNoErrors = $validator->validateParameters();
 49+ $hasFatalError = $hasNoErrors ? false : $this->hasFatalError();
 50+
 51+ if ( !$hasNoErrors ) {
 52+ if ( $egValidatorErrorLevel < Validator_ERRORS_STRICT ) $validator->correctInvalidParams();
4653 if ( $egValidatorErrorLevel >= Validator_ERRORS_WARN ) $this->errors = $validator->getErrors();
4754 }
 55+
 56+ return !$hasFatalError ? $validator->getValidParams() : false;
 57+ }
4858
49 - $showOutput = ! ( $egValidatorErrorLevel == Validator_ERRORS_STRICT && count( $this->errors ) > 0 );
 59+ /**
 60+ * Returns wether there are any fatal errors. Fatal errors are either missing or invalid required parameters,
 61+ * or simply any sort of error when the validation level is equal to (or bigger then) Validator_ERRORS_STRICT.
 62+ *
 63+ * Note: This function assumes it will only get called when there are errors. It will always return true
 64+ * when $egValidatorErrorLevel is Validator_ERRORS_STRICT or above.
 65+ *
 66+ * @return boolean
 67+ */
 68+ private function hasFatalError() {
 69+ global $egValidatorErrorLevel;
 70+ $has = $egValidatorErrorLevel >= Validator_ERRORS_STRICT;
 71+
 72+ if ( !$has ) {
 73+ foreach ( $this->errors as $error ) {
 74+ if ( $error['type'] == 'missing' ) {
 75+ $has = true;
 76+ break;
 77+ }
 78+ }
 79+ }
5080
51 - return $showOutput ? $validator->getValidParams() : false;
 81+ return $has;
5282 }
53 -
 83+
5484 /**
5585 * Returns a string containing an HTML error list, or an empty string when there are no errors.
5686 *
5787 * @return string
5888 */
59 - public function getErrorList( $errorLevel = null ) {
60 - global $wgLang;
61 -
62 - $error_count = count( $this->errors ) ;
 89+ public function getErrorList() {
 90+ global $wgLang, $egValidatorErrorLevel;
 91+ $errorCount = count( $this->errors ) ;
6392
64 - if ( is_null( $errorLevel ) ) {
65 - global $egValidatorErrorLevel;
66 - $errorLevel = $egValidatorErrorLevel;
67 - }
68 -
69 - if ( $errorLevel >= Validator_ERRORS_SHOW && $error_count > 0 ) {
70 - $errorList = '<b>' . wfMsgExt( 'validator_error_parameters', 'parsemag', $error_count ) . '</b><br /><i>';
 93+ if ( $egValidatorErrorLevel >= Validator_ERRORS_SHOW && $errorCount > 0 ) {
 94+ $errorList = '<b>' . wfMsgExt( 'validator_error_parameters', 'parsemag', $errorCount ) . '</b><br /><i>';
7195
7296 $errors = array();
7397
@@ -138,8 +162,8 @@
139163
140164 return $errorList . implode( $errors, '<br />' ) . '</i><br />';
141165 }
142 - elseif ( $errorLevel == Validator_ERRORS_WARN && $error_count > 0 ) {
143 - return '<b>' . wfMsgExt( 'validator_warning_parameters', array( 'parsemag' ), $error_count ) . '</b>';
 166+ elseif ( $egValidatorErrorLevel == Validator_ERRORS_WARN && $errorCount > 0 ) {
 167+ return '<b>' . wfMsgExt( 'validator_warning_parameters', array( 'parsemag' ), $errorCount ) . '</b>';
144168 }
145169 else {
146170 return '';
Index: trunk/extensions/Validator/INSTALL
@@ -1,6 +1,6 @@
2 -[[Validator 0.2.2]]
 2+[[Validator 0.3]]
33
4 -Once you have downloaded the code, place the 'SemanticMaps' directory within
 4+Once you have downloaded the code, place the 'Validator' directory within
55 your MediaWiki 'extensions' directory. Then add the following code to your
66 LocalSettings.php file BEFORE the inclusion of any extensions using Validator:
77
Index: trunk/extensions/Validator/Validator.php
@@ -24,11 +24,10 @@
2525 die( 'Not an entry point.' );
2626 }
2727
28 -define( 'Validator_VERSION', '0.2.3 a1' );
 28+define( 'Validator_VERSION', '0.3 a1' );
2929
3030 // Constants indicating the strictness of the parameter validation.
3131 define( 'Validator_ERRORS_NONE', 0 );
32 -define( 'Validator_ERRORS_MINIMAL', 1 );
3332 define( 'Validator_ERRORS_WARN', 2 );
3433 define( 'Validator_ERRORS_SHOW', 3 );
3534 define( 'Validator_ERRORS_STRICT', 4 );
Index: trunk/extensions/Validator/Validator_Settings.php
@@ -18,9 +18,16 @@
1919 }
2020
2121 # Integer. The strictness of the parameter validation and resulting error report when using the ValidatorManager class.
 22+# This value also affects the error messages native to extensions that integrate Validator correctly.
2223 # Validator_ERRORS_NONE : Validator will not show any errors, and make the best of the input it got.
23 -# Validator_ERRORS_MINIMAL : Validator will only show a warning when the output could not be generated.
2424 # Validator_ERRORS_WARN : Validator will make the best of the input it got, but will show a warning that there are errors.
2525 # Validator_ERRORS_SHOW : Validator will make the best of the input it got, but will show a list of all errors.
2626 # Validator_ERRORS_STRICT : Validator will only show regular output when there are no errors, if there are, a list of them will be shown.
27 -$egValidatorErrorLevel = Validator_ERRORS_SHOW;
\ No newline at end of file
 27+$egValidatorErrorLevel = Validator_ERRORS_SHOW;
 28+
 29+# Integer. The strictness of the parameter validation and resulting error report when using the ValidatorManager class.
 30+# This value also affects the error messages native to extensions that integrate Validator correctly.
 31+# Validator_ERRORS_NONE : Validator will not show any errors, and make the best of the input it got, if possible.
 32+# Validator_ERRORS_WARN : Validator will make the best of the input it got, but will show a warning that there are errors.
 33+# Validator_ERRORS_SHOW : Validator will make the best of the input it got, but will show a list of all errors.
 34+$egValidatorFatalLevel = Validator_ERRORS_SHOW;
\ No newline at end of file

Status & tagging log