http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72296
Revision: 72296
Author: jeroendedauw
Date: 2010-09-03 16:51:39 +0000 (Fri, 03 Sep 2010)
Log Message:
-----------
Follow up to r72294
Modified Paths:
--------------
trunk/extensions/Validator/includes/Parameter.php
trunk/extensions/Validator/includes/Validator.php
Modified: trunk/extensions/Validator/includes/Parameter.php
===================================================================
--- trunk/extensions/Validator/includes/Parameter.php 2010-09-03 16:34:21 UTC
(rev 72295)
+++ trunk/extensions/Validator/includes/Parameter.php 2010-09-03 16:51:39 UTC
(rev 72296)
@@ -3,6 +3,8 @@
/**
* Parameter definition class.
*
+ * TODO: create deriving ListParameter class and split list logic off to it
+ *
* @since 0.4
*
* @file Parameter.php
@@ -287,6 +289,18 @@
}
/**
+ * Returns the criteria that apply to the list as a whole.
+ *
+ * @since 0.4
+ *
+ * @return array
+ */
+ public function getListCriteria() {
+ // TODO
+ return array();
+ }
+
+ /**
* Returns the parameter name aliases.
*
* @since 0.4
Modified: trunk/extensions/Validator/includes/Validator.php
===================================================================
--- trunk/extensions/Validator/includes/Validator.php 2010-09-03 16:34:21 UTC
(rev 72295)
+++ trunk/extensions/Validator/includes/Validator.php 2010-09-03 16:51:39 UTC
(rev 72296)
@@ -491,41 +491,37 @@
protected function doListValidation( $name ) {
$hasNoErrors = true;
- /* TODO
- if ( array_key_exists( 'list-criteria',
$this->mParameterInfo[$name] ) ) {
- foreach ( $this->mParameterInfo[$name]['list-criteria']
as $criteriaName => $criteriaArgs ) {
- // Get the validation function. If there is no
matching function, throw an exception.
- if ( array_key_exists( $criteriaName,
self::$mListValidationFunctions ) ) {
- $validationFunction =
self::$mListValidationFunctions[$criteriaName];
- $isValid = $this->doCriteriaValidation(
$validationFunction, $this->mParameters['value'], $name, $criteriaArgs );
+ foreach ( $this->parameterInfo[$name]->getListCriteria() as
$criteriaName => $criteriaArgs ) {
+ // Get the validation function. If there is no matching
function, throw an exception.
+ if ( array_key_exists( $criteriaName,
self::$mListValidationFunctions ) ) {
+ $validationFunction =
self::$mListValidationFunctions[$criteriaName];
+ $isValid = $this->doCriteriaValidation(
$validationFunction, $this->mParameters['value'], $name, $criteriaArgs );
+
+ // Add a new error when the validation failed,
and break the loop if errors for one parameter should not be accumulated.
+ if ( ! $isValid ) {
+ $hasNoErrors = false;
- // Add a new error when the validation
failed, and break the loop if errors for one parameter should not be
accumulated.
- if ( ! $isValid ) {
- $hasNoErrors = false;
-
- $this->registerError(
-
$this->getCriteriaErrorMessage(
- $criteriaName,
-
$this->mParameters[$name]['original-name'],
-
$this->mParameters[$name]['original-value'],
- $criteriaArgs,
- true
- ),
- $criteriaName
- );
-
- if (
!self::$accumulateParameterErrors ) {
- break;
- }
+ $this->registerError(
+ $this->getCriteriaErrorMessage(
+ $criteriaName,
+
$this->mParameters[$name]['original-name'],
+
$this->mParameters[$name]['original-value'],
+ $criteriaArgs,
+ true
+ ),
+ $criteriaName
+ );
+
+ if ( !self::$accumulateParameterErrors
) {
+ break;
}
}
- else {
- $hasNoErrors = false;
- throw new Exception( 'There is no
validation function for list criteria type ' . $criteriaName );
- }
}
+ else {
+ $hasNoErrors = false;
+ throw new Exception( 'There is no validation
function for list criteria type ' . $criteriaName );
+ }
}
- */
return $hasNoErrors;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs