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 +++++-- framework/Web/UI/WebControls/TTextBox.php | 101 ++++++++++++++++----- .../Web/UI/WebControls/TValidationSummary.php | 72 ++++++++++++--- framework/Web/UI/WebControls/TWizard.php | 98 +++++++++++++++----- 4 files changed, 238 insertions(+), 66 deletions(-) (limited to 'framework/Web/UI/WebControls') 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 diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index feea6227..96c43092 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -58,10 +58,6 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable * Default number of columns (for MultiLine text box) */ const DEFAULT_COLUMNS=20; - /** - * @var array list of auto complete types - */ - private static $_autoCompleteTypes=array('BusinessCity','BusinessCountryRegion','BusinessFax','BusinessPhone','BusinessState','BusinessStreetAddress','BusinessUrl','BusinessZipCode','Cellular','Company','Department','Disabled','DisplayName','Email','FirstName','Gender','HomeCity','HomeCountryRegion','HomeFax','Homepage','HomePhone','HomeState','HomeStreetAddress','HomeZipCode','JobTitle','LastName','MiddleName','None','Notes','Office','Pager','Search'); /** * @var mixed safe text parser */ @@ -90,7 +86,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable $page->ensureRenderInForm($this); if(($uid=$this->getUniqueID())!=='') $writer->addAttribute('name',$uid); - if(($textMode=$this->getTextMode())==='MultiLine') + if(($textMode=$this->getTextMode())===TTextBoxMode::MultiLine) { if(($rows=$this->getRows())<=0) $rows=self::DEFAULT_ROWS; @@ -103,7 +99,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable } else { - if($textMode==='SingleLine') + if($textMode===TTextBoxMode::SingleLine) { $writer->addAttribute('type','text'); if(($text=$this->getText())!=='') @@ -233,27 +229,20 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable } /** - * @return string the AutoComplete type of the textbox + * @return TTextBoxAutoCompleteType the AutoComplete type of the textbox */ public function getAutoCompleteType() { - return $this->getViewState('AutoCompleteType','None'); + return $this->getViewState('AutoCompleteType',TTextBoxAutoCompleteType::None); } /** - * @param string the AutoComplete type of the textbox, default value is 'None'. - * Valid values include: - * 'BusinessCity','BusinessCountryRegion','BusinessFax','BusinessPhone', - * 'BusinessState','BusinessStreetAddress','BusinessUrl','BusinessZipCode', - * 'Cellular','Company','Department','Disabled','DisplayName','Email', - * 'FirstName','Gender','HomeCity','HomeCountryRegion','HomeFax','Homepage', - * 'HomePhone','HomeState','HomeStreetAddress','HomeZipCode','JobTitle', - * 'LastName','MiddleName','None','Notes','Office','Pager','Search' + * @param TTextBoxAutoCompleteType the AutoComplete type of the textbox, default value is TTextBoxAutoCompleteType::None. * @throws TInvalidDataValueException if the input parameter is not a valid AutoComplete type */ public function setAutoCompleteType($value) { - $this->setViewState('AutoCompleteType',TPropertyValue::ensureEnum($value,self::$_autoCompleteTypes),'None'); + $this->setViewState('AutoCompleteType',TPropertyValue::ensureEnumerable($value,'TTextBoxAutoCompleteType'),TTextBoxAutoCompleteType::None); } /** @@ -416,21 +405,21 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable } /** - * @return string the behavior mode (SingleLine, MultiLine, or Password) of the TTextBox component. Defaults to SingleLine. + * @return TTextBoxMode the behavior mode of the TTextBox component. Defaults to TTextBoxMode::SingleLine. */ public function getTextMode() { - return $this->getViewState('TextMode','SingleLine'); + return $this->getViewState('TextMode',TTextBoxMode::SingleLine); } /** - * Sets the behavior mode (SingleLine, MultiLine, or Password) of the TTextBox component. - * @param string the text mode + * Sets the behavior mode of the TTextBox component. + * @param TTextBoxMode the text mode * @throws TInvalidDataValueException if the input value is not a valid text mode. */ public function setTextMode($value) { - $this->setViewState('TextMode',TPropertyValue::ensureEnum($value,array('SingleLine','MultiLine','Password')),'SingleLine'); + $this->setViewState('TextMode',TPropertyValue::ensureEnumerable($value,'TTextBoxMode'),TTextBoxMode::SingleLine); } /** @@ -467,4 +456,72 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable } } +/** + * TTextBoxMode class. + * TTextBoxMode defines the enumerable type for the possible mode + * that a {@link TTextBox} control could be at. + * + * The following enumerable values are defined: + * - SingleLine: the textbox will be a regular single line input + * - MultiLine: the textbox will be a textarea allowing multiple line input + * - Password: the textbox will hide user input like a password input box + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TTextBoxMode extends TEnumerable +{ + const SingleLine='SingleLine'; + const MultiLine='MultiLine'; + const Password='Password'; +} + +/** + * TTextBoxAutoCompleteType class. + * TTextBoxAutoCompleteType defines the possible AutoComplete type that is supported + * by a {@link TTextBox} control. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TTextBoxAutoCompleteType extends TEnumerable +{ + const BusinessCity='BusinessCity'; + const BusinessCountryRegion='BusinessCountryRegion'; + const BusinessFax='BusinessFax'; + const BusinessPhone='BusinessPhone'; + const BusinessState='BusinessState'; + const BusinessStreetAddress='BusinessStreetAddress'; + const BusinessUrl='BusinessUrl'; + const BusinessZipCode='BusinessZipCode'; + const Cellular='Cellular'; + const Company='Company'; + const Department='Department'; + const Disabled='Disabled'; + const DisplayName='DisplayName'; + const Email='Email'; + const FirstName='FirstName'; + const Gender='Gender'; + const HomeCity='HomeCity'; + const HomeCountryRegion='HomeCountryRegion'; + const HomeFax='HomeFax'; + const Homepage='Homepage'; + const HomePhone='HomePhone'; + const HomeState='HomeState'; + const HomeStreetAddress='HomeStreetAddress'; + const HomeZipCode='HomeZipCode'; + const JobTitle='JobTitle'; + const LastName='LastName'; + const MiddleName='MiddleName'; + const None='None'; + const Notes='Notes'; + const Office='Office'; + const Pager='Pager'; + const Search='Search'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TValidationSummary.php b/framework/Web/UI/WebControls/TValidationSummary.php index c7330f94..539c6dc3 100644 --- a/framework/Web/UI/WebControls/TValidationSummary.php +++ b/framework/Web/UI/WebControls/TValidationSummary.php @@ -52,20 +52,19 @@ class TValidationSummary extends TWebControl } /** - * @return string the display behavior (None, Static, Dynamic) of the error message in a validation summary component. + * @return TValidationSummaryDisplayStyle the style of displaying the error messages. Defaults to TValidationSummaryDisplayStyle::Fixed. */ public function getDisplay() { - return $this->getViewState('Display','Static'); + return $this->getViewState('Display',TValidationSummaryDisplayStyle::Fixed); } /** - * Sets the display behavior (None, Static, Dynamic) of the error message in a validation summary component. - * @param string the display behavior (None, Static, Dynamic) + * @param TValidationSummaryDisplayStyle the style of displaying the error messages */ public function setDisplay($value) { - $this->setViewState('Display',TPropertyValue::ensureEnum($value,'None','Dynamic','Static'),'Static'); + $this->setViewState('Display',TPropertyValue::ensureEnumerable($value,'TValidationSummaryDisplayStyle'),TValidationSummaryDisplayStyle::Fixed); } /** @@ -86,20 +85,19 @@ class TValidationSummary extends TWebControl } /** - * @return string the display mode (BulletList, List, SingleParagraph) of the validation summary. Defaults to BulletList. + * @return TValidationSummaryDisplayMode the mode of displaying error messages. Defaults to TValidationSummaryDisplayMode::BulletList. */ public function getDisplayMode() { - return $this->getViewState('DisplayMode','BulletList'); + return $this->getViewState('DisplayMode',TValidationSummaryDisplayMode::BulletList); } /** - * Sets the display mode (BulletList, List, SingleParagraph) of the validation summary. - * @param string the display mode (BulletList, List, SingleParagraph) + * @param TValidationSummaryDisplayMode the mode of displaying error messages */ public function setDisplayMode($value) { - $this->setViewState('DisplayMode',TPropertyValue::ensureEnum($value,'List','SingleParagraph','BulletList'),'BulletList'); + $this->setViewState('DisplayMode',TPropertyValue::ensureEnumerable($value,'TValidationSummaryDisplayMode'),TValidationSummaryDisplayMode::BulletList); } /** @@ -206,7 +204,7 @@ class TValidationSummary extends TWebControl $visible=$this->getEnabled(true) && count($this->getErrorMessages()) > 0; if(!$visible) { - if($display==='None' || $display==='Dynamic') + if($display===TValidationSummaryDisplayStyle::None || $display===TValidationSummaryDisplayStyle::Dynamic) $writer->addStyleAttribute('display','none'); else $writer->addStyleAttribute('visibility','hidden'); @@ -318,13 +316,13 @@ class TValidationSummary extends TWebControl // $this->setStyle('display:block'); switch($this->getDisplayMode()) { - case 'List': + case TValidationSummaryDisplayMode::SimpleList: $this->renderList($writer); break; - case 'SingleParagraph': + case TValidationSummaryDisplayMode::SingleParagraph: $this->renderSingleParagraph($writer); break; - case 'BulletList': + case TValidationSummaryDisplayMode::BulletList: $this->renderBulletList($writer); break; } @@ -449,4 +447,50 @@ class TValidationSummaryClientScript extends TClientSideOptions } } + +/** + * TValidationSummaryDisplayMode class. + * TValidationSummaryDisplayMode defines the enumerable type for the possible modes + * that a {@link TValidationSummary} can organize and display the collected error messages. + * + * The following enumerable values are defined: + * - SimpleList: the error messages are displayed as a list without any decorations. + * - SingleParagraph: the error messages are concatenated together into a paragraph. + * - BulletList: the error messages are displayed as a bulleted list. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TValidationSummaryDisplayMode extends TEnumerable +{ + const SimpleList='SimpleList'; + const SingleParagraph='SingleParagraph'; + const BulletList='BulletList'; +} + + +/** + * TValidationSummaryDisplay class. + * TValidationSummaryDisplay defines the enumerable type for the possible styles + * that a {@link TValidationSummary} can display the collected error messages. + * + * The following enumerable values are defined: + * - None: the error messages are not displayed + * - Dynamic: the error messages are dynamically added to display as the corresponding validators fail + * - Fixed: Similar to Dynamic except that the error messages physically occupy the page layout (even though they may not be visible) + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TValidationSummaryDisplayStyle extends TEnumerable +{ + const None='None'; + const Dynamic='Dynamic'; + const Fixed='Fixed'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php index 2d54afbe..0a9bb58c 100644 --- a/framework/Web/UI/WebControls/TWizard.php +++ b/framework/Web/UI/WebControls/TWizard.php @@ -85,6 +85,7 @@ class TWizard extends TWebControl implements INamingContainer { /** * Wizard step types. + * @deprecated deprecated since version 3.0.4 (use TWizardStepType constants instead) */ const ST_AUTO='Auto'; const ST_START='Start'; @@ -918,7 +919,7 @@ class TWizard extends TWebControl implements INamingContainer } } $activeStepType=$this->getStepType($activeStep); - if($activeStepType===self::ST_COMPLETE) + if($activeStepType===TWizardStepType::Complete) { $this->_sideBar->setVisible(false); $this->_header->setVisible(false); @@ -1014,24 +1015,24 @@ class TWizard extends TWebControl implements INamingContainer /** * Determines the type of the specified wizard step. * @param TWizardStep - * @return string type of the step, 'Finish', 'Start', 'Step'. + * @return TWizardStepType type of the step */ protected function getStepType($wizardStep) { - if(($type=$wizardStep->getStepType())===self::ST_AUTO) + if(($type=$wizardStep->getStepType())===TWizardStepType::Auto) { $steps=$this->getWizardSteps(); if(($index=$steps->indexOf($wizardStep))>=0) { $stepCount=$steps->getCount(); - if($stepCount===1 || ($index<$stepCount-1 && $steps->itemAt($index+1)->getStepType()==='Complete')) - return self::ST_FINISH; + if($stepCount===1 || ($index<$stepCount-1 && $steps->itemAt($index+1)->getStepType()===TWizardStepType::Complete)) + return TWizardStepType::Finish; else if($index===0) - return self::ST_START; + return TWizardStepType::Start; else if($index===$stepCount-1) - return self::ST_FINISH; + return TWizardStepType::Finish; else - return self::ST_STEP; + return TWizardStepType::Step; } else return $type; @@ -1162,7 +1163,7 @@ class TWizard extends TWebControl implements INamingContainer if(($button=$item->findControl(self::ID_SIDEBAR_BUTTON))!==null) { $step=$item->getDataItem(); - if(($this->getStepType($step)==='Complete')) + if(($this->getStepType($step)===TWizardStepType::Complete)) $button->setEnabled(false); if(($title=$step->getTitle())!=='') $button->setText($title); @@ -1515,19 +1516,19 @@ class TWizardNavigationButtonStyle extends TStyle } /** - * @return string button type. Default to 'Button'. + * @return TWizardNavigationButtonType button type. Default to TWizardNavigationButtonType::Button. */ public function getButtonType() { - return $this->_buttonType===null?'Button':$this->_buttonType; + return $this->_buttonType===null? TWizardNavigationButtonType::Button :$this->_buttonType; } /** - * @param string button type. Valid values include 'Button', 'Image', 'Link'. + * @param TWizardNavigationButtonType button type. */ public function setButtonType($value) { - $this->_buttonType=TPropertyValue::ensureEnum($value,'Button','Image','Link'); + $this->_buttonType=TPropertyValue::ensureEnumerable($value,'TWizardNavigationButtonType'); } /** @@ -1618,22 +1619,22 @@ class TWizardStep extends TView } /** - * @return string the wizard step type. Defaults to 'Auto'. + * @return TWizardStepType the wizard step type. Defaults to TWizardStepType::Auto. */ public function getStepType() { - return $this->getViewState('StepType',TWizard::ST_AUTO); + return $this->getViewState('StepType',TWizardStepType::Auto); } /** - * @param string the wizard step type. Valid values include 'Auto', 'Complete', 'Start', 'Step', 'Finish'. + * @param TWizardStepType the wizard step type. */ public function setStepType($type) { - $type=TPropertyValue::ensureEnum($type,TWizard::ST_AUTO,TWizard::ST_COMPLETE,TWizard::ST_STEP,TWizard::ST_START,TWizard::ST_FINISH); + $type=TPropertyValue::ensureEnumerable($type,'TWizardStepType'); if($type!==$this->getStepType()) { - $this->setViewState('StepType',$type,TWizard::ST_AUTO); + $this->setViewState('StepType',$type,TWizardStepType::Auto); if($this->_wizard) $this->_wizard->wizardStepsChanged(); } @@ -1644,7 +1645,7 @@ class TWizardStep extends TView /** * TCompleteWizardStep class. * - * TCompleteWizardStep represents a wizard step of type 'Complete'. + * TCompleteWizardStep represents a wizard step of type TWizardStepType::Complete. * * @author Qiang Xue * @version $Revision: $ $Date: $ @@ -1654,11 +1655,11 @@ class TWizardStep extends TView class TCompleteWizardStep extends TWizardStep { /** - * @return string the wizard step type. Always 'Complete'. + * @return TWizardStepType the wizard step type. Always TWizardStepType::Complete. */ public function getStepType() { - return 'Complete'; + return TWizardStepType::Complete; } /** @@ -2100,13 +2101,13 @@ class TWizardNavigationTemplate extends TComponent implements ITemplate { switch($buttonStyle->getButtonType()) { - case 'Button': + case TWizardNavigationButtonType::Button: $button=new TButton; break; - case 'Link' : + case TWizardNavigationButtonType::Link: $button=new TLinkButton; break; - case 'Image' : + case TWizardNavigationButtonType::Image: $button=new TImageButton; $button->setImageUrl($buttonStyle->getImageUrl()); break; @@ -2218,4 +2219,53 @@ class TWizardStepNavigationTemplate extends TWizardNavigationTemplate } } + +/** + * TWizardNavigationButtonType class. + * TWizardNavigationButtonType defines the enumerable type for the possible types of buttons + * that can be used in the navigation part of a {@link TWizard}. + * + * The following enumerable values are defined: + * - Button: a regular click button + * - Image: an image button + * - Link: a hyperlink button + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TWizardNavigationButtonType extends TEnumerable +{ + const Button='Button'; + const Image='Image'; + const Link='Link'; +} + + +/** + * TWizardStepType class. + * TWizardStepType defines the enumerable type for the possible types of {@link TWizard wizard} steps. + * + * The following enumerable values are defined: + * - Auto: the type is automatically determined based on the location of the wizard step in the whole step collection. + * - Complete: the step is the last summary step. + * - Start: the step is the first step + * - Step: the step is between the begin and the end steps. + * - Finish: the last step before the Complete step. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TWizardStepType extends TEnumerable +{ + const Auto='Auto'; + const Complete='Complete'; + const Start='Start'; + const Step='Step'; + const Finish='Finish'; +} + ?> \ No newline at end of file -- cgit v1.2.3