diff options
author | xue <> | 2006-06-10 12:39:49 +0000 |
---|---|---|
committer | xue <> | 2006-06-10 12:39:49 +0000 |
commit | 2da825c6f1dd3726bcc866082f6d28dcc29a0c5a (patch) | |
tree | 485e1d96eee06a5337d3c589a3fc8b65acc6ab49 /framework/Web | |
parent | bd87a02b43b815f99ab9400709d8269ac56c32f3 (diff) |
Fixed #182.
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/UI/WebControls/TBaseValidator.php | 79 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TBulletedList.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TCheckBoxList.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TCompareValidator.php | 14 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TCustomValidator.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDataTypeValidator.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDropDownList.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TEmailAddressValidator.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TListBox.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TListControl.php | 9 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TListControlValidator.php | 12 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRadioButtonList.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRangeValidator.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRegularExpressionValidator.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRequiredFieldValidator.php | 16 |
15 files changed, 186 insertions, 44 deletions
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 9ff2a97d..54fea2ec 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -158,18 +158,18 @@ abstract class TBaseValidator extends TLabel implements IValidator $options['ValidationGroup'] = $this->getValidationGroup(); $options['ControlToValidate'] = $control->getClientID(); $options['ControlCssClass'] = $this->getControlCssClass(); - + $options['ControlType'] = $this->getClientControlClass($control); - + if(!is_null($this->_clientScript)) $options = array_merge($options,$this->_clientScript->getOptions()); - + return $options; } - + /** * Gets the Control type for client-side validation. If new cases exists in - * TBaseValidator::$_clientClass, be sure to update the corresponding + * TBaseValidator::$_clientClass, be sure to update the corresponding * "Javascript/validation3.js" file as well. * @param TControl control to validate. * @return string control type for client-side validation. @@ -181,21 +181,21 @@ abstract class TBaseValidator extends TLabel implements IValidator return $type; return get_class($control); } - + /** * Gets the TValidatorClientScript that allows modification of the client- - * side validator events. - * + * side validator events. + * * The client-side validator supports the following events. * # <tt>OnValidate</tt> -- raised before client-side validation is - * executed. + * executed. * # <tt>OnSuccess</tt> -- raised after client-side validation is completed * and is successfull, overrides default validator error messages updates. * # <tt>OnError</tt> -- raised after client-side validation is completed - * and failed, overrides default validator error message updates. - * + * and failed, overrides default validator error message updates. + * * You can attach custom javascript code to each of these events - * + * * @return TValidatorClientScript javascript validator event options. */ public function getClientSide() @@ -204,7 +204,7 @@ abstract class TBaseValidator extends TLabel implements IValidator $this->_clientScript = $this->createClientScript(); return $this->_clientScript; } - + /** * @return TValidatorClientScript javascript validator event options. */ @@ -228,7 +228,7 @@ abstract class TBaseValidator extends TLabel implements IValidator if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) { $manager['FormID'] = $formID; - $options = TJavaScript::encode($manager); + $options = TJavaScript::encode($manager); $scripts->registerPradoScript('validator'); $scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});"); } @@ -264,16 +264,21 @@ abstract class TBaseValidator extends TLabel implements IValidator { if($this->getEnabled(true)) { - $class = get_class($this); - $scriptKey = "prado:".$this->getClientID(); - $scripts = $this->getPage()->getClientScript(); - $options = TJavaScript::encode($this->getClientScriptOptions()); - $js = "new Prado.WebUI.{$class}({$options});"; - $scripts->registerEndScript($scriptKey, $js); + $key = 'prado:'.$this->getClientID(); + $options = TJavaScript::encode($this->getClientScriptOptions()); + $script = 'new '.$this->getClientClassName().'('.$options.');'; + $this->getPage()->getClientScript()->registerEndScript($key, $script); } } /** + * Gets the name of the javascript class responsible for performing validation for this control. + * This method overrides the parent implementation. + * @return string the javascript class name + */ + abstract protected function getClientClassName(); + + /** * This method overrides the parent implementation to forbid setting ForControl. * @param string the associated control ID * @throws TNotSupportedException whenever this method is called @@ -515,22 +520,22 @@ abstract class TBaseValidator extends TLabel implements IValidator /** * TValidatorClientScript class. - * + * * Client-side validator events can be modified through the {@link * TBaseValidator::getClientSide ClientSide} property of a validator. The * subproperties of ClientSide are those of the TValidatorClientScript * properties. The client-side validator supports the following events. - * + * * The <tt>OnValidate</tt> event is raise before the validator validation * functions are called. - * + * * The <tt>OnSuccess</tt> event is raised after the validator has successfully * validate the control. - * + * * The <tt>OnError</tt> event is raised after the validator fails validation. - * + * * See the quickstart documentation for further details. - * + * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @version $Revision: $ $Date: $ * @package System.Web.UI.WebControls @@ -542,7 +547,7 @@ class TValidatorClientScript extends TComponent * @var TMap client-side validator event javascript code. */ private $_options; - + /** * Constructor. */ @@ -550,25 +555,25 @@ class TValidatorClientScript extends TComponent { $this->_options = new TMap; } - + /** * @return string javascript code for client-side OnValidate event. */ public function getOnValidate() { - return $this->_options->itemAt['OnValidate']; + return $this->_options->itemAt['OnValidate']; } - + /** * Client-side OnValidate validator event is raise before the validators - * validation functions are called. + * validation functions are called. * @param string javascript code for client-side OnValidate event. */ public function setOnValidate($javascript) { $this->_options->add('OnValidate', $this->ensureFunction($javascript)); } - + /** * Client-side OnSuccess event is raise after validation is successfull. * This will override the default client-side validator behaviour. @@ -578,7 +583,7 @@ class TValidatorClientScript extends TComponent { $this->_options->add('OnSuccess', $this->ensureFunction($javascript)); } - + /** * @return string javascript code for client-side OnSuccess event. */ @@ -586,7 +591,7 @@ class TValidatorClientScript extends TComponent { return $this->_options->itemAt('OnSuccess'); } - + /** * Client-side OnError event is raised after validation failure. * This will override the default client-side validator behaviour. @@ -596,7 +601,7 @@ class TValidatorClientScript extends TComponent { $this->_options->add('OnError', $this->ensureFunction($javascript)); } - + /** * @return string javascript code for client-side OnError event. */ @@ -604,7 +609,7 @@ class TValidatorClientScript extends TComponent { return $this->_options->itemAt('OnError'); } - + /** * @return array list of client-side event code. */ @@ -612,7 +617,7 @@ class TValidatorClientScript extends TComponent { return $this->_options->toArray(); } - + /** * Ensure the string is a valid javascript function. If the string begins * with "javascript:" valid javascript function is assumed, otherwise the diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php index 05cbaab1..4274154e 100644 --- a/framework/Web/UI/WebControls/TBulletedList.php +++ b/framework/Web/UI/WebControls/TBulletedList.php @@ -84,6 +84,16 @@ class TBulletedList extends TListControl implements IPostBackEventHandler }
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TBulletedList';
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This overrides the parent implementation with additional bulleted list specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index 2a16673c..e6ca3642 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -106,6 +106,16 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont }
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TCheckBoxList';
+ }
+
+ /**
* @return string the alignment of the text caption, defaults to 'Right'.
*/
public function getTextAlign()
diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php index b5ebd3ab..93664b2e 100644 --- a/framework/Web/UI/WebControls/TCompareValidator.php +++ b/framework/Web/UI/WebControls/TCompareValidator.php @@ -31,8 +31,8 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); * type before the comparison operation is performed. The following value types are supported:
* - <b>Integer</b> A 32-bit signed integer data type.
* - <b>Float</b> A double-precision floating point number data type.
- * - <b>Date</b> A date data type. The format can be specified by the
- * {@link setDateFormat DateFormat} property
+ * - <b>Date</b> A date data type. The format can be specified by the
+ * {@link setDateFormat DateFormat} property
* - <b>String</b> A string data type.
*
* Use the {@link setOperator Operator} property to specify the type of comparison
@@ -47,6 +47,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); class TCompareValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TCompareValidator';
+ }
+
+ /**
* @return string the data type that the values being compared are converted to before the comparison is made. Defaults to String.
*/
public function getDataType()
diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php index 27cfa67a..32510f89 100644 --- a/framework/Web/UI/WebControls/TCustomValidator.php +++ b/framework/Web/UI/WebControls/TCustomValidator.php @@ -55,6 +55,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); class TCustomValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TCustomValidator';
+ }
+
+ /**
* @return string the name of the custom client-side script function used for validation.
*/
public function getClientValidationFunction()
diff --git a/framework/Web/UI/WebControls/TDataTypeValidator.php b/framework/Web/UI/WebControls/TDataTypeValidator.php index ebcaace7..bd7569fc 100644 --- a/framework/Web/UI/WebControls/TDataTypeValidator.php +++ b/framework/Web/UI/WebControls/TDataTypeValidator.php @@ -37,6 +37,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); class TDataTypeValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TDataTypeValidator';
+ }
+
+ /**
* @return string the data type that the values being compared are converted to before the comparison is made. Defaults to String.
*/
public function getDataType()
diff --git a/framework/Web/UI/WebControls/TDropDownList.php b/framework/Web/UI/WebControls/TDropDownList.php index 14a4dac4..860fe69c 100644 --- a/framework/Web/UI/WebControls/TDropDownList.php +++ b/framework/Web/UI/WebControls/TDropDownList.php @@ -39,6 +39,16 @@ class TDropDownList extends TListControl implements IPostBackDataHandler, IValid }
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TDropDownList';
+ }
+
+ /**
* Loads user input data.
* This method is primarly used by framework developers.
* @param string the key that can be used to retrieve data from the input data collection
diff --git a/framework/Web/UI/WebControls/TEmailAddressValidator.php b/framework/Web/UI/WebControls/TEmailAddressValidator.php index 3534d1d0..e1150233 100644 --- a/framework/Web/UI/WebControls/TEmailAddressValidator.php +++ b/framework/Web/UI/WebControls/TEmailAddressValidator.php @@ -36,6 +36,16 @@ class TEmailAddressValidator extends TRegularExpressionValidator const EMAIL_REGEXP="\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TEmailAddressValidator';
+ }
+
+ /**
* @return string the regular expression that determines the pattern used to validate a field.
*/
public function getRegularExpression()
diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php index 5ee3f58e..972ebbcb 100644 --- a/framework/Web/UI/WebControls/TListBox.php +++ b/framework/Web/UI/WebControls/TListBox.php @@ -48,6 +48,16 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl }
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TListBox';
+ }
+
+ /**
* Registers the list control to load post data on postback.
* This method overrides the parent implementation.
* @param mixed event parameter
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index 2953f380..f85cc741 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -115,7 +115,7 @@ abstract class TListControl extends TDataBoundControl if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
{
$writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.'.get_class($this),$this->getPostBackOptions());
+ $this->getPage()->getClientScript()->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
}
if(!$this->getEnabled(true) && $this->getEnabled())
$writer->addAttribute('disabled','disabled');
@@ -123,6 +123,13 @@ abstract class TListControl extends TDataBoundControl }
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ abstract protected function getClientClassName();
+
+ /**
* @return array postback options for JS postback code
*/
protected function getPostBackOptions()
diff --git a/framework/Web/UI/WebControls/TListControlValidator.php b/framework/Web/UI/WebControls/TListControlValidator.php index be69085d..010a7e77 100644 --- a/framework/Web/UI/WebControls/TListControlValidator.php +++ b/framework/Web/UI/WebControls/TListControlValidator.php @@ -64,6 +64,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); class TListControlValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TListControlValidator';
+ }
+
+ /**
* @return integer min number of selections. Defaults to -1, meaning not set.
*/
public function getMinSelection()
@@ -195,7 +205,7 @@ class TListControlValidator extends TBaseValidator if(!$control instanceof TListControl)
{
throw new TConfigurationException(
- 'tlistcontrolvalidator_invalid_control',
+ 'listcontrolvalidator_invalid_control',
$this->getID(),$this->getControlToValidate(), get_class($control));
}
diff --git a/framework/Web/UI/WebControls/TRadioButtonList.php b/framework/Web/UI/WebControls/TRadioButtonList.php index b0a36c9d..95725836 100644 --- a/framework/Web/UI/WebControls/TRadioButtonList.php +++ b/framework/Web/UI/WebControls/TRadioButtonList.php @@ -53,6 +53,16 @@ class TRadioButtonList extends TCheckBoxList }
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRadioButtonList';
+ }
+
+ /**
* Loads user input data.
* This method is primarly used by framework developers.
* @param string the key that can be used to retrieve data from the input data collection
diff --git a/framework/Web/UI/WebControls/TRangeValidator.php b/framework/Web/UI/WebControls/TRangeValidator.php index b7387522..9d23eb5e 100644 --- a/framework/Web/UI/WebControls/TRangeValidator.php +++ b/framework/Web/UI/WebControls/TRangeValidator.php @@ -43,6 +43,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); class TRangeValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRangeValidator';
+ }
+
+ /**
* @return string the minimum value of the validation range.
*/
public function getMinValue()
diff --git a/framework/Web/UI/WebControls/TRegularExpressionValidator.php b/framework/Web/UI/WebControls/TRegularExpressionValidator.php index e73fd5be..3099514b 100644 --- a/framework/Web/UI/WebControls/TRegularExpressionValidator.php +++ b/framework/Web/UI/WebControls/TRegularExpressionValidator.php @@ -50,6 +50,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); class TRegularExpressionValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRegularExpressionValidator';
+ }
+
+ /**
* @return string the regular expression that determines the pattern used to validate a field.
*/
public function getRegularExpression()
diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php index 04e333eb..b8a939ad 100644 --- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php +++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php @@ -21,7 +21,7 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); * TRequiredFieldValidator makes the associated input control a required field.
* The input control fails validation if its value does not change from
* the {@link setInitialValue InitialValue} property upon losing focus.
- *
+ *
* Validation will also succeed if input is of TListControl type and the number
* of selected values different from the initial value is greater than zero.
*
@@ -33,6 +33,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); class TRequiredFieldValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRequiredFieldValidator';
+ }
+
+ /**
* @return string the initial value of the associated input control. Defaults to empty string.
* If the associated input control does not change from this initial value
* upon postback, the validation fails.
@@ -56,11 +66,11 @@ class TRequiredFieldValidator extends TBaseValidator * This method overrides the parent's implementation.
* The validation succeeds if the input component changes its data
* from the {@link getInitialValue InitialValue} or the input control is not given.
- *
+ *
* Validation will also succeed if input is of TListControl type and the
* number of selected values different from the initial value is greater
* than zero.
- *
+ *
* @return boolean whether the validation succeeds
*/
protected function evaluateIsValid()
|