Index: trunk/extensions/Validator/INSTALL |
— | — | @@ -1,4 +1,4 @@ |
2 | | -[[Validator 0.4]] |
| 2 | +[[Validator 0.4.1]] |
3 | 3 | |
4 | 4 | Once you have downloaded the code, place the 'Validator' directory within |
5 | 5 | your MediaWiki 'extensions' directory. Then add the following code to your |
Index: trunk/extensions/Validator/RELEASE-NOTES |
— | — | @@ -12,15 +12,15 @@ |
13 | 13 | ==== New features ==== |
14 | 14 | |
15 | 15 | * Added ParserHook class that allows for out-of-the-box parser function and tag extension creation |
16 | | - with full Validator support. |
| 16 | +: with full Validator support. |
17 | 17 | |
18 | | -* Added listerrors parser hook that allows you to list all validation errors that occured at the point it's rendered. |
| 18 | +* Added listerrors parser hook that allows you to list all validation errors that occurred at the point it's rendered. |
19 | 19 | |
20 | 20 | * Added support for conditional parameter adding. |
21 | 21 | |
22 | 22 | ==== Refactoring ==== |
23 | 23 | |
24 | | -Bascially everything got rewritten... |
| 24 | +Basically everything got rewritten... |
25 | 25 | |
26 | 26 | * Added Parameter and ListParameter classes to replace parameter definitions in array form. |
27 | 27 | |
Index: trunk/extensions/Validator/includes/ValidationError.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | * |
38 | 38 | * @var array |
39 | 39 | */ |
40 | | - public $tags; |
| 40 | + protected $tags; |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Where the error occured. |
— | — | @@ -61,6 +61,18 @@ |
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
| 65 | + * Adds one or more tags. |
| 66 | + * |
| 67 | + * @since 0.4.1 |
| 68 | + * |
| 69 | + * @param mixed $criteria string or array of string |
| 70 | + */ |
| 71 | + public function addTags() { |
| 72 | + $args = func_get_args(); |
| 73 | + $this->tags += is_array( $args[0] ) ? $args[0] : $args; |
| 74 | + } |
| 75 | + |
| 76 | + /** |
65 | 77 | * Returns the error message describing the error. |
66 | 78 | * |
67 | 79 | * @since 0.4 |
— | — | @@ -98,6 +110,8 @@ |
99 | 111 | * |
100 | 112 | * @since 0.4 |
101 | 113 | * |
| 114 | + * @param integer $severity |
| 115 | + * |
102 | 116 | * @return boolean |
103 | 117 | */ |
104 | 118 | public function hasSeverity( $severity ) { |
— | — | @@ -105,6 +119,30 @@ |
106 | 120 | } |
107 | 121 | |
108 | 122 | /** |
| 123 | + * Returns if the error has a certain tag. |
| 124 | + * |
| 125 | + * @since 0.4.1 |
| 126 | + * |
| 127 | + * @param string $tag |
| 128 | + * |
| 129 | + * @return boolean |
| 130 | + */ |
| 131 | + public function hasTag( $tag ) { |
| 132 | + return in_array( $tag, $this->tags ); |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Returns the tags. |
| 137 | + * |
| 138 | + * @since 0.4.1 |
| 139 | + * |
| 140 | + * @return array |
| 141 | + */ |
| 142 | + public function getTags() { |
| 143 | + return $this->tags; |
| 144 | + } |
| 145 | + |
| 146 | + /** |
109 | 147 | * Returns the action associated with the errors severity. |
110 | 148 | * |
111 | 149 | * @since 0.4 |
Index: trunk/extensions/Validator/includes/CriterionValidationResult.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | /** |
24 | 24 | * @since 0.4 |
25 | 25 | * |
26 | | - * @var unknown_type |
| 26 | + * @var array of string |
27 | 27 | */ |
28 | 28 | protected $invalidItems = array(); |
29 | 29 | |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | * @since 0.4 |
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | | - |
| 36 | + |
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
Index: trunk/extensions/Validator/includes/Parameter.php |
— | — | @@ -326,7 +326,7 @@ |
327 | 327 | */ |
328 | 328 | public function addAliases() { |
329 | 329 | $args = func_get_args(); |
330 | | - $this->aliases = array_merge( $this->aliases, is_array( $args[0] ) ? $args[0] : $args ); |
| 330 | + $this->aliases += is_array( $args[0] ) ? $args[0] : $args; |
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
— | — | @@ -338,7 +338,7 @@ |
339 | 339 | */ |
340 | 340 | public function addCriteria() { |
341 | 341 | $args = func_get_args(); |
342 | | - $this->criteria = array_merge( $this->criteria, is_array( $args[0] ) ? $args[0] : $args ); |
| 342 | + $this->criteria += is_array( $args[0] ) ? $args[0] : $args; |
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
— | — | @@ -351,7 +351,7 @@ |
352 | 352 | */ |
353 | 353 | public function addDependencies() { |
354 | 354 | $args = func_get_args(); |
355 | | - $this->dependencies = array_merge( $this->dependencies, is_array( $args[0] ) ? $args[0] : $args ); |
| 355 | + $this->dependencies += is_array( $args[0] ) ? $args[0] : $args; |
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
— | — | @@ -363,7 +363,7 @@ |
364 | 364 | */ |
365 | 365 | public function addManipulations( $manipulations ) { |
366 | 366 | $args = func_get_args(); |
367 | | - $this->manipulations = array_merge( $this->manipulations, is_array( $args[0] ) ? $args[0] : $args ); |
| 367 | + $this->manipulations += is_array( $args[0] ) ? $args[0] : $args; |
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
— | — | @@ -523,7 +523,10 @@ |
524 | 524 | * @param CriterionValidationResult $validationResult |
525 | 525 | */ |
526 | 526 | protected function handleValidationError( CriterionValidationResult $validationResult ) { |
527 | | - $this->errors = array_merge( $this->errors, $validationResult->getErrors() ); |
| 527 | + foreach ( $validationResult->getErrors() as $error ) { |
| 528 | + $error->addTags( $this->getName() ); |
| 529 | + $this->errors[] = $error; |
| 530 | + } |
528 | 531 | } |
529 | 532 | |
530 | 533 | /** |
Index: trunk/extensions/Validator/includes/Validator.php |
— | — | @@ -229,7 +229,8 @@ |
230 | 230 | // These are unrecognized parameters, as they where not used by any parameter definition. |
231 | 231 | foreach ( $this->rawParameters as $paramName => $paramValue ) { |
232 | 232 | $this->registerNewError( |
233 | | - wfMsgExt( 'validator_error_unknown_argument', 'parsemag', $paramName ) |
| 233 | + wfMsgExt( 'validator_error_unknown_argument', 'parsemag', $paramName ), |
| 234 | + $paramName |
234 | 235 | ); |
235 | 236 | } |
236 | 237 | } |
— | — | @@ -252,7 +253,7 @@ |
253 | 254 | if ( !$setUservalue && $parameter->isRequired() ) { |
254 | 255 | $this->registerNewError( |
255 | 256 | wfMsgExt( 'validator_error_required_missing', 'parsemag', $paramName ), |
256 | | - array(), |
| 257 | + array( $paramName, 'missing' ), |
257 | 258 | ValidationError::SEVERITY_FATAL |
258 | 259 | ); |
259 | 260 | break; |
Index: trunk/extensions/Validator/Validator.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | die( 'Not an entry point.' ); |
26 | 26 | } |
27 | 27 | |
28 | | -define( 'Validator_VERSION', '0.4' ); |
| 28 | +define( 'Validator_VERSION', '0.4.1 alpha' ); |
29 | 29 | |
30 | 30 | // Register the internationalization file. |
31 | 31 | $wgExtensionMessagesFiles['Validator'] = dirname( __FILE__ ) . '/Validator.i18n.php'; |