http://www.mediawiki.org/wiki/Special:Code/MediaWiki/65308

Revision: 65308
Author:   jeroendedauw
Date:     2010-04-20 12:37:46 +0000 (Tue, 20 Apr 2010)

Log Message:
-----------
Follow up to r65307

Modified Paths:
--------------
    trunk/extensions/Validator/Validator.class.php
    trunk/extensions/Validator/Validator.php
    trunk/extensions/Validator/Validator_Manager.php

Modified: trunk/extensions/Validator/Validator.class.php
===================================================================
--- trunk/extensions/Validator/Validator.class.php      2010-04-20 12:37:25 UTC 
(rev 65307)
+++ trunk/extensions/Validator/Validator.class.php      2010-04-20 12:37:46 UTC 
(rev 65308)
@@ -19,6 +19,9 @@
  * @ingroup Validator
  *
  * @author Jeroen De Dauw
+ * 
+ * TODO: add a way to use parameter values in the validation/formatting of 
other parameters.
+ * This will also require new syntax to order the handling of the defined 
parameters.
  */
 final class Validator {
 
@@ -50,36 +53,36 @@
         * @var array Holder for the validation functions.
         */
        private static $mValidationFunctions = array(
-                       'in_array' => array( 'ValidatorFunctions', 'in_array' ),
-                       'in_range' => array( 'ValidatorFunctions', 'in_range' ),
-                       'is_numeric' => 'is_numeric',
-                       'is_float' => 'is_float',
-                       'is_integer' => array( 'ValidatorFunctions', 
'is_integer' ),
-                       'not_empty' => array( 'ValidatorFunctions', 'not_empty' 
),
-                       'has_length' => array( 'ValidatorFunctions', 
'has_length' ),
-                       'regex' => array( 'ValidatorFunctions', 'regex' ),
-                       );
+               'in_array' => array( 'ValidatorFunctions', 'in_array' ),
+               'in_range' => array( 'ValidatorFunctions', 'in_range' ),
+               'is_numeric' => 'is_numeric',
+               'is_float' => 'is_float',
+               'is_integer' => array( 'ValidatorFunctions', 'is_integer' ),
+               'not_empty' => array( 'ValidatorFunctions', 'not_empty' ),
+               'has_length' => array( 'ValidatorFunctions', 'has_length' ),
+               'regex' => array( 'ValidatorFunctions', 'regex' ),
+       );
        
        /**
         * @var array Holder for the list validation functions.
         */
        private static $mListValidationFunctions = array(
-                       'item_count' => array( 'ValidatorFunctions', 
'has_item_count' ),
-                       'unique_items' => array( 'ValidatorFunctions', 
'has_unique_items' ),
-                       );
+               'item_count' => array( 'ValidatorFunctions', 'has_item_count' ),
+               'unique_items' => array( 'ValidatorFunctions', 
'has_unique_items' ),
+       );
 
        /**
         * @var array Holder for the formatting functions.
         */
        private static $mOutputFormats = array(
-                       'array' => array( 'ValidatorFormats', 'format_array' ),
-                       'list' => array( 'ValidatorFormats', 'format_list' ),
-                       'boolean' => array( 'ValidatorFormats', 
'format_boolean' ),
-                       'boolstr' => array( 'ValidatorFormats', 
'format_boolean_string' ),
-                       'string' => array( 'ValidatorFormats', 'format_string' 
),
-                       'unique_items' => array( 'ValidatorFormats', 
'format_unique_items' ),
-                       'filtered_array' => array( 'ValidatorFormats', 
'format_filtered_array' ),
-                       );
+               'array' => array( 'ValidatorFormats', 'format_array' ),
+               'list' => array( 'ValidatorFormats', 'format_list' ),
+               'boolean' => array( 'ValidatorFormats', 'format_boolean' ),
+               'boolstr' => array( 'ValidatorFormats', 'format_boolean_string' 
),
+               'string' => array( 'ValidatorFormats', 'format_string' ),
+               'unique_items' => array( 'ValidatorFormats', 
'format_unique_items' ),
+               'filtered_array' => array( 'ValidatorFormats', 
'format_filtered_array' ),
+       );
 
        private $mParameterInfo;
        
@@ -418,7 +421,7 @@
         * @param $value
         * @param $criteriaArgs
         * 
-        * @return unknown_type
+        * @return boolean
         */
        private function doCriteriaValidation( $validationFunction, $value, 
$criteriaArgs ) {
                // Call the validation function and store the result. 
@@ -524,7 +527,7 @@
         * if it's in a class, first the class name, then the method name.
         */
        public static function addListValidationFunction( $criteriaName, array 
$functionName ) {
-               self::$mListValidationFunctions[$criteriaName] = $functionName;
+               self::$mListValidationFunctions[strtolower( $criteriaName )] = 
$functionName;
        }
        
        /**
@@ -536,6 +539,6 @@
         * if it's in a class, first the class name, then the method name.
         */
        public static function addOutputFormat( $formatName, array 
$functionName ) {
-               self::$mOutputFormats[$formatName] = $functionName;
+               self::$mOutputFormats[strtolower( $formatName )] = 
$functionName;
        }
 }
\ No newline at end of file

Modified: trunk/extensions/Validator/Validator.php
===================================================================
--- trunk/extensions/Validator/Validator.php    2010-04-20 12:37:25 UTC (rev 
65307)
+++ trunk/extensions/Validator/Validator.php    2010-04-20 12:37:46 UTC (rev 
65308)
@@ -24,7 +24,7 @@
        die( 'Not an entry point.' );
 }
 
-define( 'Validator_VERSION', '0.3 a1' );
+define( 'Validator_VERSION', '0.3 a2' );
 
 // Constants indicating the strictness of the parameter validation.
 define( 'Validator_ERRORS_NONE', 0 );

Modified: trunk/extensions/Validator/Validator_Manager.php
===================================================================
--- trunk/extensions/Validator/Validator_Manager.php    2010-04-20 12:37:25 UTC 
(rev 65307)
+++ trunk/extensions/Validator/Validator_Manager.php    2010-04-20 12:37:46 UTC 
(rev 65308)
@@ -34,6 +34,7 @@
         * @param array $rawParameters The raw parameters, as provided by the 
user.
         * @param array $parameterInfo Array containing the parameter 
definitions, which are needed for validation and defaulting.
         * @param array $defaultParams
+        * 
         * @return array or false The valid parameters or false when the output 
should not be shown.
         */
        public function manageParameters( array $rawParameters, array 
$parameterInfo, array $defaultParams = array() ) {



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to