diff options
Diffstat (limited to 'framework/Web/UI/WebControls/TValidationSummary.php')
-rw-r--r-- | framework/Web/UI/WebControls/TValidationSummary.php | 78 |
1 files changed, 20 insertions, 58 deletions
diff --git a/framework/Web/UI/WebControls/TValidationSummary.php b/framework/Web/UI/WebControls/TValidationSummary.php index 027b0410..c7330f94 100644 --- a/framework/Web/UI/WebControls/TValidationSummary.php +++ b/framework/Web/UI/WebControls/TValidationSummary.php @@ -40,7 +40,7 @@ class TValidationSummary extends TWebControl * @var TValidatorClientScript validator client-script options.
*/
private $_clientScript;
-
+
/**
* Constructor.
* This method sets the foreground color to red.
@@ -232,7 +232,7 @@ class TValidationSummary extends TWebControl if($this->getEnableClientScript() && !$cs->isEndScriptRegistered($scriptKey))
{
$manager['FormID'] = $formID;
- $options = TJavaScript::encode($manager);
+ $options = TJavaScript::encode($manager);
$cs->registerPradoScript('validator');
$cs->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});");
}
@@ -262,10 +262,11 @@ class TValidationSummary extends TWebControl $options['Refresh'] = $this->getAutoUpdate();
$options['ValidationGroup'] = $this->getValidationGroup();
$options['Display'] = $this->getDisplay();
-
+
if(!is_null($this->_clientScript))
- $options = array_merge($options,$this->_clientScript->getOptions());
-
+ $options = array_merge($options,
+ $this->_clientScript->getOptions()->toArray());
+
return $options;
}
@@ -279,7 +280,7 @@ class TValidationSummary extends TWebControl $this->_clientScript = $this->createClientScript();
return $this->_clientScript;
}
-
+
/**
* @return TValidationSummaryClientScript javascript validation summary
* event options.
@@ -388,48 +389,35 @@ class TValidationSummary extends TWebControl /**
* TValidationSummaryClientScript class.
- *
+ *
* Client-side validation summary events such as {@link setOnHideSummary
* OnHideSummary} and {@link setOnShowSummary OnShowSummary} can be modified
* through the {@link TBaseValidator:: getClientSide ClientSide} property of a
* validation summary.
- *
+ *
* The <tt>OnHideSummary</tt> event is raise when the validation summary
* requests to hide the messages.
- *
+ *
* The <tt>OnShowSummary</tt> event is raised when the validation summary
* requests to show the messages.
- *
+ *
* See the quickstart documentation for further details.
- *
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
* @since 3.0
*/
-class TValidationSummaryClientScript extends TComponent
+class TValidationSummaryClientScript extends TClientSideOptions
{
/**
- * @var TMap client-side validation summary event javascript code.
- */
- private $_options;
-
- /**
- * Constructor.
- */
- public function __construct()
- {
- $this->_options = new TMap;
- }
-
- /**
* @return string javascript code for client-side OnHideSummary event.
*/
public function getOnHideSummary()
{
- return $this->_options->itemAt['OnHideSummary'];
+ return $this->getOption('OnHideSummary');
}
-
+
/**
* Client-side OnHideSummary validation summary event is raise when all the
* validators are valid. This will override the default client-side
@@ -438,9 +426,9 @@ class TValidationSummaryClientScript extends TComponent */
public function setOnHideSummary($javascript)
{
- $this->_options->add('OnHideSummary', $this->ensureFunction($javascript));
+ $this->setFunction('OnHideSummary', $javascript);
}
-
+
/**
* Client-side OnShowSummary event is raise when one or more validators are
* not valid. This will override the default client-side validation summary
@@ -449,42 +437,16 @@ class TValidationSummaryClientScript extends TComponent */
public function setOnShowSummary($javascript)
{
- $this->_options->add('OnShowSummary', $this->ensureFunction($javascript));
+ $this->setFunction('OnShowSummary', $javascript);
}
-
+
/**
* @return string javascript code for client-side OnShowSummary event.
*/
public function getOnShowSummary()
{
- return $this->_options->itemAt('OnShowSummary');
+ return $this->getOption('OnShowSummary');
}
-
- /**
- * @return array list of client-side event code.
- */
- public function getOptions()
- {
- 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
- * code block is enclosed with "function(summary, validators){ }" block.
- * @param string javascript code.
- * @return string javascript function code.
- */
- private function ensureFunction($javascript)
- {
- if(TJavascript::isFunction($javascript))
- return $javascript;
- else
- {
- $code = "function(summary, validators){ {$javascript} }";
- return TJavascript::quoteFunction($code);
- }
- }
}
?>
\ No newline at end of file |