Index: trunk/extensions/Validator/Validator.class.php |
— | — | @@ -20,8 +20,13 @@ |
21 | 21 | * |
22 | 22 | * @author Jeroen De Dauw |
23 | 23 | * |
24 | | - * TODO: add a way to use parameter values in the validation/formatting of other parameters. |
25 | | - * This will also require new syntax to order the handling of the defined parameters. |
| 24 | + * TODO: add dependency system |
| 25 | + * * find out how to decompress dependency tree in an efficient way |
| 26 | + * * handle params in the determined order and make meta data available for sucessive ones |
| 27 | + * TODO: provide all original and inferred info about a parameter pair to the validation and formatting functions. |
| 28 | + * this will allow for the special behaviour of the default parameter of display_points in Maps |
| 29 | + * where the actual alias influences the handling |
| 30 | + * TODO: break on fatal errors, such as missing required parameters that are dependencies |
26 | 31 | */ |
27 | 32 | final class Validator { |
28 | 33 | |
— | — | @@ -50,6 +55,18 @@ |
51 | 56 | public static $perItemValidation = true; |
52 | 57 | |
53 | 58 | /** |
| 59 | + * @var mixed The default value for parameters the user did not set and do not have their own |
| 60 | + * default specified. |
| 61 | + */ |
| 62 | + public static $defaultDefaultValue = ''; |
| 63 | + |
| 64 | + /** |
| 65 | + * @var string The default delimiter for lists, used when the parameter definition does not |
| 66 | + * specify one. |
| 67 | + */ |
| 68 | + public static $defaultListDelimeter = ','; |
| 69 | + |
| 70 | + /** |
54 | 71 | * @var array Holder for the validation functions. |
55 | 72 | */ |
56 | 73 | private static $mValidationFunctions = array( |
— | — | @@ -106,53 +123,59 @@ |
107 | 124 | } |
108 | 125 | |
109 | 126 | /** |
110 | | - * Sets the raw parameters that will be validated when validateParameters is called. |
111 | | - * |
112 | | - * @param array $parameters |
113 | | - */ |
114 | | - public function setParameters( array $parameters ) { |
115 | | - $this->mRawParameters = $parameters; |
116 | | - } |
117 | | - |
118 | | - /** |
119 | 127 | * Determine all parameter names and value, and take care of default (nameless) |
120 | 128 | * parameters, by turning them into named ones. |
121 | 129 | * |
122 | 130 | * @param array $rawParams |
123 | 131 | * @param array $defaultParams |
| 132 | + * |
| 133 | + * TODO: retain info about the changing of defaults |
124 | 134 | */ |
125 | 135 | public function parseAndSetParams( array $rawParams, array $defaultParams = array() ) { |
126 | 136 | $parameters = array(); |
127 | 137 | |
128 | | - foreach( $rawParams as $arg ) { |
| 138 | + $nr = 0; |
| 139 | + $defaultNr = 0; |
| 140 | + |
| 141 | + foreach ( $rawParams as $arg ) { |
129 | 142 | // Only take into account strings. If the value is not a string, |
130 | 143 | // it is not a raw parameter, and can not be parsed correctly in all cases. |
131 | 144 | if ( is_string( $arg ) ) { |
132 | 145 | $parts = explode( '=', $arg ); |
133 | 146 | if ( count( $parts ) == 1 ) { |
134 | 147 | if ( count( $defaultParams ) > 0 ) { |
135 | | - $defaultParam = array_shift( $defaultParams ); |
136 | | - $parameters[$defaultParam] = trim( $parts[0] ); |
| 148 | + $defaultParam = array_shift( $defaultParams ); |
| 149 | + $parameters[$defaultParam] = array( |
| 150 | + 'value' => trim( $parts[0] ), |
| 151 | + 'default' => $defaultNr, |
| 152 | + 'position' => $nr |
| 153 | + ); |
| 154 | + $defaultNr++; |
137 | 155 | } |
138 | 156 | } else { |
139 | 157 | $name = strtolower( trim( array_shift( $parts ) ) ); |
140 | | - $parameters[$name] = trim( implode( '=', $parts ) ); |
141 | | - } |
| 158 | + $parameters[$name] = array( |
| 159 | + 'value' => trim( implode( '=', $parts ) ), |
| 160 | + 'default' => false, |
| 161 | + 'position' => $nr |
| 162 | + ); |
| 163 | + } |
142 | 164 | } |
| 165 | + $nr++; |
143 | 166 | } |
144 | 167 | |
145 | | - $this->setParameters( $parameters ); |
| 168 | + $this->mRawParameters = $parameters; |
146 | 169 | } |
147 | 170 | |
148 | 171 | /** |
149 | | - * Valides the raw parameters, and allocates them as valid, invalid or unknown. |
150 | | - * Errors are collected, and can be retrieved via getErrors. |
151 | | - * |
152 | | - * @return boolean Indicates whether there where NO errors. |
| 172 | + * @new |
| 173 | + * |
| 174 | + * TODO: merge meta data and value arrays |
153 | 175 | */ |
154 | | - public function validateParameters() { |
| 176 | + public function validateAndFormatParameters() { |
155 | 177 | // Loop through all the user provided parameters, and destinguise between those that are allowed and those that are not. |
156 | | - foreach ( $this->mRawParameters as $paramName => $paramValue ) { |
| 178 | + foreach ( $this->mRawParameters as $paramName => $paramData ) { |
| 179 | + $paramValue = $paramData['value']; |
157 | 180 | // Attempt to get the main parameter name (takes care of aliases). |
158 | 181 | $mainName = self::getMainParamName( $paramName ); |
159 | 182 | // If the parameter is found in the list of allowed ones, add it to the $mParameters array. |
— | — | @@ -160,7 +183,12 @@ |
161 | 184 | // Check for parameter overriding. In most cases, this has already largely been taken care off, |
162 | 185 | // in the form of later parameters overriding earlier ones. This is not true for different aliases though. |
163 | 186 | if ( !array_key_exists( $mainName, $this->mParameters ) || self::$acceptOverriding ) { |
164 | | - $this->mParameters[$mainName] = $paramValue; |
| 187 | + $this->mParameters[$mainName] = array( |
| 188 | + 'value' => $paramValue, |
| 189 | + 'original-name' => $paramName, |
| 190 | + 'default' => $paramData['default'], |
| 191 | + 'position' => $paramData['position'] |
| 192 | + ); |
165 | 193 | } |
166 | 194 | else { |
167 | 195 | $this->errors[] = array( 'type' => 'override', 'name' => $mainName ); |
— | — | @@ -171,16 +199,27 @@ |
172 | 200 | $this->mErrors[] = array( 'type' => 'unknown', 'name' => $paramName ); |
173 | 201 | } |
174 | 202 | } |
| 203 | + |
| 204 | + $dependencyList = array(); |
| 205 | + |
| 206 | + foreach ( $this->mParameterInfo as $paramName => $paramInfo ) { |
| 207 | + $dependencyList[$paramName] = array_key_exists( 'dependencies', $paramInfo ) ? |
| 208 | + (array)$paramInfo['dependencies'] : array(); |
| 209 | + } |
| 210 | + |
| 211 | + $sorter = new TopologicalSort( $dependencyList, true ); |
| 212 | + $orderedParameters = $sorter->doSort(); |
175 | 213 | |
176 | | - // Loop through the list of allowed parameters. |
177 | | - foreach ( $this->mParameterInfo as $paramName => $paramInfo ) { |
| 214 | + foreach ( $orderedParameters as $paramName ) { |
| 215 | + $paramInfo = $this->mParameterInfo[$paramName]; |
| 216 | + |
178 | 217 | // If the user provided a value for this parameter, validate and handle it. |
179 | 218 | if ( array_key_exists( $paramName, $this->mParameters ) ) { |
180 | 219 | |
181 | | - $paramValue = $this->mParameters[$paramName]; |
| 220 | + $paramValue = $this->mParameters[$paramName]['value']; |
182 | 221 | $this->cleanParameter( $paramName, $paramValue ); |
183 | 222 | |
184 | | - if ( $this->validateParameter( $paramName, $paramValue ) ) { |
| 223 | + if ( $this->validateParameter( $paramName ) ) { |
185 | 224 | // If the validation succeeded, add the parameter to the list of valid ones. |
186 | 225 | $this->mValidParams[$paramName] = $paramValue; |
187 | 226 | $this->setOutputTypes( $this->mValidParams[$paramName], $paramInfo ); |
— | — | @@ -197,13 +236,11 @@ |
198 | 237 | } |
199 | 238 | else { |
200 | 239 | // Set the default value (or default 'default value' if none is provided), and ensure the type is correct. |
201 | | - $this->mValidParams[$paramName] = array_key_exists( 'default', $paramInfo ) ? $paramInfo['default'] : ''; |
| 240 | + $this->mValidParams[$paramName] = array_key_exists( 'default', $paramInfo ) ? $paramInfo['default'] : self::$defaultDefaultValue; |
202 | 241 | $this->setOutputTypes( $this->mValidParams[$paramName], $paramInfo ); |
203 | 242 | } |
204 | 243 | } |
205 | 244 | } |
206 | | - |
207 | | - return count( $this->mErrors ) == 0; |
208 | 245 | } |
209 | 246 | |
210 | 247 | /** |
— | — | @@ -233,7 +270,7 @@ |
234 | 271 | } |
235 | 272 | |
236 | 273 | /** |
237 | | - * Ensures the parameter info is valid, trims the value, and splits lists. |
| 274 | + * Ensures the parameter info is valid, and splits lists. |
238 | 275 | * |
239 | 276 | * @param string $name |
240 | 277 | * @param $value |
— | — | @@ -260,10 +297,10 @@ |
261 | 298 | break; |
262 | 299 | case 'float': |
263 | 300 | $this->addTypeCriteria( $name, 'is_float' ); |
264 | | - break; |
| 301 | + break; |
265 | 302 | case 'number': // Note: This accepts non-decimal notations! |
266 | 303 | $this->addTypeCriteria( $name, 'is_numeric' ); |
267 | | - break; |
| 304 | + break; |
268 | 305 | case 'boolean': |
269 | 306 | // TODO: work with list of true and false values. |
270 | 307 | // TODO: i18n |
— | — | @@ -277,7 +314,7 @@ |
278 | 315 | |
279 | 316 | if ( count( $this->mParameterInfo[$name]['type'] ) > 1 && $this->mParameterInfo[$name]['type'][1] == 'list' ) { |
280 | 317 | // Trimming and splitting of list values. |
281 | | - $delimiter = count( $this->mParameterInfo[$name]['type'] ) > 2 ? $this->mParameterInfo[$name]['type'][2] : ','; |
| 318 | + $delimiter = count( $this->mParameterInfo[$name]['type'] ) > 2 ? $this->mParameterInfo[$name]['type'][2] : self::$defaultListDelimeter; |
282 | 319 | $value = preg_replace( '/((\s)*' . $delimiter . '(\s)*)/', $delimiter, $value ); |
283 | 320 | $value = explode( $delimiter, $value ); |
284 | 321 | } |
— | — | @@ -285,10 +322,6 @@ |
286 | 323 | // Trimming of array values. |
287 | 324 | for ( $i = count( $value ); $i > 0; $i-- ) $value[$i] = trim ( $value[$i] ); |
288 | 325 | } |
289 | | - else { |
290 | | - // Trimming of non-list values. |
291 | | - $value = trim ( $value ); |
292 | | - } |
293 | 326 | } |
294 | 327 | |
295 | 328 | private function addTypeCriteria( $paramName, $criteriaName, $criteriaArgs = array() ) { |
— | — | @@ -299,20 +332,23 @@ |
300 | 333 | * Valides the provided parameter by matching the value against the list and item criteria for the name. |
301 | 334 | * |
302 | 335 | * @param string $name |
303 | | - * @param string $value |
304 | 336 | * |
305 | 337 | * @return boolean Indicates whether there the parameter value(s) is/are valid. |
| 338 | + * |
| 339 | + * TODO: value was byref arg for some reason - this could break stuff |
306 | 340 | */ |
307 | | - private function validateParameter( $name, &$value ) { |
| 341 | + private function validateParameter( $name ) { |
308 | 342 | $hasNoErrors = true; |
309 | 343 | $checkItemCriteria = true; |
310 | 344 | |
| 345 | + $value = $this->mParameters[$name]['value']; |
| 346 | + |
311 | 347 | if ( array_key_exists( 'list-criteria', $this->mParameterInfo[$name] ) ) { |
312 | 348 | foreach ( $this->mParameterInfo[$name]['list-criteria'] as $criteriaName => $criteriaArgs ) { |
313 | 349 | // Get the validation function. If there is no matching function, throw an exception. |
314 | 350 | if ( array_key_exists( $criteriaName, self::$mListValidationFunctions ) ) { |
315 | 351 | $validationFunction = self::$mListValidationFunctions[$criteriaName]; |
316 | | - $isValid = $this->doCriteriaValidation( $validationFunction, $value, $criteriaArgs ); |
| 352 | + $isValid = $this->doCriteriaValidation( $validationFunction, $value, array(), $criteriaArgs ); |
317 | 353 | |
318 | 354 | // Add a new error when the validation failed, and break the loop if errors for one parameter should not be accumulated. |
319 | 355 | if ( ! $isValid ) { |
— | — | @@ -362,7 +398,7 @@ |
363 | 399 | |
364 | 400 | // Loop through all the items in the parameter value, and validate them. |
365 | 401 | foreach ( $value as $item ) { |
366 | | - $isValid = $this->doCriteriaValidation( $validationFunction, $item, $criteriaArgs ); |
| 402 | + $isValid = $this->doCriteriaValidation( $validationFunction, $item, array(), $criteriaArgs ); |
367 | 403 | if ( $isValid ) { |
368 | 404 | // If per item validation is on, store the valid items, so only these can be returned by Validator. |
369 | 405 | if ( self::$perItemValidation ) $validItems[] = $item; |
— | — | @@ -393,16 +429,16 @@ |
394 | 430 | } |
395 | 431 | else { |
396 | 432 | // Determine if the value is valid for single valued parameters. |
397 | | - $isValid = $this->doCriteriaValidation( $validationFunction, $value, $criteriaArgs ); |
| 433 | + $isValid = $this->doCriteriaValidation( $validationFunction, $value, array(), $criteriaArgs ); |
398 | 434 | } |
399 | 435 | |
400 | 436 | // Add a new error when the validation failed, and break the loop if errors for one parameter should not be accumulated. |
401 | | - if ( ! $isValid ) { |
| 437 | + if ( !$isValid ) { |
402 | 438 | $isList = is_array( $value ); |
403 | 439 | if ( $isList ) $value = $this->mRawParameters[$name]; |
404 | 440 | $this->mErrors[] = array( 'type' => $criteriaName, 'args' => $criteriaArgs, 'name' => $name, 'list' => $isList, 'value' => $value ); |
405 | 441 | $hasNoErrors = false; |
406 | | - if ( ! self::$accumulateParameterErrors ) break; |
| 442 | + if ( !self::$accumulateParameterErrors ) break; |
407 | 443 | } |
408 | 444 | } |
409 | 445 | else { |
— | — | @@ -419,13 +455,14 @@ |
420 | 456 | * |
421 | 457 | * @param $validationFunction |
422 | 458 | * @param $value |
423 | | - * @param $criteriaArgs |
| 459 | + * @param array $metaData |
| 460 | + * @param array $criteriaArgs |
424 | 461 | * |
425 | 462 | * @return boolean |
426 | 463 | */ |
427 | | - private function doCriteriaValidation( $validationFunction, $value, $criteriaArgs ) { |
| 464 | + private function doCriteriaValidation( $validationFunction, $value, array $metaData, array $criteriaArgs ) { |
428 | 465 | // Call the validation function and store the result. |
429 | | - return call_user_func_array( $validationFunction, array_merge( array( $value ), $criteriaArgs ) ); |
| 466 | + return call_user_func_array( $validationFunction, array_merge( array_merge( array( $value ), $metaData), $criteriaArgs ) ); |
430 | 467 | } |
431 | 468 | |
432 | 469 | /** |
Index: trunk/extensions/Validator/Validator_Manager.php |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | * |
22 | 22 | * @author Jeroen De Dauw |
23 | 23 | * |
24 | | - * FIXME: missing params should result in a no-go, no matter of the error level, as they can/are not defaulted. |
| 24 | + * FIXME: missing required params should result in a no-go, no matter of the error level, as they can/are not defaulted. |
25 | 25 | * |
26 | 26 | * TODO: make a distinction between fatal errors and regular errors by using 2 seperate error levels. |
27 | 27 | */ |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | $validator->setParameterInfo( $parameterInfo ); |
47 | 47 | $validator->parseAndSetParams( $rawParameters, $defaultParams ); |
48 | 48 | |
49 | | - $hasNoErrors = $validator->validateParameters(); |
| 49 | + $hasNoErrors = $validator->validateAndFormatParameters(); |
50 | 50 | $hasFatalError = $hasNoErrors ? false : $this->hasFatalError(); |
51 | 51 | |
52 | 52 | if ( !$hasNoErrors ) { |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | $has = true; |
77 | 77 | break; |
78 | 78 | } |
79 | | - } |
| 79 | + } |
80 | 80 | } |
81 | 81 | |
82 | 82 | return $has; |
Index: trunk/extensions/Validator/TopologicalSort.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | * |
9 | 9 | * usage: |
10 | 10 | * $t = new TopologicalSort($dependency_pairs); |
11 | | - * $load_order = $t->tsort(); |
| 11 | + * $load_order = $t->doSort(); |
12 | 12 | * |
13 | 13 | * where dependency_pairs is in the form: |
14 | 14 | * $name => (depends on) $value |
— | — | @@ -20,79 +20,92 @@ |
21 | 21 | * TODO: Use in revised version of Validator class |
22 | 22 | */ |
23 | 23 | class TopologicalSort { |
24 | | - var $nodes = array (); |
25 | 24 | |
| 25 | + private $nodes = array(); |
| 26 | + private $looseNodes = array(); |
| 27 | + |
26 | 28 | /** |
27 | 29 | * Dependency pairs are a list of arrays in the form |
28 | 30 | * $name => $val where $key must come before $val in load order. |
29 | 31 | */ |
30 | | - function TopologicalSort($dependencies = array(), $parse = false) { |
31 | | - if ($parse) { |
32 | | - $dependencies = $this->parseDependencyList ( $dependencies ); |
| 32 | + function TopologicalSort( $dependencies = array(), $parse = true ) { |
| 33 | + $rawDependencies = $dependencies; |
| 34 | + |
| 35 | + if ( $parse ) { |
| 36 | + $dependencies = $this->parseDependencyList( $dependencies ); |
33 | 37 | } |
34 | | - |
| 38 | + |
| 39 | + // Store items that have no dependencies, and therefore no nodes. |
| 40 | + foreach( $rawDependencies as $item => $dependency ) { |
| 41 | + if ( !in_array( $item, $dependencies ) && !array_key_exists( $item, $dependencies ) ) { |
| 42 | + $this->looseNodes[] = $item; |
| 43 | + } |
| 44 | + } |
| 45 | + |
35 | 46 | // turn pairs into double-linked node tree |
36 | 47 | foreach ( $dependencies as $key => $dpair ) { |
37 | 48 | list ( $module, $dependency ) = each ( $dpair ); |
38 | | - if ( !isset ( $this->nodes [$module] )) $this->nodes [$module] = new TSNode ( $module ); |
39 | | - if ( !isset ( $this->nodes [$dependency] )) $this->nodes [$dependency] = new TSNode ( $dependency ); |
40 | | - if ( !in_array ( $dependency, $this->nodes [$module]->children )) $this->nodes [$module]->children [] = $dependency; |
41 | | - if ( !in_array ( $module, $this->nodes [$dependency]->parents )) $this->nodes [$dependency]->parents [] = $module; |
| 49 | + if ( !isset( $this->nodes[$module] ) ) $this->nodes[$module] = new TSNode( $module ); |
| 50 | + if ( !isset( $this->nodes[$dependency] ) ) $this->nodes[$dependency] = new TSNode( $dependency ); |
| 51 | + if ( !in_array( $dependency, $this->nodes[$module]->children ) ) $this->nodes[$module]->children[] = $dependency; |
| 52 | + if ( !in_array( $module, $this->nodes[$dependency]->parents ) ) $this->nodes[$dependency]->parents[] = $module; |
42 | 53 | } |
43 | 54 | } |
44 | 55 | |
45 | 56 | /** |
46 | | - * Perform Topological Sort |
| 57 | + * Perform Topological Sort. |
47 | 58 | * |
48 | 59 | * @param array $nodes optional array of node objects may be passed. |
49 | 60 | * Default is $this->nodes created in constructor. |
50 | 61 | * |
51 | 62 | * @return sorted array |
52 | 63 | */ |
53 | | - function tsort($nodes = array()) { |
| 64 | + public function doSort( array $nodes = array() ) { |
54 | 65 | // use this->nodes if it is populated and no param passed |
55 | | - if (! @count ( $nodes ) && count ( $this->nodes )) { |
| 66 | + if ( !count( $nodes ) && count( $this->nodes ) ) { |
56 | 67 | $nodes = $this->nodes; |
57 | | - } |
| 68 | + } |
58 | 69 | |
59 | | - |
60 | 70 | // get nodes without parents |
61 | | - $root_nodes = array_values ( $this->getRootNodes ( $nodes ) ); |
| 71 | + $root_nodes = array_values( $this->getRootNodes( $nodes ) ); |
62 | 72 | |
63 | 73 | // begin algorithm |
64 | | - $sorted = array (); |
65 | | - while ( count ( $nodes ) > 0 ) { |
| 74 | + $sorted = array(); |
| 75 | + while ( count( $nodes ) > 0 ) { |
66 | 76 | // check for circular reference |
67 | | - if (count ( $root_nodes ) == 0) |
68 | | - return false; |
| 77 | + if ( count( $root_nodes ) == 0 ) return false; |
69 | 78 | |
| 79 | + |
70 | 80 | // remove this node from root_nodes |
71 | 81 | // and add it to the output |
72 | | - $n = array_pop ( $root_nodes ); |
73 | | - $sorted [] = $n->name; |
| 82 | + $n = array_pop( $root_nodes ); |
| 83 | + $sorted[] = $n->name; |
74 | 84 | |
75 | 85 | // for each of its children |
76 | 86 | // queue the new node finally remove the original |
77 | | - for($i = (count ( $n->children ) - 1); $i >= 0; $i --) { |
78 | | - $childnode = $n->children [$i]; |
| 87 | + for ( $i = count( $n->children ) - 1; $i >= 0; $i -- ) { |
| 88 | + $childnode = $n->children[$i]; |
79 | 89 | // remove the link from this node to its |
80 | 90 | // children ($nodes[$n->name]->children[$i]) AND |
81 | 91 | // remove the link from each child to this |
82 | 92 | // parent ($nodes[$childnode]->parents[?]) THEN |
83 | 93 | // remove this child from this node |
84 | | - unset ( $nodes [$n->name]->children [$i] ); |
85 | | - $parent_position = array_search ( $n->name, $nodes [$childnode]->parents ); |
86 | | - unset ( $nodes [$childnode]->parents [$parent_position] ); |
| 94 | + unset( $nodes[$n->name]->children[$i] ); |
| 95 | + $parent_position = array_search ( $n->name, $nodes[$childnode]->parents ); |
| 96 | + unset( $nodes[$childnode]->parents[$parent_position] ); |
87 | 97 | // check if this child has other parents |
88 | 98 | // if not, add it to the root nodes list |
89 | | - if (! count ( $nodes [$childnode]->parents )) |
90 | | - array_push ( $root_nodes, $nodes [$childnode] ); |
| 99 | + if ( !count( $nodes[$childnode]->parents ) ) { |
| 100 | + array_push( $root_nodes, $nodes [$childnode] ); |
| 101 | + } |
91 | 102 | } |
92 | 103 | |
93 | 104 | // nodes.Remove(n); |
94 | | - unset ( $nodes [$n->name] ); |
| 105 | + unset( $nodes[$n->name] ); |
95 | 106 | } |
96 | | - return $sorted; |
| 107 | + |
| 108 | + // Return the result with the loose nodes (items with no dependencies) appended. |
| 109 | + return array_merge( $sorted, $this->looseNodes ); |
97 | 110 | } |
98 | 111 | |
99 | 112 | /** |
— | — | @@ -102,11 +115,11 @@ |
103 | 116 | * |
104 | 117 | * @return array of node objects |
105 | 118 | */ |
106 | | - function getRootNodes( array $nodes ) { |
| 119 | + private function getRootNodes( array $nodes ) { |
107 | 120 | $output = array (); |
108 | 121 | |
109 | 122 | foreach ( $nodes as $name => $node ) { |
110 | | - if ( !count ( $node->parents )) { |
| 123 | + if ( !count ( $node->parents ) ) { |
111 | 124 | $output[$name] = $node; |
112 | 125 | } |
113 | 126 | } |
— | — | @@ -124,11 +137,11 @@ |
125 | 138 | * ...etc |
126 | 139 | * ); |
127 | 140 | * |
128 | | - * @param array $dlist Array of dependency pairs for use as parameter in tsort method |
| 141 | + * @param array $dlist Array of dependency pairs for use as parameter in doSort method |
129 | 142 | * |
130 | 143 | * @return array |
131 | 144 | */ |
132 | | - function parseDependencyList( array $dlist = array() ) { |
| 145 | + private function parseDependencyList( array $dlist = array() ) { |
133 | 146 | $output = array(); |
134 | 147 | |
135 | 148 | foreach ( $dlist as $name => $dependencies ) { |
— | — | @@ -149,7 +162,7 @@ |
150 | 163 | public $children = array(); |
151 | 164 | public $parents = array(); |
152 | 165 | |
153 | | - function TSNode( $name = '' ) { |
| 166 | + public function TSNode( $name = '' ) { |
154 | 167 | $this->name = $name; |
155 | 168 | } |
156 | 169 | } |
\ No newline at end of file |
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.3 a2' ); |
| 28 | +define( 'Validator_VERSION', '0.3 a3' ); |
29 | 29 | |
30 | 30 | // Constants indicating the strictness of the parameter validation. |
31 | 31 | define( 'Validator_ERRORS_NONE', 0 ); |
— | — | @@ -43,11 +43,12 @@ |
44 | 44 | // Register the internationalization file. |
45 | 45 | $wgExtensionMessagesFiles['Validator'] = $egValidatorDir . 'Validator.i18n.php'; |
46 | 46 | |
47 | | -// Autoload the general classes |
| 47 | +// Autoload the general classes. |
48 | 48 | $wgAutoloadClasses['Validator'] = $egValidatorDir . 'Validator.class.php'; |
49 | 49 | $wgAutoloadClasses['ValidatorFunctions'] = $egValidatorDir . 'Validator_Functions.php'; |
50 | 50 | $wgAutoloadClasses['ValidatorFormats'] = $egValidatorDir . 'Validator_Formats.php'; |
51 | 51 | $wgAutoloadClasses['ValidatorManager'] = $egValidatorDir . 'Validator_Manager.php'; |
| 52 | +$wgAutoloadClasses['TopologicalSort'] = $egValidatorDir . 'TopologicalSort.php'; |
52 | 53 | |
53 | 54 | /** |
54 | 55 | * Initialization function for the Validator extension. |