diff options
Diffstat (limited to 'framework')
6 files changed, 45 insertions, 13 deletions
diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt index c142d8a6..0734fa1f 100644 --- a/framework/Exceptions/messages.txt +++ b/framework/Exceptions/messages.txt @@ -216,9 +216,9 @@ emaillogroute_sentfrom_required = TEmailLogRoute.SentFrom cannot be empty. repeatinfo_repeatcolumns_invalid = TRepeatInfo.RepeatColumns must be no less than 0.
-basevalidator_associatedcontrolid_unsupported = TBaseValidator.AssociatedControlID is not supported.
-basevalidator_controltovalidate_invalid = TBaseValidator.ControlToValidate is empty or contains an invalid control ID path.
-basevalidator_validatable_required = TBaseValidator.ControlToValidate must point to a control implementing IValidatable interface.
+basevalidator_controltovalidate_invalid = %s.ControlToValidate is empty or contains an invalid control ID path.
+basevalidator_validatable_required = %s.ControlToValidate must point to a control implementing IValidatable interface.
+basevalidator_forcontrol_unsupported = %s.ForControl is not supported.
comparevalidator_controltocompare_invalid = TCompareValidator.ControlToCompare contains an invalid control ID path.
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 46f031ca..03362110 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -370,7 +370,7 @@ abstract class TBaseValidator extends TLabel implements IValidator if(($id=$this->getControlToValidate())!=='' && ($control=$this->findControl($id))!==null) return $control; else - throw new TConfigurationException('basevalidator_controltovalidate_invalid'); + throw new TConfigurationException('basevalidator_controltovalidate_invalid',get_class($this)); } /** @@ -384,7 +384,7 @@ abstract class TBaseValidator extends TLabel implements IValidator if($control instanceof IValidatable) return $control->getValidationPropertyValue(); else - throw new TInvalidDataTypeException('basevalidator_validatable_required'); + throw new TInvalidDataTypeException('basevalidator_validatable_required',get_class($this)); } /** diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php index 853cff17..9b8dabd5 100644 --- a/framework/Web/UI/WebControls/TCompareValidator.php +++ b/framework/Web/UI/WebControls/TCompareValidator.php @@ -206,7 +206,7 @@ class TCompareValidator extends TBaseValidator return array($value1, $value2);
case 'Date':
$dateFormat = $this->getDateFormat();
- if (strlen($dateFormat))
+ if($dateFormat!=='')
{
$formatter = Prado::createComponent('System.Data.TSimpleDateFormatter', $dateFormat);
return array($formatter->parse($value1), $formatter->parse($value2));
diff --git a/framework/Web/UI/WebControls/TEmailAddressValidator.php b/framework/Web/UI/WebControls/TEmailAddressValidator.php index b6ceff90..3534d1d0 100644 --- a/framework/Web/UI/WebControls/TEmailAddressValidator.php +++ b/framework/Web/UI/WebControls/TEmailAddressValidator.php @@ -19,8 +19,9 @@ Prado::using('System.Web.UI.WebControls.TRegularExpressionValidator'); * TEmailAddressValidator class
*
* TEmailAddressValidator validates whether the value of an associated
- * input component is a valid email address. It will check MX record
- * if checkdnsrr() is available in the installed PHP.
+ * input component is a valid email address. If {@link getCheckMXRecord CheckMXRecord}
+ * is true, it will check MX record for the email adress, provided
+ * checkdnsrr() is available in the installed PHP.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
@@ -50,7 +51,7 @@ class TEmailAddressValidator extends TRegularExpressionValidator public function evaluateIsValid()
{
$valid=parent::evaluateIsValid();
- if($valid && function_exists('checkdnsrr'))
+ if($valid && $this->getCheckMXRecord() && function_exists('checkdnsrr'))
{
if(($value=$this->getValidationValue($this->getValidationTarget()))!=='')
{
@@ -65,6 +66,23 @@ class TEmailAddressValidator extends TRegularExpressionValidator }
return $valid;
}
+
+ /**
+ * @return boolean whether to check MX record for the email address being validated. Defaults to true.
+ */
+ public function getCheckMXRecord()
+ {
+ return $this->getViewState('CheckMXRecord',true);
+ }
+
+ /**
+ * @param boolean whether to check MX record for the email address being validated.
+ * Note, if {@link checkdnsrr} is not available, this check will not be performed.
+ */
+ public function setCheckMXRecord($value)
+ {
+ $this->setViewState('CheckMXRecord',TPropertyValue::ensureBoolean($value),true);
+ }
}
?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TRegularExpressionValidator.php b/framework/Web/UI/WebControls/TRegularExpressionValidator.php index f20c2d16..4271c820 100644 --- a/framework/Web/UI/WebControls/TRegularExpressionValidator.php +++ b/framework/Web/UI/WebControls/TRegularExpressionValidator.php @@ -29,7 +29,6 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); * German Phone Number: ((\(0\d\d\) |(\(0\d{3}\) )?\d )?\d\d \d\d \d\d|\(0\d{4}\) \d \d\d-\d\d?)
* German Postal Code: (D-)?\d{5}
* Email Address: \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
- * Internal URL: http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
* Japanese Phone Number: (0\d{1,4}-|\(0\d{1,4}\) ?)?\d{1,4}-\d{4}
* Japanese Postal Code: \d{3}(-(\d{4}|\d{2}))?
* P.R.C. Phone Number: (\(\d{3}\)|\d{3}-)?\d{8}
diff --git a/framework/Web/UI/WebControls/TValueTypeValidator.php b/framework/Web/UI/WebControls/TValueTypeValidator.php index ca4a01ca..8b5d7bbc 100644 --- a/framework/Web/UI/WebControls/TValueTypeValidator.php +++ b/framework/Web/UI/WebControls/TValueTypeValidator.php @@ -1,14 +1,29 @@ <?php
+/**
+ * TValueTypeValidator class.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2005 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.WebControls
+ */
/**
- * TRequiredValueTypeValidator class.
+ * Using TBaseValidator class
+ */
+Prado::using('System.Web.UI.WebControls.TBaseValidator');
+
+/**
+ * TValueTypeValidator class
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
* @since 3.0
*/
-class TValueTypeValidator
+class TValueTypeValidator extends TBaseValidator
{
/**
* @return string the data type that the values being compared are converted to before the comparison is made. Defaults to String.
@@ -72,7 +87,7 @@ class TValueTypeValidator return strtotime($value) > 0;
}
return true;
- }
+ }
/**
* This method overrides the parent's implementation.
|