summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorxue <>2006-09-03 21:33:04 +0000
committerxue <>2006-09-03 21:33:04 +0000
commita90da4361d02a53204f198f19072e2d420b394f0 (patch)
treeecf9a1990fe1ffb9c9df405123c0e68504ecf8bb /framework/Web
parenta55994488789e9c481aab5e3e49b15bd9718afc1 (diff)
Added TEnumerable and updated places where enumerable type should be used.
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/Javascripts/js/debug/validator.js4
-rw-r--r--framework/Web/Javascripts/prado/validation3.js4
-rw-r--r--framework/Web/Services/TPageService.php2
-rw-r--r--framework/Web/TAssetManager.php8
-rw-r--r--framework/Web/THttpRequest.php40
-rw-r--r--framework/Web/THttpSession.php42
-rw-r--r--framework/Web/UI/TClientScriptManager.php4
-rw-r--r--framework/Web/UI/TThemeManager.php2
-rw-r--r--framework/Web/UI/WebControls/TBaseValidator.php33
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php101
-rw-r--r--framework/Web/UI/WebControls/TValidationSummary.php72
-rw-r--r--framework/Web/UI/WebControls/TWizard.php98
12 files changed, 312 insertions, 98 deletions
diff --git a/framework/Web/Javascripts/js/debug/validator.js b/framework/Web/Javascripts/js/debug/validator.js
index d0293cbd..170d7ff1 100644
--- a/framework/Web/Javascripts/js/debug/validator.js
+++ b/framework/Web/Javascripts/js/debug/validator.js
@@ -348,7 +348,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.
* </code>
*/
@@ -554,7 +554,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/validation3.js b/framework/Web/Javascripts/prado/validation3.js
index 67d490e3..714aa93f 100644
--- a/framework/Web/Javascripts/prado/validation3.js
+++ b/framework/Web/Javascripts/prado/validation3.js
@@ -348,7 +348,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.
* </code>
*/
@@ -554,7 +554,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 707324d3..ac1ebee1 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(!is_file($dst.'/'.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplication::STATE_PERFORMANCE)
+ 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(!is_dir($this->_basePath.'/'.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplication::STATE_PERFORMANCE)
+ 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(!is_file($dst.'/'.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplication::STATE_PERFORMANCE)
+ if(!is_file($dst.'/'.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance)
{
if(@filemtime($dst.'/'.$fileName)<@filemtime($fullpath))
{
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index 130dc3cf..fcf1c8f9 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::ensureEnumerable($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 <qiang.xue@gmail.com>
+ * @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..810d8e60 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::ensureEnumerable($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 <qiang.xue@gmail.com>
+ * @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 49a34a02..dfd78ba6 100644
--- a/framework/Web/UI/TClientScriptManager.php
+++ b/framework/Web/UI/TClientScriptManager.php
@@ -139,7 +139,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';
@@ -165,7 +165,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.='&amp;mode=debug';
$writer->write(TJavaScript::renderScriptFile($url));
}
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/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php
index 5c75273e..711dd2c4 100644
--- a/framework/Web/UI/WebControls/TBaseValidator.php
+++ b/framework/Web/UI/WebControls/TBaseValidator.php
@@ -136,7 +136,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
{
$display=$this->getDisplay();
$visible=$this->getEnabled(true) && !$this->getIsValid();
- if($display==='None' || (!$visible && $display==='Dynamic'))
+ if($display===TValidatorDisplayStyle::None || (!$visible && $display===TValidatorDisplayStyle::Dynamic))
$writer->addStyleAttribute('display','none');
else if(!$visible)
$writer->addStyleAttribute('visibility','hidden');
@@ -311,20 +311,19 @@ abstract class TBaseValidator extends TLabel implements IValidator
}
/**
- * @return string the display behavior (None, Static, Dynamic) of the error message in a validation control. Defaults to Static.
+ * @return TValidatorDisplayStyle the style of displaying the error message. Defaults to TValidatorDisplayStyle::Fixed.
*/
public function getDisplay()
{
- return $this->getViewState('Display','Static');
+ return $this->getViewState('Display',TValidatorDisplayStyle::Fixed);
}
/**
- * Sets the display behavior (None, Static, Dynamic) of the error message in a validation control.
- * @param string the display behavior (None, Static, Dynamic)
+ * @param TValidatorDisplayStyle the style of displaying the error message
*/
public function setDisplay($value)
{
- $this->setViewState('Display',TPropertyValue::ensureEnum($value,array('None','Static','Dynamic')),'Static');
+ $this->setViewState('Display',TPropertyValue::ensureEnumerable($value,'TValidatorDisplayStyle'),TValidatorDisplayStyle::Fixed);
}
/**
@@ -664,4 +663,26 @@ class TValidatorClientSide extends TClientSideOptions
}
}
+
+/**
+ * TValidatorDisplayStyle class.
+ * TValidatorDisplayStyle defines the enumerable type for the possible styles
+ * that a validator control can display the error message.
+ *
+ * The following enumerable values are defined:
+ * - None: the error message is not displayed
+ * - Dynamic: the error message dynamically appears when the validator fails validation
+ * - Fixed: Similar to Dynamic except that the error message physically occupies the page layout (even though it may not be visible)
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.WebControls
+ * @since 3.0.4
+ */
+class TValidatorDisplayStyle extends TEnumerable
+{
+ const None='None';
+ const Dynamic='Dynamic';
+ const Fixed='Fixed';
+}
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index feea6227..96c43092 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -59,10 +59,6 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
*/
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
*/
private static $_safeTextParser=null;
@@ -90,7 +86,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
$page->ensureRenderInForm($this);
if(($uid=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uid);
- if(($textMode=$this->getTextMode())==='MultiLine')
+ if(($textMode=$this->getTextMode())===TTextBoxMode::MultiLine)
{
if(($rows=$this->getRows())<=0)
$rows=self::DEFAULT_ROWS;
@@ -103,7 +99,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
}
else
{
- if($textMode==='SingleLine')
+ if($textMode===TTextBoxMode::SingleLine)
{
$writer->addAttribute('type','text');
if(($text=$this->getText())!=='')
@@ -233,27 +229,20 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
}
/**
- * @return string the AutoComplete type of the textbox
+ * @return TTextBoxAutoCompleteType the AutoComplete type of the textbox
*/
public function getAutoCompleteType()
{
- return $this->getViewState('AutoCompleteType','None');
+ return $this->getViewState('AutoCompleteType',TTextBoxAutoCompleteType::None);
}
/**
- * @param string the AutoComplete type of the textbox, default value is 'None'.
- * Valid values include:
- * 'BusinessCity','BusinessCountryRegion','BusinessFax','BusinessPhone',
- * 'BusinessState','BusinessStreetAddress','BusinessUrl','BusinessZipCode',
- * 'Cellular','Company','Department','Disabled','DisplayName','Email',
- * 'FirstName','Gender','HomeCity','HomeCountryRegion','HomeFax','Homepage',
- * 'HomePhone','HomeState','HomeStreetAddress','HomeZipCode','JobTitle',
- * 'LastName','MiddleName','None','Notes','Office','Pager','Search'
+ * @param TTextBoxAutoCompleteType the AutoComplete type of the textbox, default value is TTextBoxAutoCompleteType::None.
* @throws TInvalidDataValueException if the input parameter is not a valid AutoComplete type
*/
public function setAutoCompleteType($value)
{
- $this->setViewState('AutoCompleteType',TPropertyValue::ensureEnum($value,self::$_autoCompleteTypes),'None');
+ $this->setViewState('AutoCompleteType',TPropertyValue::ensureEnumerable($value,'TTextBoxAutoCompleteType'),TTextBoxAutoCompleteType::None);
}
/**
@@ -416,21 +405,21 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
}
/**
- * @return string the behavior mode (SingleLine, MultiLine, or Password) of the TTextBox component. Defaults to SingleLine.
+ * @return TTextBoxMode the behavior mode of the TTextBox component. Defaults to TTextBoxMode::SingleLine.
*/
public function getTextMode()
{
- return $this->getViewState('TextMode','SingleLine');
+ return $this->getViewState('TextMode',TTextBoxMode::SingleLine);
}
/**
- * Sets the behavior mode (SingleLine, MultiLine, or Password) of the TTextBox component.
- * @param string the text mode
+ * Sets the behavior mode of the TTextBox component.
+ * @param TTextBoxMode the text mode
* @throws TInvalidDataValueException if the input value is not a valid text mode.
*/
public function setTextMode($value)
{
- $this->setViewState('TextMode',TPropertyValue::ensureEnum($value,array('SingleLine','MultiLine','Password')),'SingleLine');
+ $this->setViewState('TextMode',TPropertyValue::ensureEnumerable($value,'TTextBoxMode'),TTextBoxMode::SingleLine);
}
/**
@@ -467,4 +456,72 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
}
}
+/**
+ * TTextBoxMode class.
+ * TTextBoxMode defines the enumerable type for the possible mode
+ * that a {@link TTextBox} control could be at.
+ *
+ * The following enumerable values are defined:
+ * - SingleLine: the textbox will be a regular single line input
+ * - MultiLine: the textbox will be a textarea allowing multiple line input
+ * - Password: the textbox will hide user input like a password input box
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @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 <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.WebControls
+ * @since 3.0.4
+ */
+class TTextBoxAutoCompleteType extends TEnumerable
+{
+ const BusinessCity='BusinessCity';
+ const BusinessCountryRegion='BusinessCountryRegion';
+ const BusinessFax='BusinessFax';
+ const BusinessPhone='BusinessPhone';
+ const BusinessState='BusinessState';
+ const BusinessStreetAddress='BusinessStreetAddress';
+ const BusinessUrl='BusinessUrl';
+ const BusinessZipCode='BusinessZipCode';
+ const Cellular='Cellular';
+ const Company='Company';
+ const Department='Department';
+ const Disabled='Disabled';
+ const DisplayName='DisplayName';
+ const Email='Email';
+ const FirstName='FirstName';
+ const Gender='Gender';
+ const HomeCity='HomeCity';
+ const HomeCountryRegion='HomeCountryRegion';
+ const HomeFax='HomeFax';
+ const Homepage='Homepage';
+ const HomePhone='HomePhone';
+ const HomeState='HomeState';
+ const HomeStreetAddress='HomeStreetAddress';
+ const HomeZipCode='HomeZipCode';
+ const JobTitle='JobTitle';
+ const LastName='LastName';
+ const MiddleName='MiddleName';
+ const None='None';
+ const Notes='Notes';
+ const Office='Office';
+ const Pager='Pager';
+ const Search='Search';
+}
+
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TValidationSummary.php b/framework/Web/UI/WebControls/TValidationSummary.php
index c7330f94..539c6dc3 100644
--- a/framework/Web/UI/WebControls/TValidationSummary.php
+++ b/framework/Web/UI/WebControls/TValidationSummary.php
@@ -52,20 +52,19 @@ class TValidationSummary extends TWebControl
}
/**
- * @return string the display behavior (None, Static, Dynamic) of the error message in a validation summary component.
+ * @return TValidationSummaryDisplayStyle the style of displaying the error messages. Defaults to TValidationSummaryDisplayStyle::Fixed.
*/
public function getDisplay()
{
- return $this->getViewState('Display','Static');
+ return $this->getViewState('Display',TValidationSummaryDisplayStyle::Fixed);
}
/**
- * Sets the display behavior (None, Static, Dynamic) of the error message in a validation summary component.
- * @param string the display behavior (None, Static, Dynamic)
+ * @param TValidationSummaryDisplayStyle the style of displaying the error messages
*/
public function setDisplay($value)
{
- $this->setViewState('Display',TPropertyValue::ensureEnum($value,'None','Dynamic','Static'),'Static');
+ $this->setViewState('Display',TPropertyValue::ensureEnumerable($value,'TValidationSummaryDisplayStyle'),TValidationSummaryDisplayStyle::Fixed);
}
/**
@@ -86,20 +85,19 @@ class TValidationSummary extends TWebControl
}
/**
- * @return string the display mode (BulletList, List, SingleParagraph) of the validation summary. Defaults to BulletList.
+ * @return TValidationSummaryDisplayMode the mode of displaying error messages. Defaults to TValidationSummaryDisplayMode::BulletList.
*/
public function getDisplayMode()
{
- return $this->getViewState('DisplayMode','BulletList');
+ return $this->getViewState('DisplayMode',TValidationSummaryDisplayMode::BulletList);
}
/**
- * Sets the display mode (BulletList, List, SingleParagraph) of the validation summary.
- * @param string the display mode (BulletList, List, SingleParagraph)
+ * @param TValidationSummaryDisplayMode the mode of displaying error messages
*/
public function setDisplayMode($value)
{
- $this->setViewState('DisplayMode',TPropertyValue::ensureEnum($value,'List','SingleParagraph','BulletList'),'BulletList');
+ $this->setViewState('DisplayMode',TPropertyValue::ensureEnumerable($value,'TValidationSummaryDisplayMode'),TValidationSummaryDisplayMode::BulletList);
}
/**
@@ -206,7 +204,7 @@ class TValidationSummary extends TWebControl
$visible=$this->getEnabled(true) && count($this->getErrorMessages()) > 0;
if(!$visible)
{
- if($display==='None' || $display==='Dynamic')
+ if($display===TValidationSummaryDisplayStyle::None || $display===TValidationSummaryDisplayStyle::Dynamic)
$writer->addStyleAttribute('display','none');
else
$writer->addStyleAttribute('visibility','hidden');
@@ -318,13 +316,13 @@ class TValidationSummary extends TWebControl
// $this->setStyle('display:block');
switch($this->getDisplayMode())
{
- case 'List':
+ case TValidationSummaryDisplayMode::SimpleList:
$this->renderList($writer);
break;
- case 'SingleParagraph':
+ case TValidationSummaryDisplayMode::SingleParagraph:
$this->renderSingleParagraph($writer);
break;
- case 'BulletList':
+ case TValidationSummaryDisplayMode::BulletList:
$this->renderBulletList($writer);
break;
}
@@ -449,4 +447,50 @@ class TValidationSummaryClientScript extends TClientSideOptions
}
}
+
+/**
+ * TValidationSummaryDisplayMode class.
+ * TValidationSummaryDisplayMode defines the enumerable type for the possible modes
+ * that a {@link TValidationSummary} can organize and display the collected error messages.
+ *
+ * The following enumerable values are defined:
+ * - SimpleList: the error messages are displayed as a list without any decorations.
+ * - SingleParagraph: the error messages are concatenated together into a paragraph.
+ * - BulletList: the error messages are displayed as a bulleted list.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @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 <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.WebControls
+ * @since 3.0.4
+ */
+class TValidationSummaryDisplayStyle extends TEnumerable
+{
+ const None='None';
+ const Dynamic='Dynamic';
+ const Fixed='Fixed';
+}
+
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php
index 2d54afbe..0a9bb58c 100644
--- a/framework/Web/UI/WebControls/TWizard.php
+++ b/framework/Web/UI/WebControls/TWizard.php
@@ -85,6 +85,7 @@ class TWizard extends TWebControl implements INamingContainer
{
/**
* Wizard step types.
+ * @deprecated deprecated since version 3.0.4 (use TWizardStepType constants instead)
*/
const ST_AUTO='Auto';
const ST_START='Start';
@@ -918,7 +919,7 @@ class TWizard extends TWebControl implements INamingContainer
}
}
$activeStepType=$this->getStepType($activeStep);
- if($activeStepType===self::ST_COMPLETE)
+ if($activeStepType===TWizardStepType::Complete)
{
$this->_sideBar->setVisible(false);
$this->_header->setVisible(false);
@@ -1014,24 +1015,24 @@ class TWizard extends TWebControl implements INamingContainer
/**
* Determines the type of the specified wizard step.
* @param TWizardStep
- * @return string type of the step, 'Finish', 'Start', 'Step'.
+ * @return TWizardStepType type of the step
*/
protected function getStepType($wizardStep)
{
- if(($type=$wizardStep->getStepType())===self::ST_AUTO)
+ if(($type=$wizardStep->getStepType())===TWizardStepType::Auto)
{
$steps=$this->getWizardSteps();
if(($index=$steps->indexOf($wizardStep))>=0)
{
$stepCount=$steps->getCount();
- if($stepCount===1 || ($index<$stepCount-1 && $steps->itemAt($index+1)->getStepType()==='Complete'))
- return self::ST_FINISH;
+ if($stepCount===1 || ($index<$stepCount-1 && $steps->itemAt($index+1)->getStepType()===TWizardStepType::Complete))
+ return TWizardStepType::Finish;
else if($index===0)
- return self::ST_START;
+ return TWizardStepType::Start;
else if($index===$stepCount-1)
- return self::ST_FINISH;
+ return TWizardStepType::Finish;
else
- return self::ST_STEP;
+ return TWizardStepType::Step;
}
else
return $type;
@@ -1162,7 +1163,7 @@ class TWizard extends TWebControl implements INamingContainer
if(($button=$item->findControl(self::ID_SIDEBAR_BUTTON))!==null)
{
$step=$item->getDataItem();
- if(($this->getStepType($step)==='Complete'))
+ if(($this->getStepType($step)===TWizardStepType::Complete))
$button->setEnabled(false);
if(($title=$step->getTitle())!=='')
$button->setText($title);
@@ -1515,19 +1516,19 @@ class TWizardNavigationButtonStyle extends TStyle
}
/**
- * @return string button type. Default to 'Button'.
+ * @return TWizardNavigationButtonType button type. Default to TWizardNavigationButtonType::Button.
*/
public function getButtonType()
{
- return $this->_buttonType===null?'Button':$this->_buttonType;
+ return $this->_buttonType===null? TWizardNavigationButtonType::Button :$this->_buttonType;
}
/**
- * @param string button type. Valid values include 'Button', 'Image', 'Link'.
+ * @param TWizardNavigationButtonType button type.
*/
public function setButtonType($value)
{
- $this->_buttonType=TPropertyValue::ensureEnum($value,'Button','Image','Link');
+ $this->_buttonType=TPropertyValue::ensureEnumerable($value,'TWizardNavigationButtonType');
}
/**
@@ -1618,22 +1619,22 @@ class TWizardStep extends TView
}
/**
- * @return string the wizard step type. Defaults to 'Auto'.
+ * @return TWizardStepType the wizard step type. Defaults to TWizardStepType::Auto.
*/
public function getStepType()
{
- return $this->getViewState('StepType',TWizard::ST_AUTO);
+ return $this->getViewState('StepType',TWizardStepType::Auto);
}
/**
- * @param string the wizard step type. Valid values include 'Auto', 'Complete', 'Start', 'Step', 'Finish'.
+ * @param TWizardStepType the wizard step type.
*/
public function setStepType($type)
{
- $type=TPropertyValue::ensureEnum($type,TWizard::ST_AUTO,TWizard::ST_COMPLETE,TWizard::ST_STEP,TWizard::ST_START,TWizard::ST_FINISH);
+ $type=TPropertyValue::ensureEnumerable($type,'TWizardStepType');
if($type!==$this->getStepType())
{
- $this->setViewState('StepType',$type,TWizard::ST_AUTO);
+ $this->setViewState('StepType',$type,TWizardStepType::Auto);
if($this->_wizard)
$this->_wizard->wizardStepsChanged();
}
@@ -1644,7 +1645,7 @@ class TWizardStep extends TView
/**
* TCompleteWizardStep class.
*
- * TCompleteWizardStep represents a wizard step of type 'Complete'.
+ * TCompleteWizardStep represents a wizard step of type TWizardStepType::Complete.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
@@ -1654,11 +1655,11 @@ class TWizardStep extends TView
class TCompleteWizardStep extends TWizardStep
{
/**
- * @return string the wizard step type. Always 'Complete'.
+ * @return TWizardStepType the wizard step type. Always TWizardStepType::Complete.
*/
public function getStepType()
{
- return 'Complete';
+ return TWizardStepType::Complete;
}
/**
@@ -2100,13 +2101,13 @@ class TWizardNavigationTemplate extends TComponent implements ITemplate
{
switch($buttonStyle->getButtonType())
{
- case 'Button':
+ case TWizardNavigationButtonType::Button:
$button=new TButton;
break;
- case 'Link' :
+ case TWizardNavigationButtonType::Link:
$button=new TLinkButton;
break;
- case 'Image' :
+ case TWizardNavigationButtonType::Image:
$button=new TImageButton;
$button->setImageUrl($buttonStyle->getImageUrl());
break;
@@ -2218,4 +2219,53 @@ class TWizardStepNavigationTemplate extends TWizardNavigationTemplate
}
}
+
+/**
+ * TWizardNavigationButtonType class.
+ * TWizardNavigationButtonType defines the enumerable type for the possible types of buttons
+ * that can be used in the navigation part of a {@link TWizard}.
+ *
+ * The following enumerable values are defined:
+ * - Button: a regular click button
+ * - Image: an image button
+ * - Link: a hyperlink button
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @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 <qiang.xue@gmail.com>
+ * @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