r62037 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62036‎ | r62037 | r62038 >
Date:17:24, 5 February 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.2.2.
* Added filtered_array format
Modified paths:
  • /trunk/extensions/Validator/Validator.class.php (modified) (history)
  • /trunk/extensions/Validator/Validator.php (modified) (history)
  • /trunk/extensions/Validator/Validator_Formats.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/Validator.class.php
@@ -69,7 +69,7 @@
7070
7171 /**
7272 * @var array Holder for the formatting functions.
73 - */
 73+ */
7474 private static $outputFormats = array(
7575 'array' => array( 'ValidatorFormats', 'format_array' ),
7676 'list' => array( 'ValidatorFormats', 'format_list' ),
@@ -77,6 +77,7 @@
7878 'boolstr' => array( 'ValidatorFormats', 'format_boolean_string' ),
7979 'string' => array( 'ValidatorFormats', 'format_string' ),
8080 'unique_items' => array( 'ValidatorFormats', 'format_unique_items' ),
 81+ 'filtered_array' => array( 'ValidatorFormats', 'format_filtered_array' ),
8182 );
8283
8384 private $parameterInfo;
Index: trunk/extensions/Validator/Validator_Formats.php
@@ -31,6 +31,23 @@
3232 }
3333
3434 /**
 35+ * Ensures the value is an array.
 36+ *
 37+ * @param $value
 38+ */
 39+ public static function format_filtered_array( &$value ) {
 40+ // TODO: It's possible the way the allowed values are passed here is quite inneficient...
 41+ $params = func_get_args();
 42+ array_shift( $params ); // Ommit the value
 43+
 44+ self::format_array($value);
 45+ $filtered = array();
 46+ foreach($value as $item) if (in_array($item, $params)) $filtered[] = $item;
 47+
 48+ return $filtered;
 49+ }
 50+
 51+ /**
3552 * Changes the value to list notation, by separating items with a delimiter,
3653 * and/or adding wrappers before and after the items. Intended for lists, but
3754 * will also work for single values.
Index: trunk/extensions/Validator/Validator.php
@@ -24,7 +24,7 @@
2525 die( 'Not an entry point.' );
2626 }
2727
28 -define( 'Validator_VERSION', '0.2.1' );
 28+define( 'Validator_VERSION', '0.2.2 a1' );
2929
3030 // Constants indicating the strictness of the parameter validation.
3131 define( 'Validator_ERRORS_NONE', 0 );

Status & tagging log