From 56fee292c37e162c03fab9eeadd6a8b9ab85c251 Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 4 Sep 2006 19:15:47 +0000 Subject: merge from 3.0 branch till 1387 --- framework/Exceptions/TErrorHandler.php | 4 +- framework/PradoBase.php | 4 +- framework/Security/TSecurityManager.php | 31 +++- framework/Security/TUserManager.php | 38 +++- framework/TApplication.php | 35 +++- framework/TComponent.php | 54 +++++- framework/Util/TDataFieldAccessor.php | 2 +- framework/Util/TDateTimeStamp.php | 3 +- framework/Web/Javascripts/extended/event.js | 17 +- framework/Web/Javascripts/js/compressed/ajax.js | 2 +- framework/Web/Javascripts/js/compressed/prado.js | 7 +- framework/Web/Javascripts/js/debug/ajax.js | 2 +- framework/Web/Javascripts/js/debug/prado.js | 18 +- framework/Web/Javascripts/js/debug/validator.js | 4 +- framework/Web/Javascripts/prado/controls.js | 1 + framework/Web/Javascripts/prado/validation3.js | 4 +- framework/Web/Services/TPageService.php | 2 +- framework/Web/TAssetManager.php | 10 +- framework/Web/THttpRequest.php | 40 +++-- framework/Web/THttpSession.php | 42 +++-- framework/Web/UI/TClientScriptManager.php | 26 +-- framework/Web/UI/TForm.php | 2 +- framework/Web/UI/TPage.php | 6 +- framework/Web/UI/TThemeManager.php | 2 +- framework/Web/UI/WebControls/TBaseDataList.php | 47 +---- framework/Web/UI/WebControls/TBaseValidator.php | 58 +++++- framework/Web/UI/WebControls/TBulletedList.php | 101 ++++++++--- framework/Web/UI/WebControls/TButton.php | 31 +++- framework/Web/UI/WebControls/TButtonColumn.php | 14 +- framework/Web/UI/WebControls/TCheckBox.php | 29 ++- framework/Web/UI/WebControls/TCheckBoxList.php | 9 +- framework/Web/UI/WebControls/TColorPicker.php | 34 +++- framework/Web/UI/WebControls/TCompareValidator.php | 69 ++++--- framework/Web/UI/WebControls/TDataBoundControl.php | 33 ++++ framework/Web/UI/WebControls/TDataGrid.php | 199 +++++++++++++-------- framework/Web/UI/WebControls/TDataGridColumn.php | 23 +++ framework/Web/UI/WebControls/TDataList.php | 111 ++++++------ .../Web/UI/WebControls/TDataTypeValidator.php | 15 +- framework/Web/UI/WebControls/TDatePicker.php | 78 ++++++-- .../Web/UI/WebControls/TEditCommandColumn.php | 73 +++++++- framework/Web/UI/WebControls/TImageMap.php | 62 ++++--- framework/Web/UI/WebControls/TInlineFrame.php | 72 ++++++-- framework/Web/UI/WebControls/TLabel.php | 27 ++- framework/Web/UI/WebControls/TListBox.php | 38 +++- framework/Web/UI/WebControls/TListControl.php | 19 ++ framework/Web/UI/WebControls/TPager.php | 68 +++++-- framework/Web/UI/WebControls/TPanel.php | 2 +- framework/Web/UI/WebControls/TPanelStyle.php | 88 ++++++--- framework/Web/UI/WebControls/TRangeValidator.php | 58 ++++-- framework/Web/UI/WebControls/TRepeatInfo.php | 90 +++++++--- framework/Web/UI/WebControls/TRepeater.php | 43 ++--- framework/Web/UI/WebControls/TStyle.php | 130 ++++++++++---- framework/Web/UI/WebControls/TTable.php | 69 ++++--- framework/Web/UI/WebControls/TTableHeaderCell.php | 35 +++- framework/Web/UI/WebControls/TTableRow.php | 32 +++- framework/Web/UI/WebControls/TTextBox.php | 101 ++++++++--- .../Web/UI/WebControls/TValidationSummary.php | 72 ++++++-- framework/Web/UI/WebControls/TWizard.php | 98 +++++++--- 58 files changed, 1746 insertions(+), 638 deletions(-) (limited to 'framework') diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php index e18de7ab..eabe20dc 100644 --- a/framework/Exceptions/TErrorHandler.php +++ b/framework/Exceptions/TErrorHandler.php @@ -130,7 +130,7 @@ class TErrorHandler extends TModule header('Content-Type: text/html; charset=UTF-8'); if($param instanceof THttpException) $this->handleExternalError($param->getStatusCode(),$param); - else if($this->getApplication()->getMode()===TApplication::STATE_DEBUG) + else if($this->getApplication()->getMode()===TApplicationMode::Debug) $this->displayException($param); else $this->handleExternalError(500,$param); @@ -183,7 +183,7 @@ class TErrorHandler extends TModule */ protected function handleRecursiveError($exception) { - if($this->getApplication()->getMode()===TApplication::STATE_DEBUG) + if($this->getApplication()->getMode()===TApplicationMode::Debug) { echo "Recursive Error\n"; echo "

Recursive Error

\n"; diff --git a/framework/PradoBase.php b/framework/PradoBase.php index 9423fb7c..dc99ea34 100644 --- a/framework/PradoBase.php +++ b/framework/PradoBase.php @@ -489,9 +489,9 @@ class PradoBase */ public static function trace($msg,$category='Uncategorized') { - if(self::$_application && self::$_application->getMode()===TApplication::STATE_PERFORMANCE) + if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance) return; - if(self::$_application && self::$_application->getMode()===TApplication::STATE_DEBUG) + if(!self::$_application || self::$_application->getMode()===TApplicationMode::Debug) { $trace=debug_backtrace(); if(isset($trace[0]['file']) && isset($trace[0]['line'])) diff --git a/framework/Security/TSecurityManager.php b/framework/Security/TSecurityManager.php index b0ea4e95..89f3711a 100644 --- a/framework/Security/TSecurityManager.php +++ b/framework/Security/TSecurityManager.php @@ -43,11 +43,9 @@ class TSecurityManager extends TModule { const STATE_VALIDATION_KEY='prado:securitymanager:validationkey'; const STATE_ENCRYPTION_KEY='prado:securitymanager:encryptionkey'; - const STATE_INIT_VECTOR='prado:securitymanager:initvector'; private $_validationKey=null; private $_encryptionKey=null; - private $_initVector=null; - private $_validation='SHA1'; + private $_validation=TSecurityManagerValidationMode::SHA1; private $_encryption='3DES'; /** @@ -127,7 +125,7 @@ class TSecurityManager extends TModule } /** - * @return string hashing algorithm used to generate HMAC. Defaults to 'SHA1'. + * @return TSecurityManagerValidationMode hashing algorithm used to generate HMAC. Defaults to TSecurityManagerValidationMode::SHA1. */ public function getValidation() { @@ -135,11 +133,11 @@ class TSecurityManager extends TModule } /** - * @param string hashing algorithm used to generate HMAC. Valid values include 'SHA1' and 'MD5'. + * @param TSecurityManagerValidationMode hashing algorithm used to generate HMAC. */ public function setValidation($value) { - $this->_validation=TPropertyValue::ensureEnum($value,'SHA1','MD5'); + $this->_validation=TPropertyValue::ensureEnum($value,'TSecurityManagerValidationMode'); } /** @@ -260,4 +258,25 @@ class TSecurityManager extends TModule } } + +/** + * TSecurityManagerValidationMode class. + * TSecurityManagerValidationMode defines the enumerable type for the possible validation modes + * that can be used by {@link TSecurityManager}. + * + * The following enumerable values are defined: + * - MD5: an MD5 hash is generated from the data and used for validation. + * - SHA1: an SHA1 hash is generated from the data and used for validation. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Security + * @since 3.0.4 + */ +class TSecurityManagerValidationMode extends TEnumerable +{ + const MD5='MD5'; + const SHA1='SHA1'; +} + ?> \ No newline at end of file diff --git a/framework/Security/TUserManager.php b/framework/Security/TUserManager.php index 6b10fa8b..c0bbe65d 100644 --- a/framework/Security/TUserManager.php +++ b/framework/Security/TUserManager.php @@ -35,7 +35,7 @@ Prado::using('System.Security.TUser'); * similar to the above sample. * * The user passwords may be specified as clear text, SH1 or MD5 hashed by setting - * {@link setPasswordMode PasswordMode} as Clear, SH1 or MD5. + * {@link setPasswordMode PasswordMode} as Clear, SHA1 or MD5. * The default name for a guest user is Guest. It may be changed * by setting {@link setGuestName GuestName} property. * @@ -67,9 +67,9 @@ class TUserManager extends TModule implements IUserManager */ private $_guestName='Guest'; /** - * @var string password mode, Clear|MD5|SH1 + * @var TUserManagerPasswordMode password mode */ - private $_passwordMode='MD5'; + private $_passwordMode=TUserManagerPasswordMode::MD5; /** * @var boolean whether the module has been initialized */ @@ -186,7 +186,7 @@ class TUserManager extends TModule implements IUserManager } /** - * @return string (Clear|MD5|SH1) how password is stored, clear text, or MD5 or SH1 hashed. Default to MD5. + * @return TUserManagerPasswordMode how password is stored, clear text, or MD5 or SHA1 hashed. Default to TUserManagerPasswordMode::MD5. */ public function getPasswordMode() { @@ -194,11 +194,11 @@ class TUserManager extends TModule implements IUserManager } /** - * @param string (Clear|MD5|SH1) how password is stored, clear text, or MD5 or SH1 hashed. + * @param TUserManagerPasswordMode how password is stored, clear text, or MD5 or SHA1 hashed. */ public function setPasswordMode($value) { - $this->_passwordMode=TPropertyValue::ensureEnum($value,array('Clear','MD5','SHA1')); + $this->_passwordMode=TPropertyValue::ensureEnum($value,'TUserManagerPasswordMode'); } /** @@ -209,9 +209,9 @@ class TUserManager extends TModule implements IUserManager */ public function validateUser($username,$password) { - if($this->_passwordMode==='MD5') + if($this->_passwordMode===TUserManagerPasswordMode::MD5) $password=md5($password); - else if($this->_passwordMode==='SHA1') + else if($this->_passwordMode===TUserManagerPasswordMode::SHA1) $password=sha1($password); $username=strtolower($username); return (isset($this->_users[$username]) && $this->_users[$username]===$password); @@ -258,4 +258,26 @@ class TUserManager extends TModule implements IUserManager } } +/** + * TUserManagerPasswordMode class. + * TUserManagerPasswordMode defines the enumerable type for the possible modes + * that user passwords can be specified for a {@link TUserManager}. + * + * The following enumerable values are defined: + * - Clear: the password is in plain text + * - MD5: the password is recorded as the MD5 hash value of the original password + * - SHA1: the password is recorded as the SHA1 hash value of the original password + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Security + * @since 3.0.4 + */ +class TUserManagerPasswordMode extends TEnumerable +{ + const Clear='Clear'; + const MD5='MD5'; + const SHA1='SHA1'; +} + ?> \ No newline at end of file diff --git a/framework/TApplication.php b/framework/TApplication.php index 68064072..9d50aaf5 100644 --- a/framework/TApplication.php +++ b/framework/TApplication.php @@ -113,7 +113,8 @@ require_once(PRADO_DIR.'/I18N/TGlobalization.php'); class TApplication extends TComponent { /** - * application state + * possible application mode. + * @deprecated deprecated since version 3.0.4 (use TApplicationMode constants instead) */ const STATE_OFF='Off'; const STATE_DEBUG='Debug'; @@ -261,9 +262,9 @@ class TApplication extends TComponent */ private $_authRules=null; /** - * @var string application mode + * @var TApplicationMode application mode */ - private $_mode='Debug'; + private $_mode=TApplicationMode::Debug; /** * Constructor. @@ -466,7 +467,7 @@ class TApplication extends TComponent } /** - * @return string application mode (Off|Debug|Normal|Peformance), defaults to Debug. + * @return TApplicationMode application mode. Defaults to TApplicationMode::Debug. */ public function getMode() { @@ -474,11 +475,11 @@ class TApplication extends TComponent } /** - * @param string application mode. Valid values include Off, Debug, Normal, or Peformance + * @param TApplicationMode application mode */ public function setMode($value) { - $this->_mode=TPropertyValue::ensureEnum($value,array(self::STATE_OFF,self::STATE_DEBUG,self::STATE_NORMAL,self::STATE_PERFORMANCE)); + $this->_mode=TPropertyValue::ensureEnum($value,'TApplicationMode'); } /** @@ -1038,6 +1039,28 @@ class TApplication extends TComponent } } +/** + * TApplicationMode class. + * TApplicationMode defines the possible mode that an application can be set at by + * setting {@link TApplication::setMode Mode}. + * In particular, the following modes are defined + * - Off: the application is not running. Any request to the application will obtain an error. + * - Debug: the application is running in debug mode. + * - Debug: the application is running in normal production mode. + * - Performance: the application is running in performance mode. + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System + * @since 3.0.4 + */ +class TApplicationMode extends TEnumerable +{ + const Off='Off'; + const Debug='Debug'; + const Normal='Normal'; + const Performance='Performance'; +} + /** * TApplicationConfiguration class. diff --git a/framework/TComponent.php b/framework/TComponent.php index 21a62abd..986a0b32 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -443,6 +443,32 @@ class TComponent } } +/** + * TEnumerable class. + * TEnumerable is the base class for all enumerable types. + * To define an enumerable type, extend TEnumberable and define string constants. + * Each constant represents an enumerable value. + * The constant name must be the same as the constant value. + * For example, + * + * class TTextAlign extends TEnumerable + * { + * const Left='Left'; + * const Right='Right'; + * } + * + * Then, one can use the enumerable values such as TTextAlign::Left and + * TTextAlign::Right. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System + * @since 3.0 + */ +class TEnumerable +{ +} + /** * TPropertyValue class * @@ -568,19 +594,33 @@ class TPropertyValue /** * Converts a value to enum type. - * This method mainly performs sanity check of a value to make sure - * it is a valid enumeration value. Each enumeration value is a string - * which is case-sensistive. + * + * This method checks if the value is of the specified enumerable type. + * A value is a valid enumerable value if it is equal to the name of a constant + * in the specified enumerable type (class). + * For more details about enumerable, see {@link TEnumerable}. + * + * For backward compatibility, this method also supports sanity + * check of a string value to see if it is among the given list of strings. * @param mixed the value to be converted. - * @param mixed array of valid enumeration values. If this is not an array, - * the method considers its parameters are of variable length, and the second - * till the last parameters are enumeration values. + * @param mixed class name of the enumerable type, or array of valid enumeration values. If this is not an array, + * the method considers its parameters are of variable length, and the second till the last parameters are enumeration values. * @return string the valid enumeration value * @throws TInvalidDataValueException if the original value is not in the string array. */ public static function ensureEnum($value,$enums) { - if(!is_array($enums)) + static $types=array(); + if(func_num_args()===2 && is_string($enums)) + { + if(!isset($types[$enums])) + $types[$enums]=new ReflectionClass($enums); + if($types[$enums]->hasConstant($value)) + return $value; + else + throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,$enums); + } + else if(!is_array($enums)) { $enums=func_get_args(); array_shift($enums); diff --git a/framework/Util/TDataFieldAccessor.php b/framework/Util/TDataFieldAccessor.php index 6af972e9..a3dcbb00 100644 --- a/framework/Util/TDataFieldAccessor.php +++ b/framework/Util/TDataFieldAccessor.php @@ -50,7 +50,7 @@ class TDataFieldAccessor */ public static function getDataFieldValue($data,$field) { - if(Prado::getApplication()->getMode()===TApplication::STATE_PERFORMANCE) + if(Prado::getApplication()->getMode()===TApplicationMode::Performance) { if(is_array($data) || ($data instanceof ArrayAccess)) return $data[$field]; diff --git a/framework/Util/TDateTimeStamp.php b/framework/Util/TDateTimeStamp.php index d7093ec3..6a9c9553 100644 --- a/framework/Util/TDateTimeStamp.php +++ b/framework/Util/TDateTimeStamp.php @@ -30,6 +30,7 @@ if (!defined('ADODB_ALLOW_NEGATIVE_TS') && !defined('ADODB_NO_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1); + /** * TDateTimeStamp Class * @@ -697,4 +698,4 @@ class TDateTimeStamp } } -?> \ No newline at end of file +?> diff --git a/framework/Web/Javascripts/extended/event.js b/framework/Web/Javascripts/extended/event.js index 4fd041d8..e464fa94 100644 --- a/framework/Web/Javascripts/extended/event.js +++ b/framework/Web/Javascripts/extended/event.js @@ -82,10 +82,19 @@ Object.extend(Event, } else if(Event.isMouseEvent(type)) { - var event = document.createEvent('MouseEvents'); - event.initMouseEvent(type,true,true, - document.defaultView, 1, 0, 0, 0, 0, false, - false, false, false, 0, null); + var event = document.createEvent('MouseEvents'); + if (event.initMouseEvent) + { + event.initMouseEvent(type,true,true, + document.defaultView, 1, 0, 0, 0, 0, false, + false, false, false, 0, null); + } + else + { + // Safari + // TODO we should be initialising other mouse-event related attributes here + event.initEvent(type, true, true); + } } element.dispatchEvent(event); } diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js index b65892cc..645df359 100644 --- a/framework/Web/Javascripts/js/compressed/ajax.js +++ b/framework/Web/Javascripts/js/compressed/ajax.js @@ -210,7 +210,7 @@ Event.observe(this.element,"keydown",this.handleReturnKey.bind(this));Event.obse {this.options=options;this.baseInitialize(options.ID,options.ResultPanel,options);Object.extend(this.options,{onSuccess:this.onComplete.bind(this)});if(options.AutoPostBack) this.onInit(options);},doCallback:function(event,options) {if(!this.active) -{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}},onClick:function(event) +{request=new Prado.CallbackRequest(this.options.EventTarget,options);request.dispatch();Event.stop(event);}},onClick:function(event) {var element=Event.findElement(event,'LI');this.index=element.autocompleteIndex;this.selectEntry();this.hide();Event.fireEvent(this.element,"change");},getUpdatedChoices:function() {options=new Array(this.getToken(),"__TAutoComplete_onSuggest__");Prado.Callback(this.options.EventTarget,options,null,this.options);},onComplete:function(request,boundary) {result=Prado.Element.extractContent(request.transport.responseText,boundary);if(typeof(result)=="string"&&result.length>0) diff --git a/framework/Web/Javascripts/js/compressed/prado.js b/framework/Web/Javascripts/js/compressed/prado.js index d9eb1b8e..e565d59a 100644 --- a/framework/Web/Javascripts/js/compressed/prado.js +++ b/framework/Web/Javascripts/js/compressed/prado.js @@ -137,7 +137,10 @@ return element.submit();if(document.createEvent) {if(Event.isHTMLEvent(type)) {var event=document.createEvent('HTMLEvents');event.initEvent(type,true,true);} else if(Event.isMouseEvent(type)) -{var event=document.createEvent('MouseEvents');event.initMouseEvent(type,true,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null);} +{var event=document.createEvent('MouseEvents');if(event.initMouseEvent) +{event.initMouseEvent(type,true,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null);} +else +{event.initEvent(type,true,true);}} element.dispatchEvent(event);} else if(document.createEventObject) {var evObj=document.createEventObject();element.fireEvent('on'+type,evObj);} @@ -377,7 +380,7 @@ Event.observe(this.element,"keydown",this.handleReturnKey.bind(this));Event.obse {this.options=options;this._event=this.triggerEvent.bindEvent(this);Event.observe(options['Panel'],'keydown',this._event);},triggerEvent:function(ev,target) {var enterPressed=Event.keyCode(ev)==Event.KEY_RETURN;var isTextArea=Event.element(ev).tagName.toLowerCase()=="textarea";if(enterPressed&&!isTextArea) {var defaultButton=$(this.options['Target']);if(defaultButton) -{this.triggered=true;Event.fireEvent(defaultButton,this.options['Event']);Event.stop(ev);}}}};Prado.WebUI.TTextHighlighter=Class.create();Prado.WebUI.TTextHighlighter.prototype={initialize:function(id) +{this.triggered=true;$('PRADO_POSTBACK_TARGET').value=this.options.EventTarget;Event.fireEvent(defaultButton,this.options['Event']);Event.stop(ev);}}}};Prado.WebUI.TTextHighlighter=Class.create();Prado.WebUI.TTextHighlighter.prototype={initialize:function(id) {if(!window.clipboardData)return;var options={href:'javascript:;/'+'/copy code to clipboard',onclick:'Prado.WebUI.TTextHighlighter.copy(this)',onmouseover:'Prado.WebUI.TTextHighlighter.hover(this)',onmouseout:'Prado.WebUI.TTextHighlighter.out(this)'} var div=DIV({className:'copycode'},A(options,'Copy Code'));document.write(DIV(null,div).innerHTML);}};Object.extend(Prado.WebUI.TTextHighlighter,{copy:function(obj) {var parent=obj.parentNode.parentNode.parentNode;var text='';for(var i=0;i */ @@ -564,7 +564,7 @@ Prado.WebUI.TBaseValidator.prototype = * options['ID']* Validator ID, e.g. span with message * options['FormID']* HTML form that the validator belongs * options['ControlToValidate']*HTML form input to validate - * options['Display'] Display mode, 'None', 'Static', 'Dynamic' + * options['Display'] Display mode, 'None', 'Fixed', 'Dynamic' * options['ErrorMessage'] Validation error message * options['FocusOnError'] True to focus on validation error * options['FocusElementID'] Element to focus on error diff --git a/framework/Web/Javascripts/prado/controls.js b/framework/Web/Javascripts/prado/controls.js index 25e1315b..8595b5fd 100644 --- a/framework/Web/Javascripts/prado/controls.js +++ b/framework/Web/Javascripts/prado/controls.js @@ -220,6 +220,7 @@ Prado.WebUI.DefaultButton.prototype = if(defaultButton) { this.triggered = true; + $('PRADO_POSTBACK_TARGET').value = this.options.EventTarget; Event.fireEvent(defaultButton, this.options['Event']); Event.stop(ev); } diff --git a/framework/Web/Javascripts/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js index f2b3cbb3..4e30b0b2 100644 --- a/framework/Web/Javascripts/prado/validation3.js +++ b/framework/Web/Javascripts/prado/validation3.js @@ -357,7 +357,7 @@ Prado.WebUI.TValidationSummary.prototype = * options['DisplayMode'] Summary display style, 'BulletList', 'List', 'SingleParagraph' * options['Refresh'] True to update the summary upon validator state change. * options['ValidationGroup'] Validation summary group - * options['Display'] Display mode, 'None', 'Static', 'Dynamic'. + * options['Display'] Display mode, 'None', 'Fixed', 'Dynamic'. * options['ScrollToSummary'] True to scroll to the validation summary upon refresh. * */ @@ -564,7 +564,7 @@ Prado.WebUI.TBaseValidator.prototype = * options['ID']* Validator ID, e.g. span with message * options['FormID']* HTML form that the validator belongs * options['ControlToValidate']*HTML form input to validate - * options['Display'] Display mode, 'None', 'Static', 'Dynamic' + * options['Display'] Display mode, 'None', 'Fixed', 'Dynamic' * options['ErrorMessage'] Validation error message * options['FocusOnError'] True to focus on validation error * options['FocusElementID'] Element to focus on error diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php index 5172f59c..6d3a69c7 100644 --- a/framework/Web/Services/TPageService.php +++ b/framework/Web/Services/TPageService.php @@ -244,7 +244,7 @@ class TPageService extends TService if(is_array($arr)) { list($pageConfig,$timestamps)=$arr; - if($application->getMode()!==TApplication::STATE_PERFORMANCE) + if($application->getMode()!==TApplicationMode::Performance) { foreach($timestamps as $fileName=>$timestamp) { diff --git a/framework/Web/TAssetManager.php b/framework/Web/TAssetManager.php index add4b930..733a2051 100644 --- a/framework/Web/TAssetManager.php +++ b/framework/Web/TAssetManager.php @@ -162,14 +162,14 @@ class TAssetManager extends TModule $dir=$this->hash(dirname($fullpath)); $fileName=basename($fullpath); $dst=$this->_basePath.'/'.$dir; - if($this->getApplication()->getMode()!==TApplication::STATE_PERFORMANCE || $checkTimestamp || !is_file($dst.'/'.$fileName)) + if(!is_file($dst.'/'.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) $this->copyFile($fullpath,$dst); return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; } else { $dir=$this->hash($fullpath); - if($this->getApplication()->getMode()!==TApplication::STATE_PERFORMANCE || $checkTimestamp || !is_dir($this->_basePath.'/'.$dir)) + if(!is_dir($this->_basePath.'/'.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) { Prado::trace("Publishing directory $fullpath",'System.Web.UI.TAssetManager'); $this->copyDirectory($fullpath,$this->_basePath.'/'.$dir); @@ -202,7 +202,7 @@ class TAssetManager extends TModule { @mkdir($dst); @chmod($dst, 0777); - } + } $dstFile=$dst.'/'.basename($src); if(@filemtime($dstFile)<@filemtime($src)) { @@ -263,7 +263,7 @@ class TAssetManager extends TModule $dir=$this->hash(dirname($fullpath)); $fileName=basename($fullpath); $dst=$this->_basePath.'/'.$dir; - if($this->getApplication()->getMode()!==TApplication::STATE_PERFORMANCE || $checkTimestamp || !is_file($dst.'/'.$fileName)) + if(!is_file($dst.'/'.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) { if(@filemtime($dst.'/'.$fileName)<@filemtime($fullpath)) { @@ -296,4 +296,4 @@ class TAssetManager extends TModule } -?> \ No newline at end of file +?> diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 130dc3cf..bac43057 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -88,7 +88,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar */ private $_pathInfo; - private $_urlFormat='Get'; + private $_urlFormat=THttpRequestUrlFormat::Get; private $_services; private $_requestResolved=false; private $_enableCookieValidation=false; @@ -160,7 +160,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar $_COOKIE=$this->stripSlashes($_COOKIE); } - if($this->getUrlFormat()==='Path' && ($pathInfo=trim($this->_pathInfo,'/'))!=='') + if($this->getUrlFormat()===THttpRequestUrlFormat::Path && ($pathInfo=trim($this->_pathInfo,'/'))!=='') $this->_items=array_merge($this->parseUrl(),$_POST); else $this->_items=array_merge($_GET,$_POST); @@ -205,7 +205,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } /** - * @return string the format of URLs. Defaults to 'Get'. + * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. */ public function getUrlFormat() { @@ -214,15 +214,15 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar /** * Sets the format of URLs constructed and interpretted by the request module. - * A 'Get' URL format is like index.php?name1=value1&name2=value2 - * while a 'Path' URL format is like index.php/name1,value1/name2,value. + * A Get URL format is like index.php?name1=value1&name2=value2 + * while a Path URL format is like index.php/name1,value1/name2,value. * Changing the UrlFormat will affect {@link constructUrl} and how GET variables * are parsed. - * @param string the format of URLs. Valid values include 'Path' and 'Get'. + * @param THttpRequestUrlFormat the format of URLs. */ public function setUrlFormat($value) { - $this->_urlFormat=TPropertyValue::ensureEnum($value,'Path','Get'); + $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); } /** @@ -467,7 +467,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar * If you do so, you may also need to override {@link parseUrl} so that the URL can be properly parsed. * The URL is constructed as the following format: * /entryscript.php?serviceID=serviceParameter&get1=value1&... - * If {@link setUrlFormat UrlFormat} is 'Path', the following format is used instead: + * If {@link setUrlFormat UrlFormat} is Path, the following format is used instead: * /entryscript.php/serviceID/serviceParameter/get1,value1/get2,value2... * @param string service ID * @param string service parameter @@ -511,7 +511,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } } } - if($this->getUrlFormat()==='Path') + if($this->getUrlFormat()===THttpRequestUrlFormat::Path) { $url=strtr($url,array($amp=>'/','?'=>'/','='=>$this->_separator)); if(defined('SID') && SID != '' && !((int)ini_get('session.use_cookies')===1 && ((int)ini_get('session.use_only_cookies')===1))) @@ -528,7 +528,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar /** * Parses the request URL and returns an array of input parameters (including GET variables). - * This method is invoked when the URL format is 'Path'. + * This method is invoked when the URL format is Path. * You may override this method to support customized URL format. * @return array list of input parameters, indexed by parameter names * @see constructUrl @@ -1199,4 +1199,24 @@ class TUri extends TComponent } } +/** + * THttpRequestUrlFormat class. + * THttpRequestUrlFormat defines the enumerable type for the possible URL formats + * that can be recognized by {@link THttpRequest}. + * + * The following enumerable values are defined: + * - Get: the URL format is like /path/to/index.php?name1=value1&name2=value2... + * - Path: the URL format is like /path/to/index.php/name1,value1/name2,value2... + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web + * @since 3.0.4 + */ +class THttpRequestUrlFormat extends TEnumerable +{ + const Get='Get'; + const Path='Path'; +} + ?> \ No newline at end of file diff --git a/framework/Web/THttpSession.php b/framework/Web/THttpSession.php index 19473cda..eefe50e5 100644 --- a/framework/Web/THttpSession.php +++ b/framework/Web/THttpSession.php @@ -271,22 +271,20 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar } /** - * @return string (None|Allow|Only) how to use cookie to store session ID - * 'None' means not using cookie, 'Allow' means using cookie, and 'Only' means using cookie only, defaults to 'Allow'. + * @return THttpSessionCookieMode how to use cookie to store session ID. Defaults to THttpSessionCookieMode::Allow. */ public function getCookieMode() { if(ini_get('session.use_cookies')==='0') - return 'None'; + return THttpSessionCookieMode::None; else if(ini_get('session.use_only_cookies')==='0') - return 'Allow'; + return THttpSessionCookieMode::Allow; else - return 'Only'; + return THttpSessionCookieMode::Only; } /** - * @param string (None|Allow|Only) how to use cookie to store session ID - * 'None' means not using cookie, 'Allow' means using cookie, and 'Only' means using cookie only. + * @param THttpSessionCookieMode how to use cookie to store session ID * @throws TInvalidOperationException if session is started already */ public function setCookieMode($value) @@ -295,10 +293,10 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); else { - $value=TPropertyValue::ensureEnum($value,array('None','Allow','Only')); - if($value==='None') + $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); + if($value===THttpSessionCookieMode::None) ini_set('session.use_cookies','0'); - else if($value==='Allow') + else if($value===THttpSessionCookieMode::Allow) { ini_set('session.use_cookies','1'); ini_set('session.use_only_cookies','0'); @@ -695,4 +693,28 @@ class TSessionIterator implements Iterator return $this->_key!==false; } } + + +/** + * THttpSessionCookieMode class. + * THttpSessionCookieMode defines the enumerable type for the possible methods of + * using cookies to store session ID. + * + * The following enumerable values are defined: + * - None: not using cookie. + * - Allow: using cookie. + * - Only: using cookie only. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web + * @since 3.0.4 + */ +class THttpSessionCookieMode extends TEnumerable +{ + const None='None'; + const Allow='Allow'; + const Only='Only'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 18d6089e..73564e69 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -151,7 +151,7 @@ class TClientScriptManager extends TApplicationComponent protected function getPradoScriptBasePath() { $basePath = Prado::getFrameworkPath().'/'.self::SCRIPT_PATH; - if($this->getApplication()->getMode()===TApplication::STATE_DEBUG) + if($this->getApplication()->getMode()===TApplicationMode::Debug) return $basePath.'/debug'; else return $basePath.'/compressed'; @@ -169,7 +169,7 @@ class TClientScriptManager extends TApplicationComponent $basePath=$this->getPradoScriptBasePath(); $scriptLoader=$basePath.'/'.self::SCRIPT_LOADER; $url=$this->publishFilePath($scriptLoader).'?js='.trim($files,','); - if($this->getApplication()->getMode()===TApplication::STATE_DEBUG) + if($this->getApplication()->getMode()===TApplicationMode::Debug) $url.='&mode=debug'; $writer->write(TJavaScript::renderScriptFile($url)); } @@ -235,15 +235,16 @@ class TClientScriptManager extends TApplicationComponent /** * Register a default button to panel. When the $panel is in focus and * the 'enter' key is pressed, the $button will be clicked. - * @param string client ID of the container object - * @param string client ID of the button + * @param TControl panel to register the default button action + * @param TControl button to trigger a postback */ - public function registerDefaultButton($containerID, $buttonID) + public function registerDefaultButton($panel, $button) { - $options = TJavaScript::encode($this->getDefaultButtonOptions($containerID, $buttonID)); + $options = TJavaScript::encode($this->getDefaultButtonOptions($panel, $button)); $code = "new Prado.WebUI.DefaultButton($options);"; - $this->_endScripts['prado:'.$containerID]=$code; + $this->_endScripts['prado:'.$panel->getClientID()]=$code; + $this->_hiddenFields[TPage::FIELD_POSTBACK_TARGET]=''; $this->registerPradoScriptInternal('prado'); $params=func_get_args(); @@ -267,14 +268,15 @@ class TClientScriptManager extends TApplicationComponent } /** - * @param string client ID of the container object - * @param string client ID of the button + * @param TControl container control + * @param IButtonControl button control * @return array default button options. */ - protected function getDefaultButtonOptions($containerID, $buttonID) + protected function getDefaultButtonOptions($panel, $button) { - $options['Panel'] = $containerID; - $options['Target'] = $buttonID; + $options['Panel'] = $panel->getClientID(); + $options['Target'] = $button->getClientID(); + $options['EventTarget'] = $button->getUniqueID(); $options['Event'] = 'click'; return $options; } diff --git a/framework/Web/UI/TForm.php b/framework/Web/UI/TForm.php index e70d894a..f9fd507a 100644 --- a/framework/Web/UI/TForm.php +++ b/framework/Web/UI/TForm.php @@ -58,7 +58,7 @@ class TForm extends TControl if(($butt=$this->getDefaultButton())!=='') { if(($button=$this->findControl($butt))!==null) - $this->getPage()->getClientScript()->registerDefaultButton($this->getClientID(),$button->getClientID()); + $this->getPage()->getClientScript()->registerDefaultButton($this, $button); else throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt); } diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 2bdfd3cf..fe8482ce 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -843,13 +843,17 @@ class TPage extends TTemplateControl if($control->loadPostData($key,$postData)) $this->_controlsPostDataChanged[]=$control; } - else if($control instanceof IPostBackEventHandler) + else if($control instanceof IPostBackEventHandler && + empty($this->_postData[self::FIELD_POSTBACK_TARGET])) + { $this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); // not calling setPostBackEventTarget() because the control may be removed later + } unset($this->_controlsRequiringPostData[$key]); } else if($beforeLoad) $this->_restPostData->add($key,$value); } + foreach($this->_controlsRequiringPostData as $key=>$value) { if($control=$this->findControl($key)) diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php index 1d80d0c5..ce96a6b4 100644 --- a/framework/Web/UI/TThemeManager.php +++ b/framework/Web/UI/TThemeManager.php @@ -240,7 +240,7 @@ class TTheme extends TApplicationComponent implements ITheme if(is_array($array)) { list($skins,$cssFiles,$jsFiles,$timestamp)=$array; - if($this->getApplication()->getMode()!==TApplication::STATE_PERFORMANCE) + if($this->getApplication()->getMode()!==TApplicationMode::Performance) { if(($dir=opendir($themePath))===false) throw new TIOException('theme_path_inexistent',$themePath); diff --git a/framework/Web/UI/WebControls/TBaseDataList.php b/framework/Web/UI/WebControls/TBaseDataList.php index a8ab8faf..2884ec22 100644 --- a/framework/Web/UI/WebControls/TBaseDataList.php +++ b/framework/Web/UI/WebControls/TBaseDataList.php @@ -53,39 +53,6 @@ abstract class TBaseDataList extends TDataBoundControl return new TTableStyle; } - /** - * @return string caption of the table layout - */ - public function getCaption() - { - return $this->getViewState('Caption',''); - } - - /** - * @param string caption of the table layout - */ - public function setCaption($value) - { - $this->setViewState('Caption',''); - } - - /** - * @return string alignment of the caption of the table layout. Defaults to 'NotSet'. - */ - public function getCaptionAlign() - { - return $this->getViewState('CaptionAlign','NotSet'); - } - - /** - * @return string alignment of the caption of the table layout. - * Valid values include 'NotSet','Top','Bottom','Left','Right'. - */ - public function setCaptionAlign($value) - { - $this->setViewState('CaptionAlign',TPropertyValue::ensureEnum($value,'NotSet','Top','Bottom','Left','Right'),'NotSet'); - } - /** * @return integer the cellspacing for the table layout. Defaults to -1, meaning not set. */ @@ -125,19 +92,18 @@ abstract class TBaseDataList extends TDataBoundControl } /** - * @return string the horizontal alignment of the table content. Defaults to 'NotSet'. + * @return THorizontalAlign the horizontal alignment of the table content. Defaults to THorizontalAlign::NotSet. */ public function getHorizontalAlign() { if($this->getHasStyle()) return $this->getStyle()->getHorizontalAlign(); else - return 'NotSet'; + return THorizontalAlign::NotSet; } /** - * @param string the horizontal alignment of the table content. - * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center'. + * @param THorizontalAlign the horizontal alignment of the table content. */ public function setHorizontalAlign($value) { @@ -145,20 +111,19 @@ abstract class TBaseDataList extends TDataBoundControl } /** - * @return string the grid line setting of the table layout. Defaults to 'None'. + * @return TTableGridLines the grid line setting of the table layout. Defaults to TTableGridLines::None. */ public function getGridLines() { if($this->getHasStyle()) return $this->getStyle()->getGridLines(); else - return 'None'; + return TTableGridLines::None; } /** * Sets the grid line style of the table layout. - * Valid values include 'None', 'Horizontal', 'Vertical', 'Both'. - * @param string the grid line setting of the table + * @param TTableGridLines the grid line setting of the table */ public function setGridLines($value) { diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index a6d044ff..bc8c3607 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -137,7 +137,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::ensureEnum($value,'TValidatorDisplayStyle'),TValidatorDisplayStyle::Fixed); } /** @@ -676,4 +675,51 @@ 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'; +} + +/** + * TValidationDataType class. + * TValidationDataType defines the enumerable type for the possible data types that + * a comparison validator can validate upon. + * + * The following enumerable values are defined: + * - Integer + * - Float + * - Date + * - String + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TValidationDataType extends TEnumerable +{ + const Integer='Integer'; + const Float='Float'; + const Date='Date'; + const String='String'; +} + ?> diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php index c47b1035..f7bcc5ac 100644 --- a/framework/Web/UI/WebControls/TBulletedList.php +++ b/framework/Web/UI/WebControls/TBulletedList.php @@ -24,7 +24,7 @@ Prado::using('System.Web.UI.WebControls.TListControl'); * specifies the image used as bullets. * * TBulletedList displays the item texts in three different modes, specified - * via {@link setDisplayMode DisplayMode}. When the mode is 'Text', the item texts + * via {@link setDisplayMode DisplayMode}. When the mode is Text, the item texts * are displayed as static texts; When the mode is 'HyperLink', each item * is displayed as a hyperlink whose URL is given by the item value, and the * {@link setTarget Target} property can be used to specify the target browser window; @@ -73,11 +73,11 @@ class TBulletedList extends TListControl implements IPostBackEventHandler { switch($this->getBulletStyle()) { - case 'Numbered': - case 'LowerAlpha': - case 'UpperAlpha': - case 'LowerRoman': - case 'UpperRoman': + case TBulletStyle::Numbered: + case TBulletStyle::LowerAlpha: + case TBulletStyle::UpperAlpha: + case TBulletStyle::LowerRoman: + case TBulletStyle::UpperRoman: return 'ol'; } return 'ul'; @@ -103,36 +103,36 @@ class TBulletedList extends TListControl implements IPostBackEventHandler $needStart=false; switch($this->getBulletStyle()) { - case 'Numbered': + case TBulletStyle::Numbered: $writer->addStyleAttribute('list-style-type','decimal'); $needStart=true; break; - case 'LowerAlpha': + case TBulletStyle::LowerAlpha: $writer->addStyleAttribute('list-style-type','lower-alpha'); $needStart=true; break; - case 'UpperAlpha': + case TBulletStyle::UpperAlpha: $writer->addStyleAttribute('list-style-type','upper-alpha'); $needStart=true; break; - case 'LowerRoman': + case TBulletStyle::LowerRoman: $writer->addStyleAttribute('list-style-type','lower-roman'); $needStart=true; break; - case 'UpperRoman': + case TBulletStyle::UpperRoman: $writer->addStyleAttribute('list-style-type','upper-roman'); $needStart=true; break; - case 'Disc': + case TBulletStyle::Disc: $writer->addStyleAttribute('list-style-type','disc'); break; - case 'Circle': + case TBulletStyle::Circle: $writer->addStyleAttribute('list-style-type','circle'); break; - case 'Square': + case TBulletStyle::Square: $writer->addStyleAttribute('list-style-type','square'); break; - case 'CustomImage': + case TBulletStyle::CustomImage: $url=$this->getBulletImageUrl(); $writer->addStyleAttribute('list-style-image',"url($url)"); break; @@ -159,37 +159,35 @@ class TBulletedList extends TListControl implements IPostBackEventHandler } /** - * @return string style of bullets. Defaults to 'NotSet'. + * @return TBulletStyle style of bullets. Defaults to TBulletStyle::NotSet. */ public function getBulletStyle() { - return $this->getViewState('BulletStyle','NotSet'); + return $this->getViewState('BulletStyle',TBulletStyle::NotSet); } /** - * @param string style of bullets. Valid values include - * 'NotSet','Numbered','LowerAlpha','UpperAlpha','LowerRoman','UpperRoman','Disc','Circle','Square','CustomImage' + * @param TBulletStyle style of bullets. */ public function setBulletStyle($value) { - $this->setViewState('BulletStyle',TPropertyValue::ensureEnum($value,'NotSet','Numbered','LowerAlpha','UpperAlpha','LowerRoman','UpperRoman','Disc','Circle','Square','CustomImage'),'NotSet'); + $this->setViewState('BulletStyle',TPropertyValue::ensureEnum($value,'TBulletStyle'),TBulletStyle::NotSet); } /** - * @return string display mode of the list. Defaults to 'Text'. + * @return TBulletedListDisplayMode display mode of the list. Defaults to TBulletedListDisplayMode::Text. */ public function getDisplayMode() { - return $this->getViewState('DisplayMode','Text'); + return $this->getViewState('DisplayMode',TBulletedListDisplayMode::Text); } /** - * @return string display mode of the list. Valid values include - * 'Text', 'HyperLink', 'LinkButton'. + * @return TBulletedListDisplayMode display mode of the list. */ public function setDisplayMode($value) { - $this->setViewState('DisplayMode',TPropertyValue::ensureEnum($value,'Text','HyperLink','LinkButton'),'Text'); + $this->setViewState('DisplayMode',TPropertyValue::ensureEnum($value,'TBulletedListDisplayMode'),TBulletedListDisplayMode::Text); } /** @@ -282,13 +280,13 @@ class TBulletedList extends TListControl implements IPostBackEventHandler { switch($this->getDisplayMode()) { - case 'Text': + case TBulletedListDisplayMode::Text: $this->renderTextItem($writer, $item, $index); break; - case 'HyperLink': + case TBulletedListDisplayMode::HyperLink: $this->renderHyperLinkItem($writer, $item, $index); break; - case 'LinkButton': + case TBulletedListDisplayMode::LinkButton: $this->renderLinkButtonItem($writer, $item, $index); break; } @@ -440,4 +438,51 @@ class TBulletedListEventParameter extends TEventParameter return $this->_index; } } + +/** + * TBulletStyle class. + * TBulletStyle defines the enumerable type for the possible bullet styles that may be used + * for a {@link TBulletedList} control. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TBulletStyle extends TEnumerable +{ + const NotSet='NotSet'; + const Numbered='Numbered'; + const LowerAlpha='LowerAlpha'; + const UpperAlpha='UpperAlpha'; + const LowerRoman='LowerRoman'; + const UpperRoman='UpperRoman'; + const Disc='Disc'; + const Circle='Circle'; + const Square='Square'; + const CustomImage='CustomImage'; +} + +/** + * TBulletedListDisplayMode class. + * TBulletedListDisplayMode defines the enumerable type for the possible display mode + * of a {@link TBulletedList} control. + * + * The following enumerable values are defined: + * - Text: the bulleted list items are displayed as plain texts + * - HyperLink: the bulleted list items are displayed as hyperlinks + * - LinkButton: the bulleted list items are displayed as link buttons that can cause postbacks + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TBulletedListDisplayMode extends TEnumerable +{ + const Text='Text'; + const HyperLink='HyperLink'; + const LinkButton='LinkButton'; +} + ?> diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index f1132625..1dd239a4 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -119,7 +119,7 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr */ protected function needPostBackScript() { - return $this->canCauseValidation() || ($this->getButtonType()!=='Submit' && + return $this->canCauseValidation() || ($this->getButtonType()!==TButtonType::Submit && ($this->hasEventHandler('OnClick') || $this->hasEventHandler('OnCommand'))); } @@ -270,20 +270,41 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr } /** - * @return string the type of the button. Defaults to 'Submit'. + * @return TButtonType the type of the button. Defaults to TButtonType::Submit. */ public function getButtonType() { - return $this->getViewState('ButtonType','Submit'); + return $this->getViewState('ButtonType',TButtonType::Submit); } /** - * @param string the type of the button. Valid values include 'Submit', 'Reset', 'Button'. + * @param TButtonType the type of the button. */ public function setButtonType($value) { - $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'Submit','Reset','Button'),'Submit'); + $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'TButtonType'),TButtonType::Submit); } } +/** + * TButtonType class. + * TButtonType defines the enumerable type for the possible types that a {@link TButton} can take. + * + * The following enumerable values are defined: + * - Submit: a normal submit button + * - Reset: a reset button + * - Button: a client button (normally does not perform form submission) + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TButtonType extends TEnumerable +{ + const Submit='Submit'; + const Reset='Reset'; + const Button='Button'; +} + ?> diff --git a/framework/Web/UI/WebControls/TButtonColumn.php b/framework/Web/UI/WebControls/TButtonColumn.php index fdcf58d3..5f2c228d 100644 --- a/framework/Web/UI/WebControls/TButtonColumn.php +++ b/framework/Web/UI/WebControls/TButtonColumn.php @@ -152,19 +152,19 @@ class TButtonColumn extends TDataGridColumn } /** - * @return string the type of command button. Defaults to LinkButton. + * @return TButtonColumnType the type of command button. Defaults to TButtonColumnType::LinkButton. */ public function getButtonType() { - return $this->getViewState('ButtonType','LinkButton'); + return $this->getViewState('ButtonType',TButtonColumnType::LinkButton); } /** - * @param string the type of command button, LinkButton, PushButton or ImageButton + * @param TButtonColumnType the type of command button */ public function setButtonType($value) { - $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'LinkButton','PushButton','ImageButton'),'LinkButton'); + $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'TButtonColumnType'),TButtonColumnType::LinkButton); } /** @@ -230,9 +230,9 @@ class TButtonColumn extends TDataGridColumn if($itemType===TDataGrid::IT_ITEM || $itemType===TDataGrid::IT_ALTERNATINGITEM || $itemType===TDataGrid::IT_SELECTEDITEM || $itemType===TDataGrid::IT_EDITITEM) { $buttonType=$this->getButtonType(); - if($buttonType==='LinkButton') + if($buttonType===TButtonColumnType::LinkButton) $button=new TLinkButton; - else if($buttonType==='PushButton') + else if($buttonType===TButtonColumnType::PushButton) $button=new TButton; else // image button { @@ -243,7 +243,7 @@ class TButtonColumn extends TDataGridColumn $button->setCommandName($this->getCommandName()); $button->setCausesValidation($this->getCausesValidation()); $button->setValidationGroup($this->getValidationGroup()); - if($this->getDataTextField()!=='' || ($buttonType==='ImageButton' && $this->getDataImageUrlField()!=='')) + if($this->getDataTextField()!=='' || ($buttonType===TButtonColumnType::ImageButton && $this->getDataImageUrlField()!=='')) $button->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); $cell->getControls()->add($button); $cell->registerObject('Button',$button); diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index c938950d..84138ffe 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -147,19 +147,19 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl } /** - * @return string the alignment (Left or Right) of the text caption, defaults to Right. + * @return TTextAlign the alignment (Left or Right) of the text caption, defaults to TTextAlign::Right. */ public function getTextAlign() { - return $this->getViewState('TextAlign','Right'); + return $this->getViewState('TextAlign',TTextAlign::Right); } /** - * @param string the alignment of the text caption. Valid values include Left and Right. + * @param TTextAlign the alignment of the text caption. Valid values include Left and Right. */ public function setTextAlign($value) { - $this->setViewState('TextAlign',TPropertyValue::ensureEnum($value,array('Left','Right')),'Right'); + $this->setViewState('TextAlign',TPropertyValue::ensureEnum($value,'TTextAlign'),TTextAlign::Right); } /** @@ -270,7 +270,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $clientID=$this->getClientID(); if(($text=$this->getText())!=='') { - if($this->getTextAlign()==='Left') + if($this->getTextAlign()===TTextAlign::Left) { $this->renderLabel($writer,$clientID,$text); $this->renderInputTag($writer,$clientID,$onclick); @@ -422,4 +422,23 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl } +/** + * TTextAlign class. + * TTextAlign defines the enumerable type for the possible text alignments + * + * The following enumerable values are defined: + * - Left: left aligned + * - Right: right aligned + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TTextAlign extends TEnumerable +{ + const Left='Left'; + const Right='Right'; +} + ?> diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index e6ca3642..21cc330b 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -116,20 +116,19 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont } /** - * @return string the alignment of the text caption, defaults to 'Right'. + * @return TTextAlign the alignment of the text caption, defaults to TTextAlign::Right. */ public function getTextAlign() { - return $this->getViewState('TextAlign','Right'); + return $this->getViewState('TextAlign',TTextAlign::Right); } /** - * Sets the text alignment of the checkboxes - * @param string either 'Left' or 'Right' + * @param TTextAlign the text alignment of the checkboxes */ public function setTextAlign($value) { - $this->setViewState('TextAlign',TPropertyValue::ensureEnum($value,array('Left','Right')),'Right'); + $this->setViewState('TextAlign',TPropertyValue::ensureEnum($value,'TTextAlign'),TTextAlign::Right); } diff --git a/framework/Web/UI/WebControls/TColorPicker.php b/framework/Web/UI/WebControls/TColorPicker.php index 7b40f033..a1284b5e 100644 --- a/framework/Web/UI/WebControls/TColorPicker.php +++ b/framework/Web/UI/WebControls/TColorPicker.php @@ -40,19 +40,19 @@ class TColorPicker extends TTextBox } /** - * @param string color picker UI mode, "Simple", "Basic" or "Full", default is "Basic" + * @param TColorPickerMode color picker UI mode */ public function setMode($value) { - $this->setViewState('Mode', TPropertyValue::ensureEnum($value, 'Simple', 'Basic', 'Full'), 'Basic'); + $this->setViewState('Mode', TPropertyValue::ensureEnum($value, 'TColorPickerMode'), TColorPickerMode::Basic); } /** - * @return string current color picker UI mode. + * @return TColorPickerMode current color picker UI mode. Defaults to TColorPickerMode::Basic. */ public function getMode() { - return $this->getViewState('Mode', 'Basic'); + return $this->getViewState('Mode', TColorPickerMode::Basic); } /** @@ -117,8 +117,8 @@ class TColorPicker extends TTextBox { $mode = $this->getMode(); - if($mode == 'Full') $options['Mode'] = $mode; - else if($mode == 'Simple') $options['Palette'] = 'Tiny'; + if($mode == TColorPickerMode::Full) $options['Mode'] = $mode; + else if($mode == TColorPickerMode::Simple) $options['Palette'] = 'Tiny'; $options['OKButtonText'] = $this->getOKButtonText(); $options['CancelButtonText'] = $this->getCancelButtonText(); @@ -242,4 +242,26 @@ class TColorPicker extends TTextBox } } +/** + * TColorPickerMode class. + * TColorPickerMode defines the enumerable type for the possible UI mode + * that a {@link TColorPicker} control can take. + * + * The following enumerable values are defined: + * - Simple + * - Basic + * - Full + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TColorPickerMode extends TEnumerable +{ + const Simple='Simple'; + const Basic='Basic'; + const Full='Full'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php index 93664b2e..2b1028ef 100644 --- a/framework/Web/UI/WebControls/TCompareValidator.php +++ b/framework/Web/UI/WebControls/TCompareValidator.php @@ -57,21 +57,21 @@ class TCompareValidator extends TBaseValidator } /** - * @return string the data type that the values being compared are converted to before the comparison is made. Defaults to String. + * @return TValidationDataType the data type that the values being compared are converted to before the comparison is made. Defaults to TValidationDataType::String. */ public function getDataType() { - return $this->getViewState('DataType','String'); + return $this->getViewState('DataType',TValidationDataType::String); } /** - * Sets the data type (Integer, Float, Date, String) that the values being + * Sets the data type that the values being * compared are converted to before the comparison is made. - * @param string the data type + * @param TValidationDataType the data type */ public function setDataType($value) { - $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'Integer','Float','Date','String'),'String'); + $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'TValidationDataType'),TValidationDataType::String); } /** @@ -109,20 +109,20 @@ class TCompareValidator extends TBaseValidator } /** - * @return string the comparison operation to perform (Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual). Defaults to Equal. + * @return TValidationCompareOperator the comparison operation to perform. Defaults to TValidationCompareOperator::Equal. */ public function getOperator() { - return $this->getViewState('Operator','Equal'); + return $this->getViewState('Operator',TValidationCompareOperator::Equal); } /** - * Sets the comparison operation to perform (Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual) - * @param string the comparison operation + * Sets the comparison operation to perform + * @param TValidationCompareOperator the comparison operation */ public function setOperator($value) { - $this->setViewState('Operator',TPropertyValue::ensureEnum($value,'Equal','NotEqual','GreaterThan','GreaterThanEqual','LessThan','LessThanEqual'),'Equal'); + $this->setViewState('Operator',TPropertyValue::ensureEnum($value,'TValidationCompareOperator'),TValidationCompareOperator::Equal); } /** @@ -167,17 +167,17 @@ class TCompareValidator extends TBaseValidator $values = $this->getComparisonValues($value, $value2); switch($this->getOperator()) { - case 'Equal': + case TValidationCompareOperator::Equal: return $values[0] == $values[1]; - case 'NotEqual': + case TValidationCompareOperator::NotEqual: return $values[0] != $values[1]; - case 'GreaterThan': + case TValidationCompareOperator::GreaterThan: return $values[0] > $values[1]; - case 'GreaterThanEqual': + case TValidationCompareOperator::GreaterThanEqual: return $values[0] >= $values[1]; - case 'LessThan': + case TValidationCompareOperator::LessThan: return $values[0] < $values[1]; - case 'LessThanEqual': + case TValidationCompareOperator::LessThanEqual: return $values[0] <= $values[1]; } @@ -194,11 +194,11 @@ class TCompareValidator extends TBaseValidator { switch($this->getDataType()) { - case 'Integer': + case TValidationDataType::Integer: return array(intval($value1), intval($value2)); - case 'Float': + case TValidationDataType::Float: return array(floatval($value1), floatval($value2)); - case 'Date': + case TValidationDataType::Date: $dateFormat = $this->getDateFormat(); if($dateFormat!=='') { @@ -225,7 +225,7 @@ class TCompareValidator extends TBaseValidator } if(($value=$this->getValueToCompare())!=='') $options['ValueToCompare']=$value; - if(($operator=$this->getOperator())!=='Equal') + if(($operator=$this->getOperator())!==TValidationCompareOperator::Equal) $options['Operator']=$operator; $options['DataType']=$this->getDataType(); if(($dateFormat=$this->getDateFormat())!=='') @@ -234,4 +234,33 @@ class TCompareValidator extends TBaseValidator } } + +/** + * TValidationCompareOperator class. + * TValidationCompareOperator defines the enumerable type for the comparison operations + * that {@link TCompareValidator} can perform validation with. + * + * The following enumerable values are defined: + * - Equal + * - NotEqual + * - GreaterThan + * - GreaterThanEqual + * - LessThan + * - LessThanEqual + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TValidationCompareOperator extends TEnumerable +{ + const Equal='Equal'; + const NotEqual='NotEqual'; + const GreaterThan='GreaterThan'; + const GreaterThanEqual='GreaterThanEqual'; + const LessThan='LessThan'; + const LessThanEqual='LessThanEqual'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TDataBoundControl.php b/framework/Web/UI/WebControls/TDataBoundControl.php index 38ed42dd..3f8ddc7e 100644 --- a/framework/Web/UI/WebControls/TDataBoundControl.php +++ b/framework/Web/UI/WebControls/TDataBoundControl.php @@ -506,4 +506,37 @@ abstract class TDataBoundControl extends TWebControl } } + +/** + * TListItemType class. + * TListItemType defines the enumerable type for the possible types + * that databound list items could take. + * + * The following enumerable values are defined: + * - Header: header item + * - Footer: footer item + * - Item: content item (neither header nor footer) + * - Separator: separator between items + * - AlternatingItem: alternating content item + * - EditItem: content item in edit mode + * - SelectedItem: selected content item + * - Pager: pager + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TListItemType extends TEnumerable +{ + const Header='Header'; + const Footer='Footer'; + const Item='Item'; + const Separator='Separator'; + const AlternatingItem='AlternatingItem'; + const EditItem='EditItem'; + const SelectedItem='SelectedItem'; + const Pager='Pager'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php index ad30ff3f..48b6a8c9 100644 --- a/framework/Web/UI/WebControls/TDataGrid.php +++ b/framework/Web/UI/WebControls/TDataGrid.php @@ -45,8 +45,8 @@ Prado::using('System.Web.UI.WebControls.TPanel'); * * Each datagrid item has a {@link TDataGridItem::getItemType type} * which tells the position and state of the item in the datalist. An item in the header - * of the repeater is of type 'Header'. A body item may be of either - * 'Item', 'AlternatingItem', 'SelectedItem' or 'EditItem', depending whether the item + * of the repeater is of type Header. A body item may be of either + * Item, AlternatingItem, SelectedItem or EditItem, depending whether the item * index is odd or even, whether it is being selected or edited. * * A datagrid is specified with a list of columns. Each column specifies how the corresponding @@ -151,6 +151,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer { /** * datagrid item types + * @deprecated deprecated since version 3.0.4. Use TListItemType constants instead. */ const IT_HEADER='Header'; const IT_FOOTER='Footer'; @@ -406,20 +407,19 @@ class TDataGrid extends TBaseDataList implements INamingContainer } /** - * @return string datagrid caption alignment. Defaults to 'NotSet'. + * @return TTableCaptionAlign datagrid caption alignment. Defaults to TTableCaptionAlign::NotSet. */ public function getCaptionAlign() { - return $this->getViewState('CaptionAlign','NotSet'); + return $this->getViewState('CaptionAlign',TTableCaptionAlign::NotSet); } /** - * @param string datagrid caption alignment. Valid values include - * 'NotSet','Top','Bottom','Left','Right'. + * @param TTableCaptionAlign datagrid caption alignment. Valid values include */ public function setCaptionAlign($value) { - $this->setViewState('CaptionAlign',TPropertyValue::ensureEnum($value,'NotSet','Top','Bottom','Left','Right'),'NotSet'); + $this->setViewState('CaptionAlign',TPropertyValue::ensureEnum($value,'TTableCaptionAlign'),TTableCaptionAlign::NotSet); } /** @@ -495,14 +495,14 @@ class TDataGrid extends TBaseDataList implements INamingContainer if($current>=0 && $current<$itemCount) { $item=$items->itemAt($current); - if($item->getItemType()!==self::IT_EDITITEM) - $item->setItemType($current%2?self::IT_ALTERNATINGITEM:self::IT_ITEM); + if($item->getItemType()!==TListItemType::EditItem) + $item->setItemType($current%2?TListItemType::AlternatingItem:TListItemType::Item); } if($value>=0 && $value<$itemCount) { $item=$items->itemAt($value); - if($item->getItemType()!==self::IT_EDITITEM) - $item->setItemType(self::IT_SELECTEDITEM); + if($item->getItemType()!==TListItemType::EditItem) + $item->setItemType(TListItemType::SelectedItem); } } } @@ -545,9 +545,9 @@ class TDataGrid extends TBaseDataList implements INamingContainer $items=$this->getItems(); $itemCount=$items->getCount(); if($current>=0 && $current<$itemCount) - $items->itemAt($current)->setItemType($current%2?self::IT_ALTERNATINGITEM:self::IT_ITEM); + $items->itemAt($current)->setItemType($current%2?TListItemType::AlternatingItem:TListItemType::Item); if($value>=0 && $value<$itemCount) - $items->itemAt($value)->setItemType(self::IT_EDITITEM); + $items->itemAt($value)->setItemType(TListItemType::EditItem); } } @@ -923,22 +923,22 @@ class TDataGrid extends TBaseDataList implements INamingContainer { if($allowPaging) $this->_topPager=$this->createPager(); - $this->_header=$this->createItemInternal(-1,-1,self::IT_HEADER,false,null,$columns); + $this->_header=$this->createItemInternal(-1,-1,TListItemType::Header,false,null,$columns); } if($index===$editIndex) - $itemType=self::IT_EDITITEM; + $itemType=TListItemType::EditItem; else if($index===$selectedIndex) - $itemType=self::IT_SELECTEDITEM; + $itemType=TListItemType::SelectedItem; else if($index % 2) - $itemType=self::IT_ALTERNATINGITEM; + $itemType=TListItemType::AlternatingItem; else - $itemType=self::IT_ITEM; + $itemType=TListItemType::Item; $items->add($this->createItemInternal($index,$dsIndex,$itemType,false,null,$columns)); $dsIndex++; } if($index>0) { - $this->_footer=$this->createItemInternal(-1,-1,self::IT_FOOTER,false,null,$columns); + $this->_footer=$this->createItemInternal(-1,-1,TListItemType::Footer,false,null,$columns); if($allowPaging) $this->_bottomPager=$this->createPager(); } @@ -996,23 +996,23 @@ class TDataGrid extends TBaseDataList implements INamingContainer { if($allowPaging) $this->_topPager=$this->createPager(); - $this->_header=$this->createItemInternal(-1,-1,self::IT_HEADER,true,null,$columns); + $this->_header=$this->createItemInternal(-1,-1,TListItemType::Header,true,null,$columns); } if($index===$editIndex) - $itemType=self::IT_EDITITEM; + $itemType=TListItemType::EditItem; else if($index===$selectedIndex) - $itemType=self::IT_SELECTEDITEM; + $itemType=TListItemType::SelectedItem; else if($index % 2) - $itemType=self::IT_ALTERNATINGITEM; + $itemType=TListItemType::AlternatingItem; else - $itemType=self::IT_ITEM; + $itemType=TListItemType::Item; $items->add($this->createItemInternal($index,$dsIndex,$itemType,true,$row,$columns)); $index++; $dsIndex++; } if($index>0) { - $this->_footer=$this->createItemInternal(-1,-1,self::IT_FOOTER,true,null,$columns); + $this->_footer=$this->createItemInternal(-1,-1,TListItemType::Footer,true,null,$columns); if($allowPaging) $this->_bottomPager=$this->createPager(); } @@ -1029,7 +1029,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer /** * Creates a datagrid item instance based on the item type and index. * @param integer zero-based item index - * @param string item type, may be self::IT_HEADER, self::IT_FOOTER, self::IT_ITEM, self::IT_SEPARATOR, self::IT_ALTERNATINGITEM, self::IT_SELECTEDITEM, self::IT_EDITITEM. + * @param TListItemType item type * @return TDataGridItem created data list item */ protected function createItem($itemIndex,$dataSourceIndex,$itemType) @@ -1071,15 +1071,12 @@ class TDataGrid extends TBaseDataList implements INamingContainer $index=0; foreach($columns as $column) { - if($itemType===self::IT_HEADER) + if($itemType===TListItemType::Header) $cell=new TTableHeaderCell; else $cell=new TTableCell; if(($id=$column->getID())!=='') - { - $cell->setID($id); $item->registerObject($id,$cell); - } $column->initializeCell($cell,$index,$itemType); $cells->add($cell); $index++; @@ -1103,10 +1100,10 @@ class TDataGrid extends TBaseDataList implements INamingContainer { switch($this->getPagerStyle()->getMode()) { - case 'NextPrev': + case TDataGridPagerMode::NextPrev: $this->buildNextPrevPager($pager); break; - case 'Numeric': + case TDataGridPagerMode::Numeric: $this->buildNumericPager($pager); break; } @@ -1126,7 +1123,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer */ protected function createPagerButton($buttonType,$enabled,$text,$commandName,$commandParameter) { - if($buttonType==='LinkButton') + if($buttonType===TDataGridPagerButtonType::LinkButton) { if($enabled) $button=new TLinkButton; @@ -1268,9 +1265,9 @@ class TDataGrid extends TBaseDataList implements INamingContainer } else { - $column->setHeaderText(self::IT_ITEM); + $column->setHeaderText(TListItemType::Item); $column->setDataField($key); - $column->setSortExpression(self::IT_ITEM); + $column->setSortExpression(TListItemType::Item); $autoColumns->add($column); } } @@ -1326,31 +1323,31 @@ class TDataGrid extends TBaseDataList implements INamingContainer $itemType=$item->getItemType(); switch($itemType) { - case self::IT_HEADER: + case TListItemType::Header: if($headerStyle) $item->getStyle()->mergeWith($headerStyle); if(!$this->getShowHeader()) $item->setVisible(false); break; - case self::IT_FOOTER: + case TListItemType::Footer: if($footerStyle) $item->getStyle()->mergeWith($footerStyle); if(!$this->getShowFooter()) $item->setVisible(false); break; - case self::IT_SEPARATOR: + case TListItemType::Separator: if($separatorStyle) $item->getStyle()->mergeWith($separatorStyle); break; - case self::IT_ITEM: + case TListItemType::Item: if($itemStyle) $item->getStyle()->mergeWith($itemStyle); break; - case self::IT_ALTERNATINGITEM: + case TListItemType::AlternatingItem: if($alternatingItemStyle) $item->getStyle()->mergeWith($alternatingItemStyle); break; - case self::IT_SELECTEDITEM: + case TListItemType::SelectedItem: if($selectedItemStyle) $item->getStyle()->mergeWith($selectedItemStyle); if($index % 2==1) @@ -1364,7 +1361,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer $item->getStyle()->mergeWith($alternatingItemStyle); } break; - case self::IT_EDITITEM: + case TListItemType::EditItem: if($editItemStyle) $item->getStyle()->mergeWith($editItemStyle); if($index % 2==1) @@ -1378,18 +1375,18 @@ class TDataGrid extends TBaseDataList implements INamingContainer $item->getStyle()->mergeWith($alternatingItemStyle); } break; - case self::IT_PAGER: + case TListItemType::Pager: if($pagerStyle) { $item->getStyle()->mergeWith($pagerStyle); if($index===0) { - if($pagerStyle->getPosition()==='Bottom' || !$pagerStyle->getVisible()) + if($pagerStyle->getPosition()===TDataGridPagerPosition::Bottom || !$pagerStyle->getVisible()) $item->setVisible(false); } else { - if($pagerStyle->getPosition()==='Top' || !$pagerStyle->getVisible()) + if($pagerStyle->getPosition()===TDataGridPagerPosition::Top || !$pagerStyle->getVisible()) $item->setVisible(false); } } @@ -1397,7 +1394,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer default: break; } - if($this->_columns && $itemType!==self::IT_PAGER) + if($this->_columns && $itemType!==TListItemType::Pager) { $n=$this->_columns->getCount(); $cells=$item->getCells(); @@ -1409,9 +1406,9 @@ class TDataGrid extends TBaseDataList implements INamingContainer $cell->setVisible(false); else { - if($itemType===self::IT_HEADER) + if($itemType===TListItemType::Header) $style=$column->getHeaderStyle(false); - else if($itemType===self::IT_FOOTER) + else if($itemType===TListItemType::Footer) $style=$column->getFooterStyle(false); else $style=$column->getItemStyle(false); @@ -1432,7 +1429,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer parent::renderBeginTag($writer); if(($caption=$this->getCaption())!=='') { - if(($align=$this->getCaptionAlign())!=='NotSet') + if(($align=$this->getCaptionAlign())!==TTableCaptionAlign::NotSet) $writer->addAttribute('align',strtolower($align)); $writer->renderBeginTag('caption'); $writer->write($caption); @@ -1789,21 +1786,21 @@ class TDataGridItem extends TTableRow implements INamingContainer /** * Constructor. * @param integer zero-based index of the item in the item collection of datagrid - * @param string item type, can be 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'. + * @param TListItemType item type */ public function __construct($itemIndex,$dataSourceIndex,$itemType) { $this->_itemIndex=$itemIndex; $this->_dataSourceIndex=$dataSourceIndex; $this->setItemType($itemType); - if($itemType===TDataGrid::IT_HEADER) - $this->setTableSection('Header'); - else if($itemType===TDataGrid::IT_FOOTER) - $this->setTableSection('Footer'); + if($itemType===TListItemType::Header) + $this->setTableSection(TTableRowSection::Header); + else if($itemType===TListItemType::Footer) + $this->setTableSection(TTableRowSection::Footer); } /** - * @return string item type. + * @return TListItemType item type. */ public function getItemType() { @@ -1811,11 +1808,11 @@ class TDataGridItem extends TTableRow implements INamingContainer } /** - * @param string item type, can be 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager' + * @param TListItemType item type */ public function setItemType($value) { - $this->_itemType=$value; + $this->_itemType=TPropertyValue::ensureEnum($value,'TListItemType'); } /** @@ -1924,7 +1921,7 @@ class TDataGridPager extends TPanel implements INamingContainer */ public function getItemType() { - return TDataGrid::IT_PAGER; + return TListItemType::Pager; } } @@ -2032,35 +2029,35 @@ class TDataGridPagerStyle extends TPanelStyle private $_buttonType=null; /** - * @return string pager mode. Defaults to 'NextPrev'. + * @return TDataGridPagerMode pager mode. Defaults to TDataGridPagerMode::NextPrev. */ public function getMode() { - return $this->_mode===null?'NextPrev':$this->_mode; + return $this->_mode===null?TDataGridPagerMode::NextPrev : $this->_mode; } /** - * @param string pager mode. Valid values include 'NextPrev' and 'Numeric'. + * @param TDataGridPagerMode pager mode. */ public function setMode($value) { - $this->_mode=TPropertyValue::ensureEnum($value,'NextPrev','Numeric'); + $this->_mode=TPropertyValue::ensureEnum($value,'TDataGridPagerMode'); } /** - * @return string the type of command button. Defaults to LinkButton. + * @return TDataGridPagerButtonType the type of command button. Defaults to TDataGridPagerButtonType::LinkButton. */ public function getButtonType() { - return $this->_buttonType===null?'LinkButton':$this->_buttonType; + return $this->_buttonType===null?TDataGridPagerButtonType::LinkButton:$this->_buttonType; } /** - * @param string the type of command button, LinkButton or PushButton + * @param TDataGridPagerButtonType the type of command button */ public function setButtonType($value) { - $this->_buttonType=TPropertyValue::ensureEnum($value,'LinkButton','PushButton'); + $this->_buttonType=TPropertyValue::ensureEnum($value,'TDataGridPagerButtonType'); } /** @@ -2115,19 +2112,19 @@ class TDataGridPagerStyle extends TPanelStyle } /** - * @return string where the pager is to be displayed. Defaults to 'Bottom'. + * @return TDataGridPagerPosition where the pager is to be displayed. Defaults to TDataGridPagerPosition::Bottom. */ public function getPosition() { - return $this->_position===null?'Bottom':$this->_position; + return $this->_position===null?TDataGridPagerPosition::Bottom:$this->_position; } /** - * @param string where the pager is to be displayed. Valid values include 'Bottom', 'Top', 'TopAndBottom' + * @param TDataGridPagerPosition where the pager is to be displayed. */ public function setPosition($value) { - $this->_position=TPropertyValue::ensureEnum($value,'Bottom','Top','TopAndBottom'); + $this->_position=TPropertyValue::ensureEnum($value,'TDataGridPagerPosition'); } /** @@ -2218,4 +2215,66 @@ class TDataGridPagerStyle extends TPanelStyle } } + +/** + * TDataGridPagerMode class. + * TDataGridPagerMode defines the enumerable type for the possible modes that a datagrid pager can take. + * + * The following enumerable values are defined: + * - NextPrev: pager buttons are displayed as next and previous pages + * - Numeric: pager buttons are displayed as numeric page numbers + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TDataGridPagerMode extends TEnumerable +{ + const NextPrev='NextPrev'; + const Numeric='Numeric'; +} + + +/** + * TDataGridPagerButtonType class. + * TDataGridPagerButtonType defines the enumerable type for the possible types of datagrid pager buttons. + * + * The following enumerable values are defined: + * - LinkButton: link buttons + * - PushButton: form submit buttons + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TDataGridPagerButtonType extends TEnumerable +{ + const LinkButton='LinkButton'; + const PushButton='PushButton'; +} + + +/** + * TDataGridPagerPosition class. + * TDataGridPagerPosition defines the enumerable type for the possible positions that a datagrid pager can be located at. + * + * The following enumerable values are defined: + * - Bottom: pager appears only at the bottom of the data grid. + * - Top: pager appears only at the top of the data grid. + * - TopAndBottom: pager appears on both top and bottom of the data grid. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TDataGridPagerPosition extends TEnumerable +{ + const Bottom='Bottom'; + const Top='Top'; + const TopAndBottom='TopAndBottom'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TDataGridColumn.php b/framework/Web/UI/WebControls/TDataGridColumn.php index 8c34b85f..dacc7206 100644 --- a/framework/Web/UI/WebControls/TDataGridColumn.php +++ b/framework/Web/UI/WebControls/TDataGridColumn.php @@ -388,4 +388,27 @@ abstract class TDataGridColumn extends TApplicationComponent } } + +/** + * TButtonColumnType class. + * TButtonColumnType defines the enumerable type for the possible types of buttons + * that can be used in a {@link TButtonColumn}. + * + * The following enumerable values are defined: + * - LinkButton: link buttons + * - PushButton: form buttons + * - ImageButton: image buttons + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TButtonColumnType extends TEnumerable +{ + const LinkButton='LinkButton'; + const PushButton='PushButton'; + const ImageButton='ImageButton'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php index 22bec07e..c0aa5da6 100644 --- a/framework/Web/UI/WebControls/TDataList.php +++ b/framework/Web/UI/WebControls/TDataList.php @@ -87,8 +87,8 @@ Prado::using('System.Web.UI.WebControls.TRepeatInfo'); * * Each datalist item has a {@link TDataListItem::getItemType type} * which tells the position and state of the item in the datalist. An item in the header - * of the repeater is of type 'Header'. A body item may be of either - * 'Item', 'AlternatingItem', 'SelectedItem' or 'EditItem', depending whether the item + * of the repeater is of type Header. A body item may be of either + * Item, AlternatingItem, SelectedItem or EditItem, depending whether the item * index is odd or even, whether it is being selected or edited. * * TDataList raises an {@link onItemCommand OnItemCommand} whenever a button control @@ -458,14 +458,14 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs if($current>=0 && $current<$itemCount) { $item=$items->itemAt($current); - if($item->getItemType()!=='EditItem') - $item->setItemType($current%2?'AlternatingItem':'Item'); + if($item->getItemType()!==TListItemType::EditItem) + $item->setItemType($current%2?TListItemType::AlternatingItem : TListItemType::Item); } if($value>=0 && $value<$itemCount) { $item=$items->itemAt($value); - if($item->getItemType()!=='EditItem') - $item->setItemType('SelectedItem'); + if($item->getItemType()!==TListItemType::EditItem) + $item->setItemType(TListItemType::SelectedItem); } } } @@ -524,9 +524,9 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs $items=$this->getItems(); $itemCount=$items->getCount(); if($current>=0 && $current<$itemCount) - $items->itemAt($current)->setItemType($current%2?'AlternatingItem':'Item'); + $items->itemAt($current)->setItemType($current%2?TListItemType::AlternatingItem : TListItemType::Item); if($value>=0 && $value<$itemCount) - $items->itemAt($value)->setItemType('EditItem'); + $items->itemAt($value)->setItemType(TListItemType::EditItem); } } @@ -605,7 +605,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs } /** - * @return string alignment of the caption of the table layout. Defaults to 'NotSet'. + * @return TTableCaptionAlign alignment of the caption of the table layout. Defaults to TTableCaptionAlign::NotSet. */ public function getCaptionAlign() { @@ -613,8 +613,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs } /** - * @return string alignment of the caption of the table layout. - * Valid values include 'NotSet','Top','Bottom','Left','Right'. + * @return TTableCaptionAlign alignment of the caption of the table layout. */ public function setCaptionAlign($value) { @@ -638,7 +637,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs } /** - * @return string the direction of traversing the list, defaults to 'Vertical' + * @return TRepeatDirection the direction of traversing the list, defaults to TRepeatDirection::Vertical */ public function getRepeatDirection() { @@ -646,7 +645,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs } /** - * @param string the direction (Vertical, Horizontal) of traversing the list + * @param TRepeatDirection the direction of traversing the list */ public function setRepeatDirection($value) { @@ -654,7 +653,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs } /** - * @return string how the list should be displayed, using table or using line breaks. Defaults to 'Table'. + * @return TRepeatLayout how the list should be displayed, using table or using line breaks. Defaults to TRepeatLayout::Table. */ public function getRepeatLayout() { @@ -662,7 +661,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs } /** - * @param string how the list should be displayed, using table or using line breaks (Table, Flow, Raw) + * @param TRepeatLayout how the list should be displayed, using table or using line breaks */ public function setRepeatLayout($value) { @@ -875,14 +874,14 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs { switch($itemType) { - case 'Header': return $this->getControls()->itemAt(0); - case 'Footer': return $this->getControls()->itemAt($this->getControls()->getCount()-1); - case 'Item': - case 'AlternatingItem': - case 'SelectedItem': - case 'EditItem': + case TListItemType::Header: return $this->getControls()->itemAt(0); + case TListItemType::Footer: return $this->getControls()->itemAt($this->getControls()->getCount()-1); + case TListItemType::Item: + case TListItemType::AlternatingItem: + case TListItemType::SelectedItem: + case TListItemType::EditItem: return $this->getItems()->itemAt($index); - case 'Separator': + case TListItemType::Separator: $i=$index+$index+1; if($this->_headerTemplate!==null) $i++; @@ -895,7 +894,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs * Creates a data list item and does databinding if needed. * This method invokes {@link createItem} to create a new data list item. * @param integer zero-based item index. - * @param string item type, may be 'Header', 'Footer', 'Item', 'Separator', 'AlternatingItem', 'SelectedItem', 'EditItem'. + * @param TListItemType item type * @param boolean whether to do databinding for the item * @param mixed data to be associated with the item * @return TDataListItem the created item @@ -925,7 +924,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs /** * Creates a DataList item instance based on the item type and index. * @param integer zero-based item index - * @param string item type, may be 'Header', 'Footer', 'Item', 'Separator', 'AlternatingItem', 'SelectedItem', 'EditItem'. + * @param TListItemType item type * @return TDataListItem created data list item */ protected function createItem($itemIndex,$itemType) @@ -978,27 +977,27 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs continue; switch($item->getItemType()) { - case 'Header': + case TListItemType::Header: if($headerStyle) $item->getStyle()->mergeWith($headerStyle); break; - case 'Footer': + case TListItemType::Footer: if($footerStyle) $item->getStyle()->mergeWith($footerStyle); break; - case 'Separator': + case TListItemType::Separator: if($separatorStyle) $item->getStyle()->mergeWith($separatorStyle); break; - case 'Item': + case TListItemType::Item: if($itemStyle) $item->getStyle()->mergeWith($itemStyle); break; - case 'AlternatingItem': + case TListItemType::AlternatingItem: if($alternatingItemStyle) $item->getStyle()->mergeWith($alternatingItemStyle); break; - case 'SelectedItem': + case TListItemType::SelectedItem: if($selectedItemStyle) $item->getStyle()->mergeWith($selectedItemStyle); if($index % 2==1) @@ -1012,7 +1011,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs $item->getStyle()->mergeWith($alternatingItemStyle); } break; - case 'EditItem': + case TListItemType::EditItem: if($editItemStyle) $item->getStyle()->mergeWith($editItemStyle); if($index % 2==1) @@ -1043,30 +1042,30 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs $template=null; switch($item->getItemType()) { - case 'Header': + case TListItemType::Header: $template=$this->_headerTemplate; break; - case 'Footer': + case TListItemType::Footer: $template=$this->_footerTemplate; break; - case 'Item': + case TListItemType::Item: $template=$this->_itemTemplate; break; - case 'AlternatingItem': + case TListItemType::AlternatingItem: if(($template=$this->_alternatingItemTemplate)===null) $template=$this->_itemTemplate; break; - case 'Separator': + case TListItemType::Separator: $template=$this->_separatorTemplate; break; - case 'SelectedItem': + case TListItemType::SelectedItem: if(($template=$this->_selectedItemTemplate)===null) { if(!($item->getItemIndex()%2) || ($template=$this->_alternatingItemTemplate)===null) $template=$this->_itemTemplate; } break; - case 'EditItem': + case TListItemType::EditItem: if(($template=$this->_editItemTemplate)===null) { if($item->getItemIndex()!==$this->getSelectedItemIndex() || ($template=$this->_selectedItemTemplate)===null) @@ -1130,21 +1129,21 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs $editIndex=$this->getEditItemIndex(); $hasSeparator=$this->_separatorTemplate!==null; if($this->_headerTemplate!==null) - $this->_header=$this->createItemInternal(-1,'Header',false,null); + $this->_header=$this->createItemInternal(-1,TListItemType::Header,false,null); for($i=0;$i<$itemCount;++$i) { if($hasSeparator && $i>0) - $this->createItemInternal($i-1,'Separator',false,null); + $this->createItemInternal($i-1,TListItemType::Separator,false,null); if($i===$editIndex) - $itemType='EditItem'; + $itemType=TListItemType::EditItem; else if($i===$selectedIndex) - $itemType='SelectedItem'; + $itemType=TListItemType::SelectedItem; else - $itemType=$i%2?'AlternatingItem':'Item'; + $itemType=$i%2?TListItemType::AlternatingItem : TListItemType::Item; $items->add($this->createItemInternal($i,$itemType,false,null)); } if($this->_footerTemplate!==null) - $this->_footer=$this->createItemInternal(-1,'Footer',false,null); + $this->_footer=$this->createItemInternal(-1,TListItemType::Footer,false,null); } else if($this->_emptyTemplate!==null) $this->_emptyTemplate->instantiateIn($this); @@ -1175,20 +1174,20 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs else $keys->add($key); if($itemIndex===0 && $this->_headerTemplate!==null) - $this->_header=$this->createItemInternal(-1,'Header',true,null); + $this->_header=$this->createItemInternal(-1,TListItemType::Header,true,null); if($hasSeparator && $itemIndex>0) - $this->createItemInternal($itemIndex-1,'Separator',true,null); + $this->createItemInternal($itemIndex-1,TListItemType::Separator,true,null); if($itemIndex===$editIndex) - $itemType='EditItem'; + $itemType=TListItemType::EditItem; else if($itemIndex===$selectedIndex) - $itemType='SelectedItem'; + $itemType=TListItemType::SelectedItem; else - $itemType=$itemIndex%2?'AlternatingItem':'Item'; + $itemType=$itemIndex%2?TListItemType::AlternatingItem : TListItemType::Item; $items->add($this->createItemInternal($itemIndex,$itemType,true,$dataItem)); $itemIndex++; } if($itemIndex>0 && $this->_footerTemplate!==null) - $this->_footer=$this->createItemInternal(-1,'Footer',true,null); + $this->_footer=$this->createItemInternal(-1,TListItemType::Footer,true,null); if($itemIndex===0 && $this->_emptyTemplate!==null) { $this->_emptyTemplate->instantiateIn($this); @@ -1335,9 +1334,9 @@ class TDataListItem extends TWebControl implements INamingContainer private $_itemIndex=''; /** * type of the TDataListItem - * @var string + * @var TListItemType */ - private $_itemType=''; + private $_itemType; /** * value of the data item * @var mixed @@ -1347,7 +1346,7 @@ class TDataListItem extends TWebControl implements INamingContainer /** * Constructor. * @param integer zero-based index of the item in the item collection of DataList - * @param string item type, can be 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'. + * @param TListItemType item type */ public function __construct($itemIndex,$itemType) { @@ -1366,7 +1365,7 @@ class TDataListItem extends TWebControl implements INamingContainer } /** - * @return string item type + * @return TListItemType item type */ public function getItemType() { @@ -1374,11 +1373,11 @@ class TDataListItem extends TWebControl implements INamingContainer } /** - * @param string item type. Valid values include 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'. + * @param TListItemType item type. */ public function setItemType($value) { - $this->_itemType=TPropertyValue::ensureEnum($value,'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'); + $this->_itemType=TPropertyValue::ensureEnum($value,'TListItemType'); } /** diff --git a/framework/Web/UI/WebControls/TDataTypeValidator.php b/framework/Web/UI/WebControls/TDataTypeValidator.php index ec39e8a3..e6cdb30e 100644 --- a/framework/Web/UI/WebControls/TDataTypeValidator.php +++ b/framework/Web/UI/WebControls/TDataTypeValidator.php @@ -47,7 +47,7 @@ class TDataTypeValidator extends TBaseValidator } /** - * @return string the data type that the values being compared are converted to before the comparison is made. Defaults to String. + * @return TValidationDataType the data type that the values being compared are converted to before the comparison is made. Defaults to TValidationDataType::String. */ public function getDataType() { @@ -55,13 +55,12 @@ class TDataTypeValidator extends TBaseValidator } /** - * Sets the data type (Integer, Float, Date, String) that the values being - * compared are converted to before the comparison is made. - * @param string the data type + * Sets the data type that the values being compared are converted to before the comparison is made. + * @param TValidationDataType the data type */ public function setDataType($value) { - $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'Integer','Float','Date','String'),'String'); + $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'TValidationDataType'),TValidationDataType::String); } /** @@ -94,11 +93,11 @@ class TDataTypeValidator extends TBaseValidator switch($this->getDataType()) { - case 'Integer': + case TValidationDataType::Integer: return preg_match('/^[-+]?[0-9]+$/',trim($value)); - case 'Float': + case TValidationDataType::Float: return preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/',trim($value)); - case 'Date': + case TValidationDataType::Date: $dateFormat = $this->getDateFormat(); if(strlen($dateFormat)) { diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 2a9340e5..73a69abc 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -131,30 +131,36 @@ class TDatePicker extends TTextBox $this->setViewState('Culture', $value, ''); } + /** + * @param TDatePickerInputMode input method of date values + */ public function setInputMode($value) { - $this->setViewState('InputMode', TPropertyValue::ensureEnum($value, 'TextBox', 'DropDownList'), 'TextBox'); + $this->setViewState('InputMode', TPropertyValue::ensureEnum($value, 'TDatePickerInputMode'), TDatePickerInputMode::TextBox); } + /** + * @return TDatePickerInputMode input method of date values. Defaults to TDatePickerInputMode::TextBox. + */ public function getInputMode() { - return $this->getViewState('InputMode', 'TextBox'); + return $this->getViewState('InputMode', TDatePickerInputMode::TextBox); } /** - * @param string calendar UI mode, "Basic", "Button" or "ImageButton" + * @param TDatePickerMode calendar UI mode */ public function setMode($value) { - $this->setViewState('Mode', TPropertyValue::ensureEnum($value, 'Basic', 'Button', 'ImageButton'), 'Basic'); + $this->setViewState('Mode', TPropertyValue::ensureEnum($value, 'TDatePickerMode'), TDatePickerMode::Basic); } /** - * @return string current calendar UI mode. + * @return TDatePickerMode current calendar UI mode. */ public function getMode() { - return $this->getViewState('Mode', 'Basic'); + return $this->getViewState('Mode', TDatePickerMode::Basic); } /** * @param string the image url for "Image" UI mode. @@ -340,12 +346,12 @@ class TDatePicker extends TTextBox /** * Renders body content. * This method overrides parent implementation by adding - * additional date picker button if Mode is "Button" or "ImageButton". + * additional date picker button if Mode is Button or ImageButton. * @param THtmlWriter writer */ public function render($writer) { - if($this->getInputMode() == 'TextBox') + if($this->getInputMode() == TDatePickerInputMode::TextBox) { parent::render($writer); $this->renderDatePickerButtons($writer); @@ -370,8 +376,8 @@ class TDatePicker extends TTextBox { switch ($this->getMode()) { - case 'Button': $this->renderButtonDatePicker($writer); break; - case 'ImageButton' : $this->renderImageButtonDatePicker($writer); break; + case TDatePickerMode::Button: $this->renderButtonDatePicker($writer); break; + case TDatePickerMode::ImageButton : $this->renderImageButtonDatePicker($writer); break; } } } @@ -386,7 +392,7 @@ class TDatePicker extends TTextBox */ public function loadPostData($key,$values) { - if($this->getInputMode() == "TextBox") + if($this->getInputMode() == TDatePickerInputMode::TextBox) return parent::loadPostData($key, $values); $value = $this->getDateFromPostData($key, $values); if(!$this->getReadOnly() && $this->getText()!==$value) @@ -447,7 +453,7 @@ class TDatePicker extends TTextBox $options['ClassName'] = $cssClass; $options['FromYear'] = $this->getFromYear(); $options['UpToYear'] = $this->getUpToYear(); - if($this->getMode()!=='Basic') + if($this->getMode()!==TDatePickerMode::Basic) $options['Trigger'] = $this->getDatePickerButtonID(); $options = array_merge($options, $this->getCulturalOptions()); @@ -501,8 +507,8 @@ class TDatePicker extends TTextBox */ protected function renderDropDownListCalendar($writer) { - if($this->getMode() == 'Basic') - $this->setMode('ImageButton'); + if($this->getMode() == TDatePickerMode::Basic) + $this->setMode(TDatePickerMode::ImageButton); parent::addAttributesToRender($writer); $writer->removeAttribute('name'); $writer->removeAttribute('type'); @@ -824,4 +830,46 @@ class TDatePickerClientScript extends TClientSideOptions } } -?> + +/** + * TDatePickerInputMode class. + * TDatePickerInputMode defines the enumerable type for the possible datepicker input methods. + * + * The following enumerable values are defined: + * - TextBox: text boxes are used to input date values + * - DropDownList: dropdown lists are used to pick up date values + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TDatePickerInputMode extends TEnumerable +{ + const TextBox='TextBox'; + const DropDownList='DropDownList'; +} + +/** + * TDatePickerMode class. + * TDatePickerMode defines the enumerable type for the possible UI mode + * that a {@link TDatePicker} control can take. + * + * The following enumerable values are defined: + * - Basic: Only shows a text input, focusing on the input shows the date picker + * - Button: Shows a button next to the text input, clicking on the button shows the date, button text can be by the + * - ImageButton: Shows an image next to the text input, clicking on the image shows the date picker, + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TDatePickerMode extends TEnumerable +{ + const Basic='Basic'; + const Button='Button'; + const ImageButton='ImageButton'; +} + +?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TEditCommandColumn.php b/framework/Web/UI/WebControls/TEditCommandColumn.php index c742ef11..327e03a2 100644 --- a/framework/Web/UI/WebControls/TEditCommandColumn.php +++ b/framework/Web/UI/WebControls/TEditCommandColumn.php @@ -25,7 +25,7 @@ Prado::using('System.Web.UI.WebControls.TDataGridColumn'); * The button captions are specified using {@link setEditText EditText}, * {@link setUpdateText UpdateText}, and {@link setCancelText CancelText}. * - * The buttons in the column can be set to display as hyperlinks or push buttons + * The buttons in the column can be set to display as hyperlinks, push or image buttons * by setting the {@link setButtonType ButtonType} property. * * When an edit button is clicked, the datagrid will generate an @@ -54,19 +54,19 @@ Prado::using('System.Web.UI.WebControls.TDataGridColumn'); class TEditCommandColumn extends TDataGridColumn { /** - * @return string the type of command button. Defaults to LinkButton. + * @return TButtonColumnType the type of command button. Defaults to TButtonColumnType::LinkButton. */ public function getButtonType() { - return $this->getViewState('ButtonType','LinkButton'); + return $this->getViewState('ButtonType',TButtonColumnType::LinkButton); } /** - * @param string the type of command button, LinkButton or PushButton + * @param TButtonColumnType the type of command button. */ public function setButtonType($value) { - $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'LinkButton','PushButton'),'LinkButton'); + $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'TButtonColumnType'),TButtonColumnType::LinkButton); } /** @@ -85,6 +85,22 @@ class TEditCommandColumn extends TDataGridColumn $this->setViewState('EditText',$value,'Edit'); } + /** + * @return string the URL of the image file for edit image buttons + */ + public function getEditImageUrl() + { + return $this->getViewState('EditImageUrl',''); + } + + /** + * @param string the URL of the image file for edit image buttons + */ + public function setEditImageUrl($value) + { + $this->setViewState('EditImageUrl',$value,''); + } + /** * @return string the caption of the update button. Defaults to 'Update'. */ @@ -101,6 +117,22 @@ class TEditCommandColumn extends TDataGridColumn $this->setViewState('UpdateText',$value,'Update'); } + /** + * @return string the URL of the image file for update image buttons + */ + public function getUpdateImageUrl() + { + return $this->getViewState('UpdateImageUrl',''); + } + + /** + * @param string the URL of the image file for update image buttons + */ + public function setUpdateImageUrl($value) + { + $this->setViewState('UpdateImageUrl',$value,''); + } + /** * @return string the caption of the cancel button. Defaults to 'Cancel'. */ @@ -117,6 +149,22 @@ class TEditCommandColumn extends TDataGridColumn $this->setViewState('CancelText',$value,'Cancel'); } + /** + * @return string the URL of the image file for cancel image buttons + */ + public function getCancelImageUrl() + { + return $this->getViewState('CancelImageUrl',''); + } + + /** + * @param string the URL of the image file for cancel image buttons + */ + public function setCancelImageUrl($value) + { + $this->setViewState('CancelImageUrl',$value,''); + } + /** * @return boolean whether postback event trigger by edit or update button will cause input validation, default is true */ @@ -191,10 +239,21 @@ class TEditCommandColumn extends TDataGridColumn */ protected function createButton($commandName,$text,$causesValidation,$validationGroup) { - if($this->getButtonType()==='LinkButton') + if($this->getButtonType()===TButtonColumnType::LinkButton) $button=Prado::createComponent('System.Web.UI.WebControls.TLinkButton'); - else + else if($this->getButtonType()===TButtonColumnType::PushButton) $button=Prado::createComponent('System.Web.UI.WebControls.TButton'); + else // image buttons + { + $button=Prado::createComponent('System.Web.UI.WebControls.TImageButton'); + if(strcasecmp($commandName,'Update')===0) + $url=$this->getUpdateImageUrl(); + else if(strcasecmp($commandName,'Cancel')===0) + $url=$this->getCancelImageUrl(); + else + $url=$this->getEditImageUrl(); + $button->setImageUrl($url); + } $button->setText($text); $button->setCommandName($commandName); $button->setCausesValidation($causesValidation); diff --git a/framework/Web/UI/WebControls/TImageMap.php b/framework/Web/UI/WebControls/TImageMap.php index 78216a35..b765ec8c 100644 --- a/framework/Web/UI/WebControls/TImageMap.php +++ b/framework/Web/UI/WebControls/TImageMap.php @@ -88,8 +88,8 @@ class TImageMap extends TImage implements IPostBackEventHandler $writer->addAttribute('name',self::MAP_NAME_PREFIX.$clientID); $writer->renderBeginTag('map'); $writer->writeLine(); - if(($mode=$this->getHotSpotMode())==='NotSet') - $mode='Navigate'; + if(($mode=$this->getHotSpotMode())===THotSpotMode::NotSet) + $mode=THotSpotMode::Navigate; $target=$this->getTarget(); $i=0; $options['EventTarget'] = $this->getUniqueID(); @@ -97,11 +97,11 @@ class TImageMap extends TImage implements IPostBackEventHandler $cs=$this->getPage()->getClientScript(); foreach($hotspots as $hotspot) { - if($hotspot->getHotSpotMode()==='NotSet') + if($hotspot->getHotSpotMode()===THotSpotMode::NotSet) $hotspot->setHotSpotMode($mode); if($target!=='' && $hotspot->getTarget()==='') $hotspot->setTarget($target); - if($hotspot->getHotSpotMode()==='PostBack') + if($hotspot->getHotSpotMode()===THotSpotMode::PostBack) { $id=$clientID.'_'.$i; $writer->addAttribute('id',$id); @@ -146,9 +146,9 @@ class TImageMap extends TImage implements IPostBackEventHandler if($index>=0 && $index<$hotspots->getCount()) { $hotspot=$hotspots->itemAt($index); - if(($mode=$hotspot->getHotSpotMode())==='NotSet') + if(($mode=$hotspot->getHotSpotMode())===THotSpotMode::NotSet) $mode=$this->getHotSpotMode(); - if($mode==='PostBack') + if($mode===THotSpotMode::PostBack) { $postBackValue=$hotspot->getPostBackValue(); if($hotspot->getCausesValidation()) @@ -161,23 +161,22 @@ class TImageMap extends TImage implements IPostBackEventHandler } /** - * @return string the behavior of hotspot regions in this imagemap when they are clicked. Defaults to 'NotSet'. + * @return THotSpotMode the behavior of hotspot regions in this imagemap when they are clicked. Defaults to THotSpotMode::NotSet. */ public function getHotSpotMode() { - return $this->getViewState('HotSpotMode','NotSet'); + return $this->getViewState('HotSpotMode',THotSpotMode::NotSet); } /** * Sets the behavior of hotspot regions in this imagemap when they are clicked. * If an individual hotspot has a mode other than 'NotSet', the mode set in this * imagemap will be ignored. By default, 'NotSet' is equivalent to 'Navigate'. - * @param string the behavior of hotspot regions in this imagemap when they are clicked. - * Valid values include 'NotSet','Navigate','PostBack','Inactive'. + * @param THotSpotMode the behavior of hotspot regions in this imagemap when they are clicked. */ public function setHotSpotMode($value) { - $this->setViewState('HotSpotMode',TPropertyValue::ensureEnum($value,'NotSet','Navigate','PostBack','Inactive'),'NotSet'); + $this->setViewState('HotSpotMode',TPropertyValue::ensureEnum($value,'THotSpotMode'),THotSpotMode::NotSet); } /** @@ -376,20 +375,19 @@ abstract class THotSpot extends TComponent } /** - * @return string the behavior of a HotSpot object when it is clicked. Defaults to 'NotSet'. + * @return THotSpotMode the behavior of a HotSpot object when it is clicked. Defaults to THotSpotMode::NotSet. */ public function getHotSpotMode() { - return $this->getViewState('HotSpotMode','NotSet'); + return $this->getViewState('HotSpotMode',THotSpotMode::NotSet); } /** - * @param string the behavior of a HotSpot object when it is clicked. - * Valid values include 'NotSet','Navigate','PostBack','Inactive'. + * @param THotSpotMode the behavior of a HotSpot object when it is clicked. */ public function setHotSpotMode($value) { - $this->setViewState('HotSpotMode',TPropertyValue::ensureEnum($value,'NotSet','Navigate','PostBack','Inactive'),'NotSet'); + $this->setViewState('HotSpotMode',TPropertyValue::ensureEnum($value,'THotSpotMode'),THotSpotMode::NotSet); } /** @@ -498,15 +496,15 @@ abstract class THotSpot extends TComponent { $writer->addAttribute('shape',$this->getShape()); $writer->addAttribute('coords',$this->getCoordinates()); - if(($mode=$this->getHotSpotMode())==='NotSet') - $mode='Navigate'; - if($mode==='Navigate') + if(($mode=$this->getHotSpotMode())===THotSpotMode::NotSet) + $mode=THotSpotMode::Navigate; + if($mode===THotSpotMode::Navigate) { $writer->addAttribute('href',$this->getNavigateUrl()); if(($target=$this->getTarget())!=='') $writer->addAttribute('target',$target); } - else if($mode==='Inactive') + else if($mode===THotSpotMode::Inactive) $writer->addAttribute('nohref','true'); $text=$this->getAlternateText(); $writer->addAttribute('title',$text); @@ -734,4 +732,28 @@ class TPolygonHotSpot extends THotSpot } } + +/** + * THotSpotMode class. + * THotSpotMode defines the enumerable type for the possible hot spot modes. + * + * The following enumerable values are defined: + * - NotSet: the mode is not specified + * - Navigate: clicking on the hotspot will redirect the browser to a different page + * - PostBack: clicking on the hotspot will cause a postback + * - Inactive: the hotspot is inactive (not clickable) + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class THotSpotMode extends TEnumerable +{ + const NotSet='NotSet'; + const Navigate='Navigate'; + const PostBack='PostBack'; + const Inactive='Inactive'; +} + ?> diff --git a/framework/Web/UI/WebControls/TInlineFrame.php b/framework/Web/UI/WebControls/TInlineFrame.php index 5b0be90c..f0ecf3f5 100644 --- a/framework/Web/UI/WebControls/TInlineFrame.php +++ b/framework/Web/UI/WebControls/TInlineFrame.php @@ -42,20 +42,19 @@ class TInlineFrame extends TWebControl } /** - * @return string alignment of the iframe. Defaults to 'NotSet'. + * @return TInlineFrameAlign alignment of the iframe. Defaults to TInlineFrameAlign::NotSet. */ public function getAlign() { - return $this->getViewState('Align','NotSet'); + return $this->getViewState('Align',TInlineFrameAlign::NotSet); } /** - * @param string alignment of the iframe. Valid values include - * 'NotSet', 'Left', 'Right', 'Top', 'Middle', 'Bottom'. + * @param TInlineFrameAlign alignment of the iframe. */ public function setAlign($value) { - $this->setViewState('Align',TPropertyValue::ensureEnum($value,'NotSet','Left','Right','Top','Middle','Bottom'),'NotSet'); + $this->setViewState('Align',TPropertyValue::ensureEnum($value,'TInlineFrameAlign'),TInlineFrameAlign::NotSet); } /** @@ -107,20 +106,19 @@ class TInlineFrame extends TWebControl } /** - * @return string the visibility and position of scroll bars in an iframe. Defaults to 'Auto'. + * @return TInlineFrameScrollBars the visibility and position of scroll bars in an iframe. Defaults to TInlineFrameScrollBars::Auto. */ public function getScrollBars() { - return $this->getViewState('ScrollBars','Auto'); + return $this->getViewState('ScrollBars',TInlineFrameScrollBars::Auto); } /** - * @param string the visibility and position of scroll bars in an iframe. - * Valid values include None, Auto, Both. + * @param TInlineFrameScrollBars the visibility and position of scroll bars in an iframe. */ public function setScrollBars($value) { - $this->setViewState('ScrollBars',TPropertyValue::ensureEnum($value,array('None','Auto','Both')),'Auto'); + $this->setViewState('ScrollBars',TPropertyValue::ensureEnum($value,'TInlineFrameScrollBars'),TInlineFrameScrollBars::Auto); } /** @@ -180,9 +178,9 @@ class TInlineFrame extends TWebControl $writer->addAttribute('align',$align); $scrollBars=$this->getScrollBars(); - if($scrollBars==='None') + if($scrollBars===TInlineFrameScrollBars::None) $writer->addAttribute('scrolling','no'); - else if($scrollBars==='Both') + else if($scrollBars===TInlineFrameScrollBars::Both) $writer->addAttribute('scrolling','yes'); if (!$this->getShowBorder()) @@ -200,4 +198,54 @@ class TInlineFrame extends TWebControl parent::addAttributesToRender($writer); } } + +/** + * TInlineFrameAlign class. + * TInlineFrameAlign defines the enumerable type for the possible alignments + * that the content in a {@link TInlineFrame} could be. + * + * The following enumerable values are defined: + * - NotSet: the alignment is not specified. + * - Left: left aligned + * - Right: right aligned + * - Top: top aligned + * - Middle: middle aligned + * - Bottom: bottom aligned + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TInlineFrameAlign extends TEnumerable +{ + const NotSet='NotSet'; + const Left='Left'; + const Right='Right'; + const Top='Top'; + const Middle='Middle'; + const Bottom='Bottom'; +} + +/** + * TInlineFrameScrollBars class. + * TInlineFrameScrollBars defines the enumerable type for the possible scroll bar mode + * that a {@link TInlineFrame} control could use. + * + * The following enumerable values are defined: + * - None: no scroll bars. + * - Auto: scroll bars automatically appeared when needed. + * - Both: show both horizontal and vertical scroll bars all the time. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TInlineFrameScrollBars extends TEnumerable +{ + const None='None'; + const Auto='Auto'; + const Both='Both'; +} ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TLabel.php b/framework/Web/UI/WebControls/TLabel.php index a7a25eef..65517fc9 100644 --- a/framework/Web/UI/WebControls/TLabel.php +++ b/framework/Web/UI/WebControls/TLabel.php @@ -20,6 +20,7 @@ * To use TLabel as a form label, associate it with a control by setting the * {@link setForControl ForControl} property. * The associated control must be locatable within the label's naming container. + * If the associated control is not visible, the label will not be rendered, either. * * Note, {@link setText Text} will NOT be encoded for rendering. * Make sure it does not contain dangerous characters that you want to avoid. @@ -31,6 +32,8 @@ */ class TLabel extends TWebControl { + private $_forControl=''; + /** * @return string tag name of the label, returns 'label' if there is an associated control, 'span' otherwise. */ @@ -45,15 +48,35 @@ class TLabel extends TWebControl * @throws TInvalidDataValueException if associated control cannot be found using the ID */ protected function addAttributesToRender($writer) + { + if($this->_forControl!=='') + $writer->addAttribute('for',$this->_forControl); + parent::addAttributesToRender($writer); + } + + /** + * Renders the label. + * It overrides the parent implementation by checking if an associated + * control is visible or not. If not, the label will not be rendered. + * @param THtmlWriter writer + */ + public function render($writer) { if(($aid=$this->getForControl())!=='') { if($control=$this->findControl($aid)) - $writer->addAttribute('for',$control->getClientID()); + { + if($control->getVisible(true)) + { + $this->_forControl=$control->getClientID(); + parent::render($writer); + } + } else throw new TInvalidDataValueException('label_associatedcontrol_invalid',$aid); } - parent::addAttributesToRender($writer); + else + parent::render($writer); } /** diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php index 79b73fb6..0191c168 100644 --- a/framework/Web/UI/WebControls/TListBox.php +++ b/framework/Web/UI/WebControls/TListBox.php @@ -20,7 +20,7 @@ Prado::using('System.Web.UI.WebControls.TListControl'); * * TListBox displays a list box on a Web page that allows single or multiple selection. * The list box allows multiple selections if {@link setSelectionMode SelectionMode} - * is 'Multiple'. It takes single selection only if 'Single'. + * is TListSelectionMode::Multiple. It takes single selection only if Single. * The property {@link setRows Rows} specifies how many rows of options are visible * at a time. See {@link TListControl} for inherited properties. * @@ -47,7 +47,7 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl { $rows=$this->getRows(); $writer->addAttribute('size',"$rows"); - if($this->getSelectionMode()==='Multiple') + if($this->getSelectionMode()===TListSelectionMode::Multiple) $writer->addAttribute('name',$this->getUniqueID().'[]'); else $writer->addAttribute('name',$this->getUniqueID()); @@ -92,7 +92,7 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl if($selections!==null) { $items=$this->getItems(); - if($this->getSelectionMode()==='Single') + if($this->getSelectionMode()===TListSelectionMode::Single) { $selection=is_array($selections)?$selections[0]:$selections; $index=$items->findIndexByValue($selection,false); @@ -158,7 +158,7 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl */ protected function getIsMultiSelect() { - return $this->getSelectionMode()==='Multiple'; + return $this->getSelectionMode()===TListSelectionMode::Multiple; } /** @@ -181,20 +181,19 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl } /** - * @return string the selection mode (Single, Multiple). Defaults to 'Single'. + * @return TListSelectionMode the selection mode (Single, Multiple). Defaults to TListSelectionMode::Single. */ public function getSelectionMode() { - return $this->getViewState('SelectionMode', 'Single'); + return $this->getViewState('SelectionMode', TListSelectionMode::Single); } /** - * Sets the selection mode of the list control (Single, Multiple) - * @param string the selection mode + * @param TListSelectionMode the selection mode */ public function setSelectionMode($value) { - $this->setViewState('SelectionMode',TPropertyValue::ensureEnum($value,array('Single','Multiple')),'Single'); + $this->setViewState('SelectionMode',TPropertyValue::ensureEnum($value,'TListSelectionMode'),TListSelectionMode::Single); } /** @@ -207,4 +206,25 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl return $this->getSelectedValue(); } } + + +/** + * TListSelectionMode class. + * TListSelectionMode defines the enumerable type for the possible selection modes of a {@link TListBox}. + * + * The following enumerable values are defined: + * - Single: single selection + * - Multiple: allow multiple selection + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TListSelectionMode extends TEnumerable +{ + const Single='Single'; + const Multiple='Multiple'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index 76c59903..3a0a4f76 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -195,6 +195,7 @@ abstract class TListControl extends TDataBoundControl if($valueField==='') $valueField=1; $textFormat=$this->getDataTextFormatString(); + $groupField=$this->getDataGroupField(); foreach($data as $key=>$object) { $item=$items->createListItem(); @@ -203,6 +204,8 @@ abstract class TListControl extends TDataBoundControl $text=TDataFieldAccessor::getDataFieldValue($object,$textField); $value=TDataFieldAccessor::getDataFieldValue($object,$valueField); $item->setValue($value); + if($groupField!=='') + $item->setAttribute('Group',TDataFieldAccessor::getDataFieldValue($object,$groupField)); } else { @@ -395,6 +398,22 @@ abstract class TListControl extends TDataBoundControl $this->setViewState('DataValueField',$value,''); } + /** + * @return string the field of the data source that provides the label of the list item groups + */ + public function getDataGroupField() + { + return $this->getViewState('DataGroupField',''); + } + + /** + * @param string the field of the data source that provides the label of the list item groups + */ + public function setDataGroupField($value) + { + $this->setViewState('DataGroupField',$value,''); + } + /** * @return integer the number of items in the list control */ diff --git a/framework/Web/UI/WebControls/TPager.php b/framework/Web/UI/WebControls/TPager.php index 0401c4f2..a6bf75e7 100644 --- a/framework/Web/UI/WebControls/TPager.php +++ b/framework/Web/UI/WebControls/TPager.php @@ -86,35 +86,35 @@ class TPager extends TWebControl implements INamingContainer } /** - * @return string pager mode. Defaults to 'NextPrev'. + * @return TPagerMode pager mode. Defaults to TPagerMode::NextPrev. */ public function getMode() { - return $this->getViewState('Mode','NextPrev'); + return $this->getViewState('Mode',TPagerMode::NextPrev); } /** - * @param string pager mode. Valid values include 'NextPrev', 'Numeric' and 'List'. + * @param TPagerMode pager mode. */ public function setMode($value) { - $this->setViewState('Mode',TPropertyValue::ensureEnum($value,'NextPrev','Numeric','List'),'NextPrev'); + $this->setViewState('Mode',TPropertyValue::ensureEnum($value,'TPagerMode'),TPagerMode::NextPrev); } /** - * @return string the type of command button for paging. Defaults to 'LinkButton'. + * @return TPagerButtonType the type of command button for paging. Defaults to TPagerButtonType::LinkButton. */ public function getButtonType() { - return $this->getViewState('ButtonType','LinkButton'); + return $this->getViewState('ButtonType',TPagerButtonType::LinkButton); } /** - * @param string the type of command button for paging. Valid values include 'LinkButton' and 'PushButton'. + * @param TPagerButtonType the type of command button for paging. */ public function setButtonType($value) { - $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'LinkButton','PushButton')); + $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'TPagerButtonType'),TPagerButtonType::LinkButton); } /** @@ -282,20 +282,20 @@ class TPager extends TWebControl implements INamingContainer /** * Builds the pager content based on the pager mode. - * Current implementation includes building 'NextPrev', 'Numeric' and 'List' pagers. + * Current implementation includes building 'NextPrev', 'Numeric' and 'DropDownList' pagers. * Derived classes may override this method to provide additional pagers. */ protected function buildPager() { switch($this->getMode()) { - case 'NextPrev': + case TPagerMode::NextPrev: $this->buildNextPrevPager(); break; - case 'Numeric': + case TPagerMode::Numeric: $this->buildNumericPager(); break; - case 'List': + case TPagerMode::DropDownList: $this->buildListPager(); break; } @@ -315,7 +315,7 @@ class TPager extends TWebControl implements INamingContainer */ protected function createPagerButton($buttonType,$enabled,$text,$commandName,$commandParameter) { - if($buttonType==='LinkButton') + if($buttonType===TPagerButtonType::LinkButton) { if($enabled) $button=new TLinkButton; @@ -600,4 +600,46 @@ class TPagerPageChangedEventParameter extends TEventParameter } } + +/** + * TPagerMode class. + * TPagerMode defines the enumerable type for the possible modes that a {@link TPager} control can take. + * + * The following enumerable values are defined: + * - NextPrev: pager buttons are displayed as next and previous pages + * - Numeric: pager buttons are displayed as numeric page numbers + * - DropDownList: a dropdown list is used to select pages + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TPagerMode extends TEnumerable +{ + const NextPrev='NextPrev'; + const Numeric='Numeric'; + const DropDownList='DropDownList'; +} + + +/** + * TPagerButtonType class. + * TPagerButtonType defines the enumerable type for the possible types of pager buttons. + * + * The following enumerable values are defined: + * - LinkButton: link buttons + * - PushButton: form submit buttons + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TPagerButtonType extends TEnumerable +{ + const LinkButton='LinkButton'; + const PushButton='PushButton'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TPanel.php b/framework/Web/UI/WebControls/TPanel.php index 27006b94..a9ce260c 100644 --- a/framework/Web/UI/WebControls/TPanel.php +++ b/framework/Web/UI/WebControls/TPanel.php @@ -79,7 +79,7 @@ class TPanel extends TWebControl else { $writer->addAttribute('id',$this->getClientID()); - $this->getPage()->getClientScript()->registerDefaultButton($this->getClientID(), $button->getClientID()); + $this->getPage()->getClientScript()->registerDefaultButton($this, $button); } } } diff --git a/framework/Web/UI/WebControls/TPanelStyle.php b/framework/Web/UI/WebControls/TPanelStyle.php index dc20806e..d3f8cee8 100644 --- a/framework/Web/UI/WebControls/TPanelStyle.php +++ b/framework/Web/UI/WebControls/TPanelStyle.php @@ -59,21 +59,21 @@ class TPanelStyle extends TStyle switch($this->getScrollBars()) { - case 'Horizontal': $this->setStyleField('overflow-x','scroll'); break; - case 'Vertical': $this->setStyleField('overflow-y','scroll'); break; - case 'Both': $this->setStyleField('overflow','scroll'); break; - case 'Auto': $this->setStyleField('overflow','auto'); break; + case TScrollBars::Horizontal: $this->setStyleField('overflow-x','scroll'); break; + case TScrollBars::Vertical: $this->setStyleField('overflow-y','scroll'); break; + case TScrollBars::Both: $this->setStyleField('overflow','scroll'); break; + case TScrollBars::Auto: $this->setStyleField('overflow','auto'); break; } - if(($align=$this->getHorizontalAlign())!=='NotSet') + if(($align=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) $this->setStyleField('text-align',strtolower($align)); if(!$this->getWrap()) $this->setStyleField('white-space','nowrap'); - if(($direction=$this->getDirection())!=='NotSet') + if(($direction=$this->getDirection())!==TContentDirection::NotSet) { - if($direction==='LeftToRight') + if($direction===TContentDirection::LeftToRight) $this->setStyleField('direction','ltr'); else $this->setStyleField('direction','rtl'); @@ -100,20 +100,19 @@ class TPanelStyle extends TStyle } /** - * @return string alignment of the content in the panel. Defaults to 'NotSet'. + * @return TContentDirection alignment of the content in the panel. Defaults to TContentDirection::NotSet. */ public function getDirection() { - return $this->_direction===null?'NotSet':$this->_direction; + return $this->_direction===null?TContentDirection::NotSet:$this->_direction; } /** - * @param string alignment of the content in the panel. - * Valid values include 'NotSet', 'LeftToRight', 'RightToLeft'. + * @param TContentDirection alignment of the content in the panel. */ public function setDirection($value) { - $this->_direction=TPropertyValue::ensureEnum($value,array('NotSet','LeftToRight','RightToLeft')); + $this->_direction=TPropertyValue::ensureEnum($value,'TContentDirection'); } /** @@ -134,38 +133,36 @@ class TPanelStyle extends TStyle } /** - * @return string the horizontal alignment of the contents within the panel, defaults to 'NotSet'. + * @return THorizontalAlign the horizontal alignment of the contents within the panel, defaults to THorizontalAlign::NotSet. */ public function getHorizontalAlign() { - return $this->_horizontalAlign===null?'NotSet':$this->_horizontalAlign; + return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; } /** * Sets the horizontal alignment of the contents within the panel. - * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' - * @param string the horizontal alignment + * @param THorizontalAlign the horizontal alignment */ public function setHorizontalAlign($value) { - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,array('NotSet','Left','Right','Center','Justify')); + $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign'); } /** - * @return string the visibility and position of scroll bars in a panel control, defaults to None. + * @return TScrollBars the visibility and position of scroll bars in a panel control, defaults to TScrollBars::None. */ public function getScrollBars() { - return $this->_scrollBars===null?'None':$this->_scrollBars; + return $this->_scrollBars===null?TScrollBars::None:$this->_scrollBars; } /** - * @param string the visibility and position of scroll bars in a panel control. - * Valid values include None, Auto, Both, Horizontal and Vertical. + * @param TScrollBars the visibility and position of scroll bars in a panel control. */ public function setScrollBars($value) { - $this->_scrollBars=TPropertyValue::ensureEnum($value,array('None','Auto','Both','Horizontal','Vertical')); + $this->_scrollBars=TPropertyValue::ensureEnum($value,'TScrollBars'); } /** @@ -232,4 +229,51 @@ class TPanelStyle extends TStyle } } +/** + * TContentDirection class. + * TContentDirection defines the enumerable type for the possible directions that a panel can be at. + * + * The following enumerable values are defined: + * - NotSet: the direction is not specified + * - LeftToRight: content in a panel is left to right + * - RightToLeft: content in a panel is right to left + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TContentDirection extends TEnumerable +{ + const NotSet='NotSet'; + const LeftToRight='LeftToRight'; + const RightToLeft='RightToLeft'; +} + +/** + * TScrollBars class. + * TScrollBars defines the enumerable type for the possible scroll bar mode + * that a {@link TPanel} control could use. + * + * The following enumerable values are defined: + * - None: no scroll bars. + * - Auto: scroll bars automatically appeared when needed. + * - Both: show both horizontal and vertical scroll bars all the time. + * - Horizontal: horizontal scroll bar only + * - Vertical: vertical scroll bar only + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TScrollBars extends TEnumerable +{ + const None='None'; + const Auto='Auto'; + const Both='Both'; + const Horizontal='Horizontal'; + const Vertical='Vertical'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TRangeValidator.php b/framework/Web/UI/WebControls/TRangeValidator.php index b54a1684..a868dd67 100644 --- a/framework/Web/UI/WebControls/TRangeValidator.php +++ b/framework/Web/UI/WebControls/TRangeValidator.php @@ -35,10 +35,10 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); * the GNU date syntax is assumed. * - String A string data type. * - StringLength check for string length. - * + * * The TRangeValidator allows a special DataType "StringLength" that - * can be used to verify minimum and maximum string length. The - * {@link setCharset Charset} property can be used to force a particular + * can be used to verify minimum and maximum string length. The + * {@link setCharset Charset} property can be used to force a particular * charset for comparison. Otherwise, the application charset is used and is * defaulted as UTF-8. * @@ -94,23 +94,21 @@ class TRangeValidator extends TBaseValidator } /** - * @return string the data type that the values being compared are - * converted to before the comparison is made. Defaults to String. + * @return TRangeValidationDataType the data type that the values being compared are + * converted to before the comparison is made. Defaults to TRangeValidationDataType::String. */ public function getDataType() { - return $this->getViewState('DataType','String'); + return $this->getViewState('DataType',TRangeValidationDataType::String); } /** - * Sets the data type (Integer, Float, Date, String, StringLength) that the - * values being compared are converted to before the comparison is made. - * @param string the data type + * Sets the data type that the values being compared are converted to before the comparison is made. + * @param TRangeValidationDataType the data type */ public function setDataType($value) { - $this->setViewState('DataType',TPropertyValue::ensureEnum( - $value,'Integer','Float','Date','String', 'StringLength'),'String'); + $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'TRangeValidationDataType'),TRangeValidationDataType::String); } /** @@ -137,7 +135,7 @@ class TRangeValidator extends TBaseValidator { $this->setViewState('Charset', $value, ''); } - + /** * @return string charset for string length comparison. */ @@ -160,13 +158,13 @@ class TRangeValidator extends TBaseValidator switch($this->getDataType()) { - case 'Integer': + case TRangeValidationDataType::Integer: return $this->isValidInteger($value); - case 'Float': + case TRangeValidationDataType::Float: return $this->isValidFloat($value); - case 'Date': + case TRangeValidationDataType::Date: return $this->isValidDate($value); - case 'StringLength': + case TRangeValidationDataType::StringLength: return $this->isValidStringLength($value); default: return $this->isValidString($value); @@ -264,10 +262,10 @@ class TRangeValidator extends TBaseValidator $valid=$valid && (strcmp($value,$maxValue)<=0); return $valid; } - + /** * @param string string for comparision - * @return boolean true if min and max string length are satisfied. + * @return boolean true if min and max string length are satisfied. */ protected function isValidStringLength($value) { @@ -283,7 +281,7 @@ class TRangeValidator extends TBaseValidator if(!$charset) $charset = 'UTF-8'; } - + $length = iconv_strlen($value, $charset); if($minValue!=='') $valid = $valid && $length >= intval($minValue); @@ -308,4 +306,26 @@ class TRangeValidator extends TBaseValidator } } + +/** + * TRangeValidationDataType class. + * TRangeValidationDataType defines the enumerable type for the possible data types that + * a range validator can validate upon. + * + * The following enumerable values are defined: + * - Integer + * - Float + * - Date + * - String + * - StringLength + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TRangeValidationDataType extends TValidationDataType +{ + const StringLength='StringLength'; +} ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TRepeatInfo.php b/framework/Web/UI/WebControls/TRepeatInfo.php index 81b82c33..f5a827aa 100644 --- a/framework/Web/UI/WebControls/TRepeatInfo.php +++ b/framework/Web/UI/WebControls/TRepeatInfo.php @@ -10,6 +10,8 @@ * @package System.Web.UI.WebControls */ +Prado::using('System.Web.UI.WebControls.TTable'); + /** * IRepeatInfoUser interface. * This interface must be implemented by classes who want to use {@link TRepeatInfo}. @@ -57,7 +59,7 @@ interface IRepeatInfoUser * TRepeatInfo class. * TRepeatInfo represents repeat information for controls like {@link TCheckBoxList}. * The layout of the repeated items is specified via {@link setRepeatLayout RepeatLayout}, - * which can be either 'Table' (default), 'Flow' or 'Raw'. + * which can be either Table (default), Flow or Raw. * A table layout uses HTML table cells to organize the items while * a flow layout uses line breaks to organize the items. * The number of columns used to display the items is specified via @@ -79,21 +81,21 @@ class TRepeatInfo extends TComponent */ private $_caption=''; /** - * @var string alignment of the caption of the table used to organize the repeated items + * @var TTableCaptionAlign alignment of the caption of the table used to organize the repeated items */ - private $_captionAlign='NotSet'; + private $_captionAlign=TTableCaptionAlign::NotSet; /** * @var integer number of columns that the items should be arranged in */ private $_repeatColumns=0; /** - * @var string direction of the repetition + * @var TRepeatDirection direction of the repetition */ - private $_repeatDirection='Vertical'; + private $_repeatDirection=TRepeatDirection::Vertical; /** - * @var string layout of the repeated items + * @var TRepeatLayout layout of the repeated items */ - private $_repeatLayout='Table'; + private $_repeatLayout=TRepeatLayout::Table; /** * @return string caption of the table layout @@ -112,7 +114,7 @@ class TRepeatInfo extends TComponent } /** - * @return string alignment of the caption of the table layout. Defaults to 'NotSet'. + * @return TTableCaptionAlign alignment of the caption of the table layout. Defaults to TTableCaptionAlign::NotSet. */ public function getCaptionAlign() { @@ -120,12 +122,11 @@ class TRepeatInfo extends TComponent } /** - * @return string alignment of the caption of the table layout. - * Valid values include 'NotSet','Top','Bottom','Left','Right'. + * @return TTableCaptionAlign alignment of the caption of the table layout. */ public function setCaptionAlign($value) { - $this->_captionAlign=TPropertyValue::ensureEnum($value,array('NotSet','Top','Bottom','Left','Right')); + $this->_captionAlign=TPropertyValue::ensureEnum($value,'TTableCaptionAlign'); } /** @@ -147,7 +148,7 @@ class TRepeatInfo extends TComponent } /** - * @return string the direction of traversing the repeated items, defaults to 'Vertical' + * @return TRepeatDirection the direction of traversing the repeated items, defaults to TRepeatDirection::Vertical */ public function getRepeatDirection() { @@ -155,16 +156,15 @@ class TRepeatInfo extends TComponent } /** - * Sets the direction of traversing the repeated items (Vertical, Horizontal) - * @param string the direction of traversing the repeated items + * @param TRepeatDirection the direction of traversing the repeated items */ public function setRepeatDirection($value) { - $this->_repeatDirection=TPropertyValue::ensureEnum($value,array('Horizontal','Vertical')); + $this->_repeatDirection=TPropertyValue::ensureEnum($value,'TRepeatDirection'); } /** - * @return string how the repeated items should be displayed, using table or using line breaks. Defaults to 'Table'. + * @return TRepeatLayout how the repeated items should be displayed, using table or using line breaks. Defaults to TRepeatLayout::Table. */ public function getRepeatLayout() { @@ -172,12 +172,11 @@ class TRepeatInfo extends TComponent } /** - * @param string how the repeated items should be displayed, using table or using line breaks. - * Valid values include 'Table', 'Flow' and 'Raw'. + * @param TRepeatLayout how the repeated items should be displayed, using table or using line breaks. */ public function setRepeatLayout($value) { - $this->_repeatLayout=TPropertyValue::ensureEnum($value,array('Table','Flow','Raw')); + $this->_repeatLayout=TPropertyValue::ensureEnum($value,'TRepeatLayout'); } /** @@ -187,7 +186,7 @@ class TRepeatInfo extends TComponent */ public function renderRepeater($writer, IRepeatInfoUser $user) { - if($this->_repeatLayout==='Table') + if($this->_repeatLayout===TRepeatLayout::Table) { $control=new TTable; if($this->_caption!=='') @@ -196,7 +195,7 @@ class TRepeatInfo extends TComponent $control->setCaptionAlign($this->_captionAlign); } } - else if($this->_repeatLayout==='Raw') + else if($this->_repeatLayout===TRepeatLayout::Raw) { $this->renderRawContents($writer,$user); return; @@ -210,7 +209,7 @@ class TRepeatInfo extends TComponent $control->renderBeginTag($writer); $writer->writeLine(); - if($this->_repeatDirection==='Vertical') + if($this->_repeatDirection===TRepeatDirection::Vertical) $this->renderVerticalContents($writer,$user); else $this->renderHorizontalContents($writer,$user); @@ -248,7 +247,7 @@ class TRepeatInfo extends TComponent */ protected function renderHorizontalContents($writer,$user) { - $tableLayout=($this->_repeatLayout==='Table'); + $tableLayout=($this->_repeatLayout===TRepeatLayout::Table); $hasSeparators=$user->getHasSeparators(); $itemCount=$user->getItemCount(); $columns=$this->_repeatColumns===0?$itemCount:$this->_repeatColumns; @@ -330,7 +329,7 @@ class TRepeatInfo extends TComponent */ protected function renderVerticalContents($writer,$user) { - $tableLayout=($this->_repeatLayout==='Table'); + $tableLayout=($this->_repeatLayout===TRepeatLayout::Table); $hasSeparators=$user->getHasSeparators(); $itemCount=$user->getItemCount(); if($this->_repeatColumns<=1) @@ -516,4 +515,47 @@ class TRepeatInfo extends TComponent } } + +/** + * TRepeatDirection class. + * TRepeatDirection defines the enumerable type for the possible directions + * that repeated contents can repeat along + * + * The following enumerable values are defined: + * - Vertical + * - Horizontal + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TRepeatDirection extends TEnumerable +{ + const Vertical='Vertical'; + const Horizontal='Horizontal'; +} + +/** + * TRepeatLayout class. + * TRepeatLayout defines the enumerable type for the possible layouts + * that repeated contents can take. + * + * The following enumerable values are defined: + * - Table: the repeated contents are organized using an HTML table + * - Flow: the repeated contents are organized using HTML spans and breaks + * - Raw: the repeated contents are stacked together without any additional decorations + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TRepeatLayout extends TEnumerable +{ + const Table='Table'; + const Flow='Flow'; + const Raw='Raw'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php index 01c88a30..c5b3e2ef 100644 --- a/framework/Web/UI/WebControls/TRepeater.php +++ b/framework/Web/UI/WebControls/TRepeater.php @@ -38,8 +38,8 @@ Prado::using('System.Util.TDataFieldAccessor'); * * Each repeater item has a {@link TRepeaterItem::getItemType type} * which tells the position of the item in the repeater. An item in the header - * of the repeater is of type TRepeater::IT_HEADER. A body item may be of either - * TRepeater::IT_ITEM or TRepeater::IT_ALTERNATINGITEM, depending whether the item + * of the repeater is of type TListItemType::Header. A body item may be of either + * TListItemType::Item or TListItemType::AlternatingItem, depending whether the item * index is odd or even. * * You can retrive the repeated contents by the {@link getItems Items} property. @@ -73,6 +73,7 @@ class TRepeater extends TDataBoundControl implements INamingContainer { /** * Repeater item types + * @deprecated deprecated since version 3.0.4. Use TListItemType constants instead. */ const IT_HEADER='Header'; const IT_FOOTER='Footer'; @@ -345,11 +346,11 @@ class TRepeater extends TDataBoundControl implements INamingContainer $template=null; switch($item->getItemType()) { - case self::IT_HEADER: $template=$this->_headerTemplate; break; - case self::IT_FOOTER: $template=$this->_footerTemplate; break; - case self::IT_ITEM : $template=$this->_itemTemplate; break; - case self::IT_SEPARATOR : $template=$this->_separatorTemplate; break; - case self::IT_ALTERNATINGITEM : $template=$this->_alternatingItemTemplate===null ? $this->_itemTemplate : $this->_alternatingItemTemplate; break; + case TListItemType::Header: $template=$this->_headerTemplate; break; + case TListItemType::Footer: $template=$this->_footerTemplate; break; + case TListItemType::Item : $template=$this->_itemTemplate; break; + case TListItemType::Separator : $template=$this->_separatorTemplate; break; + case TListItemType::AlternatingItem : $template=$this->_alternatingItemTemplate===null ? $this->_itemTemplate : $this->_alternatingItemTemplate; break; } if($template!==null) $template->instantiateIn($item); @@ -416,16 +417,16 @@ class TRepeater extends TDataBoundControl implements INamingContainer $items=$this->getItems(); $hasSeparator=$this->_separatorTemplate!==null; if($this->_headerTemplate!==null) - $this->_header=$this->createItemInternal(-1,self::IT_HEADER,false,null); + $this->_header=$this->createItemInternal(-1,TListItemType::Header,false,null); for($i=0;$i<$itemCount;++$i) { if($hasSeparator && $i>0) - $this->createItemInternal($i-1,self::IT_SEPARATOR,false,null); - $itemType=$i%2==0?self::IT_ITEM:self::IT_ALTERNATINGITEM; + $this->createItemInternal($i-1,TListItemType::Separator,false,null); + $itemType=$i%2==0?TListItemType::Item : TListItemType::AlternatingItem; $items->add($this->createItemInternal($i,$itemType,false,null)); } if($this->_footerTemplate!==null) - $this->_footer=$this->createItemInternal(-1,self::IT_FOOTER,false,null); + $this->_footer=$this->createItemInternal(-1,TListItemType::Footer,false,null); } else if($this->_emptyTemplate!==null) $this->_emptyTemplate->instantiateIn($this); @@ -456,15 +457,15 @@ class TRepeater extends TDataBoundControl implements INamingContainer else $keys->add($key); if($itemIndex===0 && $this->_headerTemplate!==null) - $this->_header=$this->createItemInternal(-1,self::IT_HEADER,true,null); + $this->_header=$this->createItemInternal(-1,TListItemType::Header,true,null); if($hasSeparator && $itemIndex>0) - $this->createItemInternal($itemIndex-1,self::IT_SEPARATOR,true,null); - $itemType=$itemIndex%2==0?self::IT_ITEM:self::IT_ALTERNATINGITEM; + $this->createItemInternal($itemIndex-1,TListItemType::Separator,true,null); + $itemType=$itemIndex%2==0?TListItemType::Item : TListItemType::AlternatingItem; $items->add($this->createItemInternal($itemIndex,$itemType,true,$dataItem)); $itemIndex++; } if($itemIndex>0 && $this->_footerTemplate!==null) - $this->_footer=$this->createItemInternal(-1,self::IT_FOOTER,true,null); + $this->_footer=$this->createItemInternal(-1,TListItemType::Footer,true,null); if($itemIndex===0 && $this->_emptyTemplate!==null) { $this->_emptyTemplate->instantiateIn($this); @@ -674,9 +675,9 @@ class TRepeaterItem extends TControl implements INamingContainer private $_itemIndex=''; /** * type of the TRepeaterItem - * @var string + * @var TListItemType */ - private $_itemType=''; + private $_itemType; /** * value of the data item * @var mixed @@ -686,7 +687,7 @@ class TRepeaterItem extends TControl implements INamingContainer /** * Constructor. * @param integer zero-based index of the item in the item collection of repeater - * @param string item type, can be 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'. + * @param TListItemType item type */ public function __construct($itemIndex,$itemType) { @@ -695,7 +696,7 @@ class TRepeaterItem extends TControl implements INamingContainer } /** - * @return string item type + * @return TListItemType item type */ public function getItemType() { @@ -703,11 +704,11 @@ class TRepeaterItem extends TControl implements INamingContainer } /** - * @param string item type. Valid values include 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'. + * @param TListItemType item type. */ public function setItemType($value) { - $this->_itemType=TPropertyValue::ensureEnum($value,'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'); + $this->_itemType=TPropertyValue::ensureEnum($value,'TListItemType'); } /** diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index d4cb6154..2c03f3e7 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -384,11 +384,11 @@ class TStyle extends TComponent class TTableStyle extends TStyle { /** - * @var string the URL of the background image for the table + * @var TVerticalAlign the URL of the background image for the table */ private $_backImageUrl=null; /** - * @var string horizontal alignment of the contents within the table + * @var THorizontalAlign horizontal alignment of the contents within the table */ private $_horizontalAlign=null; /** @@ -400,7 +400,7 @@ class TTableStyle extends TStyle */ private $_cellSpacing=null; /** - * @var string grid line setting of the table + * @var TTableGridLines grid line setting of the table */ private $_gridLines=null; /** @@ -486,7 +486,7 @@ class TTableStyle extends TStyle if(($url=trim($this->getBackImageUrl()))!=='') $writer->addStyleAttribute('background-image','url('.$url.')'); - if(($horizontalAlign=$this->getHorizontalAlign())!=='NotSet') + if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) $writer->addStyleAttribute('text-align',strtolower($horizontalAlign)); if(($cellPadding=$this->getCellPadding())>=0) @@ -500,9 +500,9 @@ class TTableStyle extends TStyle switch($this->getGridLines()) { - case 'Horizontal' : $writer->addAttribute('rules','rows'); break; - case 'Vertical' : $writer->addAttribute('rules','cols'); break; - case 'Both' : $writer->addAttribute('rules','all'); break; + case TTableGridLines::Horizontal : $writer->addAttribute('rules','rows'); break; + case TTableGridLines::Vertical : $writer->addAttribute('rules','cols'); break; + case TTableGridLines::Both : $writer->addAttribute('rules','all'); break; } parent::addAttributesToRender($writer); @@ -526,21 +526,20 @@ class TTableStyle extends TStyle } /** - * @return string the horizontal alignment of the contents within the table, defaults to 'NotSet'. + * @return THorizontalAlign the horizontal alignment of the contents within the table, defaults to THorizontalAlign::NotSet. */ public function getHorizontalAlign() { - return $this->_horizontalAlign===null?'NotSet':$this->_horizontalAlign; + return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; } /** * Sets the horizontal alignment of the contents within the table. - * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' - * @param string the horizontal alignment + * @param THorizontalAlign the horizontal alignment */ public function setHorizontalAlign($value) { - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,array('NotSet','Left','Right','Center','Justify')); + $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign'); } /** @@ -580,21 +579,20 @@ class TTableStyle extends TStyle } /** - * @return string the grid line setting of the table. Defaults to 'None'. + * @return TTableGridLines the grid line setting of the table. Defaults to TTableGridLines::None. */ public function getGridLines() { - return $this->_gridLines===null?'None':$this->_gridLines; + return $this->_gridLines===null?TTableGridLines::None:$this->_gridLines; } /** * Sets the grid line style of the table. - * Valid values include 'None', 'Horizontal', 'Vertical', 'Both'. - * @param string the grid line setting of the table + * @param TTableGridLines the grid line setting of the table */ public function setGridLines($value) { - $this->_gridLines=TPropertyValue::ensureEnum($value,array('None', 'Horizontal', 'Vertical', 'Both')); + $this->_gridLines=TPropertyValue::ensureEnum($value,'TTableGridLines'); } @@ -627,11 +625,11 @@ class TTableStyle extends TStyle class TTableItemStyle extends TStyle { /** - * @var string horizontal alignment of the contents within the table item + * @var THorizontalAlign horizontal alignment of the contents within the table item */ private $_horizontalAlign=null; /** - * @var string vertical alignment of the contents within the table item + * @var TVerticalAlign vertical alignment of the contents within the table item */ private $_verticalAlign=null; /** @@ -702,49 +700,47 @@ class TTableItemStyle extends TStyle if(!$this->getWrap()) $writer->addStyleAttribute('white-space','nowrap'); - if(($horizontalAlign=$this->getHorizontalAlign())!=='NotSet') + if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) $writer->addAttribute('align',strtolower($horizontalAlign)); - if(($verticalAlign=$this->getVerticalAlign())!=='NotSet') + if(($verticalAlign=$this->getVerticalAlign())!==TVerticalAlign::NotSet) $writer->addAttribute('valign',strtolower($verticalAlign)); parent::addAttributesToRender($writer); } /** - * @return string the horizontal alignment of the contents within the table item, defaults to 'NotSet'. + * @return THorizontalAlign the horizontal alignment of the contents within the table item, defaults to THorizontalAlign::NotSet. */ public function getHorizontalAlign() { - return $this->_horizontalAlign===null?'NotSet':$this->_horizontalAlign; + return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; } /** * Sets the horizontal alignment of the contents within the table item. - * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' - * @param string the horizontal alignment + * @param THorizontalAlign the horizontal alignment */ public function setHorizontalAlign($value) { - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,array('NotSet','Left','Right','Center','Justify')); + $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign'); } /** - * @return string the vertical alignment of the contents within the table item, defaults to 'NotSet'. + * @return TVerticalAlign the vertical alignment of the contents within the table item, defaults to TVerticalAlign::NotSet. */ public function getVerticalAlign() { - return $this->_verticalAlign===null?'NotSet':$this->_verticalAlign; + return $this->_verticalAlign===null?TVerticalAlign::NotSet:$this->_verticalAlign; } /** * Sets the vertical alignment of the contents within the table item. - * Valid values include 'NotSet','Top','Bottom','Middle' - * @param string the horizontal alignment + * @param TVerticalAlign the horizontal alignment */ public function setVerticalAlign($value) { - $this->_verticalAlign=TPropertyValue::ensureEnum($value,array('NotSet','Top','Bottom','Middle')); + $this->_verticalAlign=TPropertyValue::ensureEnum($value,'TVerticalAlign'); } /** @@ -765,4 +761,76 @@ class TTableItemStyle extends TStyle } } +/** + * THorizontalAlign class. + * THorizontalAlign defines the enumerable type for the possible horizontal alignments in a CSS style. + * + * The following enumerable values are defined: + * - NotSet: the alignment is not specified. + * - Left: left aligned + * - Right: right aligned + * - Center: center aligned + * - Justify: the begin and end are justified + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class THorizontalAlign extends TEnumerable +{ + const NotSet='NotSet'; + const Left='Left'; + const Right='Right'; + const Center='Center'; + const Justify='Justify'; +} + +/** + * TVerticalAlign class. + * TVerticalAlign defines the enumerable type for the possible vertical alignments in a CSS style. + * + * The following enumerable values are defined: + * - NotSet: the alignment is not specified. + * - Top: top aligned + * - Bottom: bottom aligned + * - Middle: middle aligned + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TVerticalAlign extends TEnumerable +{ + const NotSet='NotSet'; + const Top='Top'; + const Bottom='Bottom'; + const Middle='Middle'; +} + + +/** + * TTableGridLines class. + * TTableGridLines defines the enumerable type for the possible grid line types of an HTML table. + * + * The following enumerable values are defined: + * - None: no grid lines + * - Horizontal: horizontal grid lines only + * - Vertical: vertical grid lines only + * - Both: both horizontal and vertical grid lines are shown + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TTableGridLines extends TEnumerable +{ + const None='None'; + const Horizontal='Horizontal'; + const Vertical='Vertical'; + const Both='Both'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php index ac61eb3f..d3036c9c 100644 --- a/framework/Web/UI/WebControls/TTable.php +++ b/framework/Web/UI/WebControls/TTable.php @@ -107,7 +107,7 @@ class TTable extends TWebControl $border=0; if($this->getHasStyle()) { - if($this->getGridLines()!=='None') + if($this->getGridLines()!==TTableGridLines::None) { if(($border=$this->getBorderWidth())==='') $border=1; @@ -153,20 +153,19 @@ class TTable extends TWebControl } /** - * @return string table caption alignment. Defaults to 'NotSet'. + * @return TTableCaptionAlign table caption alignment. Defaults to TTableCaptionAlign::NotSet. */ public function getCaptionAlign() { - return $this->getViewState('CaptionAlign','NotSet'); + return $this->getViewState('CaptionAlign',TTableCaptionAlign::NotSet); } /** - * @param string table caption alignment. Valid values include - * 'NotSet','Top','Bottom','Left','Right'. + * @param TTableCaptionAlign table caption alignment. */ public function setCaptionAlign($value) { - $this->setViewState('CaptionAlign',TPropertyValue::ensureEnum($value,'NotSet','Top','Bottom','Left','Right'),'NotSet'); + $this->setViewState('CaptionAlign',TPropertyValue::ensureEnum($value,'TTableCaptionAlign'),TTableCaptionAlign::NotSet); } /** @@ -208,19 +207,18 @@ class TTable extends TWebControl } /** - * @return string the horizontal alignment of the table content. Defaults to 'NotSet'. + * @return THorizontalAlign the horizontal alignment of the table content. Defaults to THorizontalAlign::NotSet. */ public function getHorizontalAlign() { if($this->getHasStyle()) return $this->getStyle()->getHorizontalAlign(); else - return 'NotSet'; + return THorizontalAlign::NotSet; } /** - * @param string the horizontal alignment of the table content. - * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center'. + * @param THorizontalAlign the horizontal alignment of the table content. */ public function setHorizontalAlign($value) { @@ -228,20 +226,18 @@ class TTable extends TWebControl } /** - * @return string the grid line setting of the table. Defaults to 'None'. + * @return TTableGridLines the grid line setting of the table. Defaults to TTableGridLines::None. */ public function getGridLines() { if($this->getHasStyle()) return $this->getStyle()->getGridLines(); else - return 'None'; + return TTableGridLines::None; } /** - * Sets the grid line style of the table. - * Valid values include 'None', 'Horizontal', 'Vertical', 'Both'. - * @param string the grid line setting of the table + * @param TTableGridLines the grid line setting of the table */ public function setGridLines($value) { @@ -277,7 +273,7 @@ class TTable extends TWebControl parent::renderBeginTag($writer); if(($caption=$this->getCaption())!=='') { - if(($align=$this->getCaptionAlign())!=='NotSet') + if(($align=$this->getCaptionAlign())!==TTableCaptionAlign::NotSet) $writer->addAttribute('align',strtolower($align)); $writer->renderBeginTag('caption'); $writer->write($caption); @@ -296,7 +292,7 @@ class TTable extends TWebControl $renderTableSection=false; foreach($this->getControls() as $row) { - if($row->getTableSection()!=='Body') + if($row->getTableSection()!==TTableRowSection::Body) { $renderTableSection=true; break; @@ -304,31 +300,31 @@ class TTable extends TWebControl } if($renderTableSection) { - $currentSection='Header'; + $currentSection=TTableRowSection::Header; $writer->writeLine(); foreach($this->getControls() as $index=>$row) { if(($section=$row->getTableSection())===$currentSection) { - if($index===0 && $currentSection==='Header') + if($index===0 && $currentSection===TTableRowSection::Header) $writer->renderBeginTag('thead'); } else { - if($currentSection==='Header') + if($currentSection===TTableRowSection::Header) { if($index>0) $writer->renderEndTag(); - if($section==='Body') + if($section===TTableRowSection::Body) $writer->renderBeginTag('tbody'); else $writer->renderBeginTag('tfoot'); $currentSection=$section; } - else if($currentSection==='Body') + else if($currentSection===TTableRowSection::Body) { $writer->renderEndTag(); - if($section==='Footer') + if($section===TTableRowSection::Footer) $writer->renderBeginTag('tfoot'); else throw new TConfigurationException('table_tablesection_outoforder'); @@ -385,4 +381,31 @@ class TTableRowCollection extends TControlCollection } } + +/** + * TTableCaptionAlign class. + * TTableCaptionAlign defines the enumerable type for the possible alignments + * that a table caption can take. + * + * The following enumerable values are defined: + * - NotSet: alignment not specified + * - Top: top aligned + * - Bottom: bottom aligned + * - Left: left aligned + * - Right: right aligned + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TTableCaptionAlign extends TEnumerable +{ + const NotSet='NotSet'; + const Top='Top'; + const Bottom='Bottom'; + const Left='Left'; + const Right='Right'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTableHeaderCell.php b/framework/Web/UI/WebControls/TTableHeaderCell.php index 12009de6..497b2088 100644 --- a/framework/Web/UI/WebControls/TTableHeaderCell.php +++ b/framework/Web/UI/WebControls/TTableHeaderCell.php @@ -43,8 +43,8 @@ class TTableHeaderCell extends TTableCell protected function addAttributesToRender($writer) { parent::addAttributesToRender($writer); - if(($scope=$this->getScope())!=='NotSet') - $writer->addAttribute('scope',$scope==='Row'?'row':'col'); + if(($scope=$this->getScope())!==TTableHeaderScope::NotSet) + $writer->addAttribute('scope',$scope===TTableHeaderScope::Row?'row':'col'); if(($text=$this->getAbbreviatedText())!=='') $writer->addAttribute('abbr',$text); if(($text=$this->getCategoryText())!=='') @@ -52,20 +52,19 @@ class TTableHeaderCell extends TTableCell } /** - * @return string the scope of the cells that the header cell applies to. Defaults to 'NotSet'. + * @return TTableHeaderScope the scope of the cells that the header cell applies to. Defaults to TTableHeaderScope::NotSet. */ public function getScope() { - return $this->getViewState('Scope','NotSet'); + return $this->getViewState('Scope',TTableHeaderScope::NotSet); } /** - * @param string the scope of the cells that the header cell applies to. - * Valid values include 'NotSet','Row','Column'. + * @param TTableHeaderScope the scope of the cells that the header cell applies to. */ public function setScope($value) { - $this->setViewState('Scope',TPropertyValue::ensureEnum($value,'NotSet','Row','Column'),'NotSet'); + $this->setViewState('Scope',TPropertyValue::ensureEnum($value,'TTableHeaderScope'),TTableHeaderScope::NotSet); } /** @@ -101,4 +100,26 @@ class TTableHeaderCell extends TTableCell } } + +/** + * TTableHeaderScope class. + * TTableHeaderScope defines the enumerable type for the possible table scopes that a table header is associated with. + * + * The following enumerable values are defined: + * - NotSet: the scope is not specified + * - Row: the scope is row-wise + * - Column: the scope is column-wise + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TTableHeaderScope extends TEnumerable +{ + const NotSet='NotSet'; + const Row='Row'; + const Column='Column'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTableRow.php b/framework/Web/UI/WebControls/TTableRow.php index b0e0bfbe..d4bf7984 100644 --- a/framework/Web/UI/WebControls/TTableRow.php +++ b/framework/Web/UI/WebControls/TTableRow.php @@ -121,20 +121,19 @@ class TTableRow extends TWebControl } /** - * @return string location of a row in a table. Defaults to 'Body'. + * @return TTableRowSection location of a row in a table. Defaults to TTableRowSection::Body. */ public function getTableSection() { - return $this->getViewState('TableSection','Body'); + return $this->getViewState('TableSection',TTableRowSection::Body); } /** - * @param string location of a row in a table. Valid values include 'Header', 'Footer' and 'Body'. + * @param TTableRowSection location of a row in a table. */ public function setTableSection($value) { - $value=TPropertyValue::ensureEnum($value,'Header','Body','Footer'); - $this->setViewState('TableSection',$value,'Body'); + $this->setViewState('TableSection',TPropertyValue::ensureEnum($value,'TTableRowSection'),TTableRowSection::Body); } /** @@ -184,4 +183,27 @@ class TTableCellCollection extends TControlCollection } } + +/** + * TTableRowSection class. + * TTableRowSection defines the enumerable type for the possible table sections + * that a {@link TTableRow} can be within. + * + * The following enumerable values are defined: + * - Header: in table header + * - Body: in table body + * - Footer: in table footer + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.4 + */ +class TTableRowSection extends TEnumerable +{ + const Header='Header'; + const Body='Body'; + const Footer='Footer'; +} + ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index c13f20e7..fa190164 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())!=='') @@ -250,27 +246,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::ensureEnum($value,'TTextBoxAutoCompleteType'),TTextBoxAutoCompleteType::None); } /** @@ -433,21 +422,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::ensureEnum($value,'TTextBoxMode'),TTextBoxMode::SingleLine); } /** @@ -484,4 +473,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 796a62f0..e42652ff 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::ensureEnum($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::ensureEnum($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'); @@ -317,13 +315,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; } @@ -460,4 +458,50 @@ class TClientSideValidationSummaryOptions 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'; +} + ?> diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php index 684ef5dc..a4a0e36a 100644 --- a/framework/Web/UI/WebControls/TWizard.php +++ b/framework/Web/UI/WebControls/TWizard.php @@ -84,6 +84,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'; @@ -917,7 +918,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); @@ -1013,24 +1014,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; @@ -1161,7 +1162,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); @@ -1514,19 +1515,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::ensureEnum($value,'TWizardNavigationButtonType'); } /** @@ -1617,22 +1618,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::ensureEnum($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(); } @@ -1643,7 +1644,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: $ @@ -1653,11 +1654,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; } /** @@ -2099,13 +2100,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; @@ -2217,4 +2218,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