From a90da4361d02a53204f198f19072e2d420b394f0 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 3 Sep 2006 21:33:04 +0000 Subject: Added TEnumerable and updated places where enumerable type should be used. --- framework/Web/UI/WebControls/TBaseValidator.php | 33 ++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'framework/Web/UI/WebControls/TBaseValidator.php') diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 5c75273e..711dd2c4 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -136,7 +136,7 @@ abstract class TBaseValidator extends TLabel implements IValidator { $display=$this->getDisplay(); $visible=$this->getEnabled(true) && !$this->getIsValid(); - if($display==='None' || (!$visible && $display==='Dynamic')) + if($display===TValidatorDisplayStyle::None || (!$visible && $display===TValidatorDisplayStyle::Dynamic)) $writer->addStyleAttribute('display','none'); else if(!$visible) $writer->addStyleAttribute('visibility','hidden'); @@ -311,20 +311,19 @@ abstract class TBaseValidator extends TLabel implements IValidator } /** - * @return string the display behavior (None, Static, Dynamic) of the error message in a validation control. Defaults to Static. + * @return TValidatorDisplayStyle the style of displaying the error message. Defaults to TValidatorDisplayStyle::Fixed. */ public function getDisplay() { - return $this->getViewState('Display','Static'); + return $this->getViewState('Display',TValidatorDisplayStyle::Fixed); } /** - * Sets the display behavior (None, Static, Dynamic) of the error message in a validation control. - * @param string the display behavior (None, Static, Dynamic) + * @param TValidatorDisplayStyle the style of displaying the error message */ public function setDisplay($value) { - $this->setViewState('Display',TPropertyValue::ensureEnum($value,array('None','Static','Dynamic')),'Static'); + $this->setViewState('Display',TPropertyValue::ensureEnumerable($value,'TValidatorDisplayStyle'),TValidatorDisplayStyle::Fixed); } /** @@ -664,4 +663,26 @@ class TValidatorClientSide extends TClientSideOptions } } + +/** + * TValidatorDisplayStyle class. + * TValidatorDisplayStyle defines the enumerable type for the possible styles + * that a validator control can display the error message. + * + * The following enumerable values are defined: + * - None: the error message is not displayed + * - Dynamic: the error message dynamically appears when the validator fails validation + * - Fixed: Similar to Dynamic except that the error message physically occupies the page layout (even though it may not be visible) + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TValidatorDisplayStyle extends TEnumerable +{ + const None='None'; + const Dynamic='Dynamic'; + const Fixed='Fixed'; +} ?> \ No newline at end of file -- cgit v1.2.3