From 1afc913c386bba8e6072c278b0eb4fd9818ab310 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 25 Apr 2006 01:27:04 +0000 Subject: Undo previous checkin (which goes int 3.0 branch and will be merged back). --- framework/Web/UI/WebControls/TCompareValidator.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'framework/Web/UI/WebControls/TCompareValidator.php') diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php index b5ebd3ab..172e472f 100644 --- a/framework/Web/UI/WebControls/TCompareValidator.php +++ b/framework/Web/UI/WebControls/TCompareValidator.php @@ -31,6 +31,7 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); * type before the comparison operation is performed. The following value types are supported: * - Integer A 32-bit signed integer data type. * - Float A double-precision floating point number data type. + * - Currency A decimal data type that can contain currency symbols. * - Date A date data type. The format can be specified by the * {@link setDateFormat DateFormat} property * - String A string data type. @@ -55,13 +56,12 @@ class TCompareValidator extends TBaseValidator } /** - * Sets the data type (Integer, Float, Date, String) that the values being - * compared are converted to before the comparison is made. + * Sets the data type (Integer, Float, Currency, Date, String) that the values being compared are converted to before the comparison is made. * @param string the data type */ public function setDataType($value) { - $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'Integer','Float','Date','String'),'String'); + $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'Integer','Float','Date','Currency','String'),'String'); } /** @@ -188,6 +188,16 @@ class TCompareValidator extends TBaseValidator return array(intval($value1), intval($value2)); case 'Float': return array(floatval($value1), floatval($value2)); + case 'Currency': + if(preg_match('/[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?/',$value1,$matches)) + $value1=floatval($matches[0]); + else + $value1=0; + if(preg_match('/[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?/',$value2,$matches)) + $value2=floatval($matches[0]); + else + $value2=0; + return array($value1, $value2); case 'Date': $dateFormat = $this->getDateFormat(); if($dateFormat!=='') -- cgit v1.2.3