diff options
author | xue <> | 2006-04-28 11:10:06 +0000 |
---|---|---|
committer | xue <> | 2006-04-28 11:10:06 +0000 |
commit | 2cc93773feb5e76d2dd002b1dcd463a01d606794 (patch) | |
tree | c3615e1183fa6db678dbdf08b07c25543a2cde09 | |
parent | 1f63d5c05ba117e0158c02d5bc79fa1f38f8ce85 (diff) |
Merge from 3.0 branch till 985.
19 files changed, 463 insertions, 122 deletions
diff --git a/.gitattributes b/.gitattributes index fc04fe48..df9af126 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1021,9 +1021,12 @@ tests/FunctionalTests/config.php -text tests/FunctionalTests/features.php -text tests/FunctionalTests/features/index.php -text tests/FunctionalTests/features/protected/application.xml -text +tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl -text +tests/FunctionalTests/features/protected/controls/LabeledTextbox.php -text tests/FunctionalTests/features/protected/controls/Layout.php -text tests/FunctionalTests/features/protected/controls/Layout.tpl -text tests/FunctionalTests/features/protected/pages/ColorPicker.page -text +tests/FunctionalTests/features/protected/pages/CompositeControl.page -text tests/FunctionalTests/features/protected/pages/DatePicker.page -text tests/FunctionalTests/features/protected/pages/FeatureList.page -text tests/FunctionalTests/features/protected/pages/FeatureList.php -text @@ -1035,6 +1038,7 @@ tests/FunctionalTests/features/protected/pages/I18N/Home.zh_CN.page -text tests/FunctionalTests/features/protected/pages/I18N/config.xml -text tests/FunctionalTests/features/protected/pages/RatingList.page -text tests/FunctionalTests/features/protected/pages/ValidatorEffects.page -text +tests/FunctionalTests/features/tests/CompositeControlTestCase.php -text tests/FunctionalTests/index.php -text tests/FunctionalTests/quickstart.php -text tests/FunctionalTests/quickstart/Advanced/I18N.php -text @@ -1155,6 +1159,7 @@ tests/FunctionalTests/tickets/protected/pages/Ticket27.page -text tests/FunctionalTests/tickets/protected/pages/Ticket54.page -text tests/FunctionalTests/tickets/protected/pages/Ticket54Master.php -text tests/FunctionalTests/tickets/protected/pages/Ticket54Master.tpl -text +tests/FunctionalTests/tickets/protected/pages/Ticket68.page -text tests/FunctionalTests/tickets/protected/pages/Ticket72.page -text tests/FunctionalTests/tickets/protected/pages/Ticket72.php -text tests/FunctionalTests/tickets/protected/pages/config.xml -text @@ -8,6 +8,7 @@ NEW: SQLMap (Wei) Version 3.0.0 May 1, 2006
=========================
+BUG: Ticket#68 - 2 TButtons with THtmlArea causes second button to fail to function (Wei)
BUG: Ticket#70 - Javascript for TDataTypeValidator added (Wei)
BUG: Ticket#131 - TImageMap and TLinkButton continue to postback even client validator fails (Wei)
BUG: Ticket#135 - TBrowserLogRoute reports wrong timings (Qiang)
@@ -26,6 +27,7 @@ ENH: Format string in classes extending TDataGridColumn can now evaluate an expr ENH: Format string in classes extending TListControl can now evaluate an expression (Qiang)
ENH: Custom visual effects can be added to client-side validators. (Wei)
ENH: TJavascript::encode() allows raw javascript code when string begins with "javascript:" (Wei)
+ENH: Update TinyMCE to 2.0.5.1
CHG: Rewrote client-side javascript validators, check your client-side validation behaviour (Wei)
CHG: Updated the javascript Prototype library, a few utilties functions REMOVED, may break your existing javascript code. (Wei)
CHG: Build javascript without compression, only comments are removed. (Wei)
@@ -35,7 +37,6 @@ NEW: TListControlValidator (Wei) NEW: TClientScript (Wei)
-
Version 3.0RC2 April 16, 2006
=============================
BUG: Ticket#54 - recursive reverse() definition (Wei)
@@ -4,7 +4,7 @@ !!!IMPORTANT!!!
-After upgrading, remember to delete everything under
+After installing the framework, remember to delete everything under
your PRADO application's assets and runtime directories.
@@ -16,9 +16,9 @@ for both A and B. Upgrading from v3.0.0 RC2
-------------------------
-There should be no PHP compatibility issues. Javascript libraries
-were updated and client-side validators rewritten.
-
+There should be no PHP compatibility issues. Remember to clean up 'assets'
+directory of your PRADO application as Javascript libraries were updated
+and client-side validators rewritten.
Upgrading from v3.0.0 RC1
diff --git a/framework/3rdParty/TinyMCE/tiny_mce.md5 b/framework/3rdParty/TinyMCE/tiny_mce.md5 index 861556e5..1ee34468 100644 --- a/framework/3rdParty/TinyMCE/tiny_mce.md5 +++ b/framework/3rdParty/TinyMCE/tiny_mce.md5 @@ -1 +1 @@ -b79c5807630d8324b2c968eb563e9076 *tiny_mce.tar +505c2761e878f40d5451115bd5643355 *tiny_mce.tar diff --git a/framework/3rdParty/TinyMCE/tiny_mce.tar b/framework/3rdParty/TinyMCE/tiny_mce.tar Binary files differindex f57b3509..663abb34 100644 --- a/framework/3rdParty/TinyMCE/tiny_mce.tar +++ b/framework/3rdParty/TinyMCE/tiny_mce.tar diff --git a/framework/3rdParty/readme.html b/framework/3rdParty/readme.html index 923e9056..ea5b05db 100644 --- a/framework/3rdParty/readme.html +++ b/framework/3rdParty/readme.html @@ -37,7 +37,7 @@ projects. </tr>
<tr>
<td><a href="TinyMCE">TinyMCE</a></td>
- <td><a href="http://tinymce.moxiecode.com/">TinyMCE Javascript Content Editor</a> (v2.0.2)</td>
+ <td><a href="http://tinymce.moxiecode.com/">TinyMCE Javascript Content Editor</a> (v2.0.5.1)</td>
<td><a href="tiny_mce/license.txt">GNU LIBRARY GENERAL PUBLIC LICENSE</a></td>
<td>System.Web.UI.WebControls.THtmlArea</td>
<td>TinyMCE is a powerful WYSIWYG editor control for web browsers such as MSIE or Mozilla that enables the user to edit HTML contents in a more user friendly way.</td>
diff --git a/framework/Web/Javascripts/js/validator.js b/framework/Web/Javascripts/js/validator.js index 5e23df50..88dfb25e 100644 --- a/framework/Web/Javascripts/js/validator.js +++ b/framework/Web/Javascripts/js/validator.js @@ -156,41 +156,45 @@ Prado.WebUI.TValidationSummary.prototype = group : null, options : {}, visible : false, -summary : null, +messages : null, initialize : function(options) { this.options = options; this.group = options.ValidationGroup; -this.summary = $(options.ID); -this.visible = this.summary.style.visibility != "hidden" -this.visible = this.visible && this.summary.style.display != "none"; +this.messages = $(options.ID); +this.visible = this.messages.style.visibility != "hidden" +this.visible = this.visible && this.messages.style.display != "none"; Prado.Validation.addSummary(options.FormID, this); }, updateSummary : function(validators, update) { if(validators.length <= 0) -return this.hideSummary(update); +{ +if(update || this.options.Refresh != false) +{ +return this.hideSummary(validators); +} +return; +} var refresh = update || this.visible == false || this.options.Refresh != false; if(this.options.ShowSummary != false && refresh) { -this.displayHTMLMessages(this.getMessages(validators)); -this.visible = true; +this.updateHTMLMessages(this.getMessages(validators)); +this.showSummary(validators); } if(this.options.ScrollToSummary != false) -window.scrollTo(this.summary.offsetLeft-20, this.summary.offsetTop-20); +window.scrollTo(this.messages.offsetLeft-20, this.messages.offsetTop-20); if(this.options.ShowMessageBox == true && refresh) { this.alertMessages(this.getMessages(validators)); this.visible = true; } }, -displayHTMLMessages : function(messages) +updateHTMLMessages : function(messages) { -this.summary.show(); -this.summary.style.visibility = "visible"; -while(this.summary.childNodes.length > 0) -this.summary.removeChild(this.summary.lastChild); -new Insertion.Bottom(this.summary, this.formatSummary(messages)); +while(this.messages.childNodes.length > 0) +this.messages.removeChild(this.messages.lastChild); +new Insertion.Bottom(this.messages, this.formatSummary(messages)); }, alertMessages : function(messages) { @@ -208,15 +212,28 @@ messages.push(message); }) return messages; }, -hideSummary : function(refresh) +hideSummary : function(validators) +{if(typeof(this.options.OnHideSummary) == "function") { -if(refresh || this.options.Refresh != false) +this.messages.style.visibility="visible"; +this.options.OnHideSummary(this,validators) +} +else { +this.messages.style.visibility="hidden"; if(this.options.Display == "None" || this.options.Display == "Dynamic") -this.summary.hide(); -this.summary.style.visibility="hidden"; -this.visible = false; +this.messages.hide(); } +this.visible = false; +}, +showSummary : function(validators) +{ +this.messages.style.visibility="visible"; +if(typeof(this.options.OnShowSummary) == "function") +this.options.OnShowSummary(this,validators); +else +this.messages.show(); +this.visible = true; }, formats : function(type) { @@ -330,6 +347,7 @@ if(this.isValid) if(typeof(this.options.OnSuccess) == "function") { this.visible = true; +this.message.style.visibility = "visible"; this.updateControlCssClass(this.control, this.isValid); this.options.OnSuccess(this, invoker); } @@ -341,6 +359,7 @@ else if(typeof(this.options.OnError) == "function") { this.visible = true; +this.message.style.visibility = "visible"; this.updateControlCssClass(this.control, this.isValid); this.options.OnError(this, invoker); } @@ -415,6 +434,10 @@ getValidationValue : function(control) this.observeDatePickerChanges(); return Prado.WebUI.TDatePicker.getDropDownDate(control).getTime(); } + case 'THtmlArea': + if(typeof tinyMCE != "undefined") +tinyMCE.triggerSave(); +return this.trim($F(control)); default: if(this.isListControlType()) return this.getFirstSelectedListValue(); diff --git a/framework/Web/Javascripts/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js index 3ed31744..1f154fec 100644 --- a/framework/Web/Javascripts/prado/validation3.js +++ b/framework/Web/Javascripts/prado/validation3.js @@ -336,7 +336,7 @@ Prado.WebUI.TValidationSummary.prototype = group : null,
options : {},
visible : false,
- summary : null,
+ messages : null,
/**
* <code>
@@ -356,9 +356,9 @@ Prado.WebUI.TValidationSummary.prototype = {
this.options = options;
this.group = options.ValidationGroup;
- this.summary = $(options.ID);
- this.visible = this.summary.style.visibility != "hidden"
- this.visible = this.visible && this.summary.style.display != "none";
+ this.messages = $(options.ID);
+ this.visible = this.messages.style.visibility != "hidden"
+ this.visible = this.visible && this.messages.style.display != "none";
Prado.Validation.addSummary(options.FormID, this);
},
@@ -370,19 +370,25 @@ Prado.WebUI.TValidationSummary.prototype = */
updateSummary : function(validators, update)
{
- if(validators.length <= 0)
- return this.hideSummary(update);
+ if(validators.length <= 0)
+ {
+ if(update || this.options.Refresh != false)
+ {
+ return this.hideSummary(validators);
+ }
+ return;
+ }
var refresh = update || this.visible == false || this.options.Refresh != false;
if(this.options.ShowSummary != false && refresh)
{
- this.displayHTMLMessages(this.getMessages(validators));
- this.visible = true;
+ this.updateHTMLMessages(this.getMessages(validators));
+ this.showSummary(validators);
}
if(this.options.ScrollToSummary != false)
- window.scrollTo(this.summary.offsetLeft-20, this.summary.offsetTop-20);
+ window.scrollTo(this.messages.offsetLeft-20, this.messages.offsetTop-20);
if(this.options.ShowMessageBox == true && refresh)
{
@@ -394,13 +400,11 @@ Prado.WebUI.TValidationSummary.prototype = /**
* Display the validator error messages as inline HTML.
*/
- displayHTMLMessages : function(messages)
+ updateHTMLMessages : function(messages)
{
- this.summary.show();
- this.summary.style.visibility = "visible";
- while(this.summary.childNodes.length > 0)
- this.summary.removeChild(this.summary.lastChild);
- new Insertion.Bottom(this.summary, this.formatSummary(messages));
+ while(this.messages.childNodes.length > 0)
+ this.messages.removeChild(this.messages.lastChild);
+ new Insertion.Bottom(this.messages, this.formatSummary(messages));
},
/**
@@ -428,18 +432,34 @@ Prado.WebUI.TValidationSummary.prototype = },
/**
- * Hides the validation summary if options['Refresh'] is not false.
- * @param boolean true to always hide the summary
+ * Hides the validation summary.
*/
- hideSummary : function(refresh)
- {
- if(refresh || this.options.Refresh != false)
+ hideSummary : function(validators)
+ { if(typeof(this.options.OnHideSummary) == "function")
{
+ this.messages.style.visibility="visible";
+ this.options.OnHideSummary(this,validators)
+ }
+ else
+ {
+ this.messages.style.visibility="hidden";
if(this.options.Display == "None" || this.options.Display == "Dynamic")
- this.summary.hide();
- this.summary.style.visibility="hidden";
- this.visible = false;
- }
+ this.messages.hide();
+ }
+ this.visible = false;
+ },
+
+ /**
+ * Shows the validation summary.
+ */
+ showSummary : function(validators)
+ {
+ this.messages.style.visibility="visible";
+ if(typeof(this.options.OnShowSummary) == "function")
+ this.options.OnShowSummary(this,validators);
+ else
+ this.messages.show();
+ this.visible = true;
},
/**
@@ -638,6 +658,7 @@ Prado.WebUI.TBaseValidator.prototype = if(typeof(this.options.OnSuccess) == "function")
{
this.visible = true;
+ this.message.style.visibility = "visible";
this.updateControlCssClass(this.control, this.isValid);
this.options.OnSuccess(this, invoker);
}
@@ -648,7 +669,8 @@ Prado.WebUI.TBaseValidator.prototype = {
if(typeof(this.options.OnError) == "function")
{
- this.visible = true;
+ this.visible = true;
+ this.message.style.visibility = "visible";
this.updateControlCssClass(this.control, this.isValid);
this.options.OnError(this, invoker);
}
@@ -750,6 +772,10 @@ Prado.WebUI.TBaseValidator.prototype = return Prado.WebUI.TDatePicker.getDropDownDate(control).getTime();
}
+ case 'THtmlArea':
+ if(typeof tinyMCE != "undefined")
+ tinyMCE.triggerSave();
+ return this.trim($F(control));
default:
if(this.isListControlType())
return this.getFirstSelectedListValue();
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 4ca4c1f6..a63941db 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -43,7 +43,7 @@ * * You can also customized the client-side behaviour by adding javascript * code to the subproperties of the {@link getClientValidation ClientValidation} - * property. + * property. See quickstart documentation for further details. * * You can also place a {@link TValidationSummary} control on a page to display error messages * from the validators together. In this case, only the {@link setErrorMessage ErrorMessage} @@ -79,7 +79,9 @@ abstract class TBaseValidator extends TLabel implements IValidator * @var boolean whether the validator has been registered with the page */ private $_registered=false; - + /** + * @var TValidatorClientScript validator client-script options. + */ private $_clientScript; /** @@ -186,7 +188,7 @@ abstract class TBaseValidator extends TLabel implements IValidator */ protected function createClientScript() { - return new TValidatorClientScript($this->getPage()->getClientScript()); + return new TValidatorClientScript; } /** @@ -491,7 +493,21 @@ abstract class TBaseValidator extends TLabel implements IValidator /** * TValidatorClientScript class. * - * @todo Add doc to quickstart and classes. + * Client-side validator events can be modified through the {@link + * TBaseValidator::getClientValidation ClientValidation} property of a + * validator. The subproperties of ClientValidation 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: $ @@ -500,58 +516,95 @@ abstract class TBaseValidator extends TLabel implements IValidator */ class TValidatorClientScript extends TComponent { + /** + * @var TMap client-side validator event javascript code. + */ private $_options; - private $_manager; - private $_effectsEnabled = false; - public function __construct($manager) + /** + * Constructor. + */ + public function __construct() { $this->_options = new TMap; - $this->_manager = $manager; } + /** + * @return string javascript code for client-side OnValidate event. + */ public function getOnValidate() { return $this->_options->itemAt['OnValidate']; } + /** + * Client-side OnValidate validator event is raise before the validators + * 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. + * @param string javascript code for client-side OnSuccess event. + */ public function setOnSuccess($javascript) { $this->_options->add('OnSuccess', $this->ensureFunction($javascript)); } + /** + * @return string javascript code for client-side OnSuccess event. + */ public function getOnSuccess() { return $this->_options->itemAt('OnSuccess'); } + /** + * Client-side OnError event is raised after validation failure. + * This will override the default client-side validator behaviour. + * @param string javascript code for client-side OnError event. + */ public function setOnError($javascript) { $this->_options->add('OnError', $this->ensureFunction($javascript)); } + /** + * @return string javascript code for client-side OnError event. + */ public function getOnError() { return $this->_options->itemAt('OnError'); } + /** + * @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(validator, sender){ }" block. + * @param string javascript code. + * @return string javascript function code. + */ private function ensureFunction($javascript) { if(TJavascript::isFunction($javascript)) return $javascript; else { - $code = "function(validator, invoker){ {$javascript} }"; + $code = "function(validator, sender){ {$javascript} }"; return TJavascript::quoteFunction($code); } } diff --git a/framework/Web/UI/WebControls/THtmlArea.php b/framework/Web/UI/WebControls/THtmlArea.php index 8e5fcd16..8b214b69 100644 --- a/framework/Web/UI/WebControls/THtmlArea.php +++ b/framework/Web/UI/WebControls/THtmlArea.php @@ -78,44 +78,44 @@ Prado::using('System.Web.UI.WebControls.TTextBox'); */
class THtmlArea extends TTextBox
{
- // Qiang: need to clean up the following (too inefficient)
+ /**
+ * @var array list of locale => language file pairs.
+ */
private static $_langs = array(
- 'da' => array('da'),
- 'fa' => array('fa'),
- 'hu' => array('hu'),
- 'nb' => array('nb'),
- 'pt_br' => array('pt_BR'),
- 'sk' => array('sk'),
- 'zh_tw_utf8' => array('zh_TW', 'zh_HK'),
- 'ar' => array('ar'),
- 'de' => array('de'),
- 'fi' => array('fi'),
- 'is' => array('is'),
- 'nl' => array('nl'),
- 'sv' => array('sv'),
- 'ca' => array('ca'),
- 'el' => array('el'),
- 'fr' => array('fr'),
- 'it' => array('it'),
- 'nn' => array('nn'), //what is nn?
-// 'ru' => array('ru'),
- 'th' => array('th'),
- 'cs' => array('cs'),
- 'en' => array('en'),
- 'fr_ca' => array('fr_CA'),
- 'ja' => array('ja'),
- 'pl' => array('pl'),
-// 'ru_KOI8-R' => array('ru'), /// what is this?
- 'zh_cn' => array('zh_CN'),
- 'cy' => array('cy'), //what is this?
- 'es' => array('es'),
- 'he' => array('he'),
- 'ko' => array('ko'),
- 'pt' => array('pt'),
- 'ru_UTF-8' => array('ru'),
- 'tr' => array('tr'),
- 'si' => array('si'),
-// 'zh_tw' => array('zh_TW'),
+ 'ar' => 'ar',
+ 'ca' => 'ca',
+ 'cs' => 'cs',
+ 'da' => 'da',
+ 'de' => 'de',
+ 'el' => 'el',
+ 'en' => 'en',
+ 'es' => 'es',
+ 'fa' => 'fa',
+ 'fi' => 'fi',
+ 'fr' => 'fr',
+ 'fr_CA' => 'fr_ca',
+ 'he' => 'he',
+ 'hu' => 'hu',
+ 'is' => 'is',
+ 'it' => 'it',
+ 'ja' => 'ja',
+ 'ko' => 'ko',
+ 'nb' => 'nb',
+ 'nl' => 'nl',
+ 'pl' => 'pl',
+ 'pt' => 'pt',
+ 'pt_BR' => 'pt_br',
+ 'ru' => 'ru_UTF-8',
+ 'si' => 'si',
+ 'sk' => 'sk',
+ 'sv' => 'sv',
+ 'th' => 'th',
+ 'tr' => 'tr',
+ 'vi' => 'vi',
+ 'zh' => 'zh_cn_utf8',
+ 'zh_CN' => 'zh_cn_utf8',
+ 'zh_HK' => 'zh_tw_utf8',
+ 'zh_TW' => 'zh_tw_utf8'
);
/**
@@ -271,9 +271,14 @@ class THtmlArea extends TTextBox $options['elements'] = $this->getClientID();
$options['language'] = $this->getLanguageSuffix($this->getCulture());
$options['theme'] = 'advanced';
+
+ //make it basic advanced to fit into 1 line of buttons.
+ //$options['theme_advanced_buttons1'] = 'bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright, justifyfull,separator,bullist,numlist,separator,undo,redo,separator,link,unlink,separator,charmap,separator,code,help';
+ //$options['theme_advanced_buttons2'] = ' ';
$options['theme_advanced_buttons1'] = 'formatselect,fontselect,fontsizeselect,separator,bold,italic,underline,strikethrough,sub,sup';
$options['theme_advanced_buttons2'] = 'justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,outdent,indent,separator,forecolor,backcolor,separator,hr,link,unlink,image,charmap,separator,removeformat,code,help';
$options['theme_advanced_buttons3'] = ' ';
+
$options['theme_advanced_toolbar_location'] = 'top';
$options['theme_advanced_toolbar_align'] = 'left';
$options['theme_advanced_path_location'] = 'bottom';
@@ -312,22 +317,10 @@ class THtmlArea extends TTextBox if(!is_null($app))
$variants = $app->getCultureVariants($culture);
- //default the variant to "en"
- if(count($variants) == 0)
- {
- if(empty($culture))
- return 'en';
- $variants[] = strtolower($culture);
- }
-
- // TODO: triple loops???
- foreach(self::$_langs as $js => $langs)
+ foreach($variants as $variant)
{
- foreach($variants as $variant)
- {
- if(in_array($variant, $langs))
- return $js;
- }
+ if(isset(self::$_langs[$variant]))
+ return self::$_langs[$variant];
}
return 'en';
diff --git a/framework/Web/UI/WebControls/TValidationSummary.php b/framework/Web/UI/WebControls/TValidationSummary.php index 2bc3f62c..aa46142b 100644 --- a/framework/Web/UI/WebControls/TValidationSummary.php +++ b/framework/Web/UI/WebControls/TValidationSummary.php @@ -37,6 +37,11 @@ class TValidationSummary extends TWebControl
{
/**
+ * @var TValidatorClientScript validator client-script options.
+ */
+ private $_clientScript;
+
+ /**
* Constructor.
* This method sets the foreground color to red.
*/
@@ -242,10 +247,33 @@ 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());
+
return $options;
}
/**
+ * @return TValidationSummaryClientScript client-side validation summary
+ * event options.
+ */
+ public function getClientValidation()
+ {
+ if(is_null($this->_clientScript))
+ $this->_clientScript = $this->createClientScript();
+ return $this->_clientScript;
+ }
+
+ /**
+ * @return TValidationSummaryClientScript javascript validation summary
+ * event options.
+ */
+ protected function createClientScript()
+ {
+ return new TValidationSummaryClientScript;
+ }
+ /**
* Get the list of validation error messages.
* @return array list of validator error messages.
*/
@@ -343,4 +371,105 @@ 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:: getClientValidation ClientValidation}
+ * 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
+{
+ /**
+ * @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'];
+ }
+
+ /**
+ * Client-side OnHideSummary validation summary event is raise when all the
+ * validators are valid. This will override the default client-side
+ * validation summary behaviour.
+ * @param string javascript code for client-side OnHideSummary event.
+ */
+ public function setOnHideSummary($javascript)
+ {
+ $this->_options->add('OnHideSummary', $this->ensureFunction($javascript));
+ }
+
+ /**
+ * Client-side OnShowSummary event is raise when one or more validators are
+ * not valid. This will override the default client-side validation summary
+ * behaviour.
+ * @param string javascript code for client-side OnShowSummary event.
+ */
+ public function setOnShowSummary($javascript)
+ {
+ $this->_options->add('OnShowSummary', $this->ensureFunction($javascript));
+ }
+
+ /**
+ * @return string javascript code for client-side OnShowSummary event.
+ */
+ public function getOnShowSummary()
+ {
+ return $this->_options->itemAt('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 diff --git a/tests/FunctionalTests/features/protected/application.xml b/tests/FunctionalTests/features/protected/application.xml index 642152cc..9153f3f7 100644 --- a/tests/FunctionalTests/features/protected/application.xml +++ b/tests/FunctionalTests/features/protected/application.xml @@ -1,6 +1,9 @@ <?xml version="1.0" encoding="utf-8"?>
<application id="FeatureTests" Mode="Debug">
+ <paths>
+ <using namespace="Application.controls.*" />
+ </paths>
<services>
<service id="page" class="TPageService" DefaultPage="FeatureList">
<pages MasterClass="Application.controls.Layout" />
diff --git a/tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl b/tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl new file mode 100644 index 00000000..276d03b2 --- /dev/null +++ b/tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl @@ -0,0 +1,2 @@ +<com:TLabel ID="label" ForControl="textbox" Text="label:" />
+<com:TTextBox ID="textbox" />
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php b/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php new file mode 100644 index 00000000..9a50d095 --- /dev/null +++ b/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php @@ -0,0 +1,25 @@ +<?php
+/*
+ * Created on 28/04/2006
+ */
+
+class LabeledTextBox extends TTemplateControl
+{
+ public function __construct()
+ {
+ parent::__construct();
+ $this->ensureChildControls();
+ }
+
+ public function getTextBox()
+ {
+ return $this->getRegisteredObject('textbox');
+ }
+
+ public function getLabel()
+ {
+ return $this->getRegisteredObject('label');
+ }
+}
+
+?>
diff --git a/tests/FunctionalTests/features/protected/pages/CompositeControl.page b/tests/FunctionalTests/features/protected/pages/CompositeControl.page new file mode 100644 index 00000000..b135445a --- /dev/null +++ b/tests/FunctionalTests/features/protected/pages/CompositeControl.page @@ -0,0 +1,12 @@ +<com:TContent ID="Content">
+<h1>Composite Control Test</h1>
+ <com:LabeledTextBox id="user" Label.Text="username:" /><br />
+ <com:LabeledTextBox id="pass" Label.Text="password:" /><br />
+ <com:TButton Text="Submit" />
+
+<com:TPanel Visible=<%= $this->user->TextBox->Text != "" %> >
+<h2>Result</h2>
+ User: <%= $this->user->TextBox->Text %> Pass: <%= $this->pass->TextBox->Text %>
+</com:TPanel>
+
+</com:TContent>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/HtmlArea.page b/tests/FunctionalTests/features/protected/pages/HtmlArea.page index 8b56f48d..3936e68c 100644 --- a/tests/FunctionalTests/features/protected/pages/HtmlArea.page +++ b/tests/FunctionalTests/features/protected/pages/HtmlArea.page @@ -1,10 +1,25 @@ -<%@ Application.Globalization.Charset="GB2312" %>
+
<com:TContent ID="Content">
- <com:THtmlArea>
- <prop:Options>
- plugins : "contextmenu,paste",
- language: "zh_CN"
- </prop:Options>
- </com:THtmlArea>
+ <com:THtmlArea ID="text1" />
+
+ <com:TRequiredFieldValidator
+ ControlToValidate="text1"
+ ErrorMessage="*" />
+
+ <com:TButton ID="button1" Text="submit 1" />
+
+ <com:TButton ID="button2" Text="submit 2" />
+
+ <com:THtmlArea ID="text2" />
+
+ <com:TRequiredFieldValidator
+ ControlToValidate="text2"
+ ValidationGroup="group2"
+ ErrorMessage="*" />
+
+ <com:TButton ID="button3" ValidationGroup="group2" Text="submit 3" />
+
+ <com:TButton ID="button4" ValidationGroup="group2" Text="submit 4" />
+
</com:TContent>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/ValidatorEffects.page b/tests/FunctionalTests/features/protected/pages/ValidatorEffects.page index 47d99969..da03f9b8 100644 --- a/tests/FunctionalTests/features/protected/pages/ValidatorEffects.page +++ b/tests/FunctionalTests/features/protected/pages/ValidatorEffects.page @@ -4,7 +4,7 @@ <fieldset id="quickRegistration">
<legend>Create New Account</legend>
-<com:TClientScript UsingPradoScripts="effects" />
+<com:TClientScript UsingPradoScripts="effects,logger" />
<div class="username">
Username:
@@ -81,8 +81,14 @@ <com:TValidationSummary
ID="summary2"
ValidationGroup="signin"
- AutoUpdate="false"
- HeaderText="<p>You could not login because</p>" />
+ Display="Dynamic"
+ ClientValidation.OnHideSummary="Effect.Squish(summary.messages)"
+ HeaderText="<p>You could not login because</p>">
+ <prop:ClientValidation.OnShowSummary>
+ Effect.Appear(summary.messages)
+ Effect.Shake(summary.messages,{ queue: 'end'})
+ </prop:ClientValidation.OnShowSummary>
+ </com:TValidationSummary>
</div>
</fieldset>
diff --git a/tests/FunctionalTests/features/tests/CompositeControlTestCase.php b/tests/FunctionalTests/features/tests/CompositeControlTestCase.php new file mode 100644 index 00000000..dda3f63b --- /dev/null +++ b/tests/FunctionalTests/features/tests/CompositeControlTestCase.php @@ -0,0 +1,23 @@ +<?php
+/*
+ * Created on 28/04/2006
+ */
+
+class CompositeControlTestCase extends SeleniumTestCase
+{
+
+ function test()
+ {
+ $base = "ctl0_Content_";
+ $this->open("features/index.php?page=CompositeControl", "");
+ $this->verifyTextPresent("Composite Control Test", "");
+ $this->type("{$base}user_textbox", "Hello");
+ $this->type("{$base}pass_textbox", "world");
+ $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
+ $this->verifyTextPresent("Result", "");
+ $this->verifyTextPresent("User: Hello Pass: world", "");
+ }
+
+}
+
+?>
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket68.page b/tests/FunctionalTests/tickets/protected/pages/Ticket68.page new file mode 100644 index 00000000..3936e68c --- /dev/null +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket68.page @@ -0,0 +1,25 @@ +
+<com:TContent ID="Content">
+
+ <com:THtmlArea ID="text1" />
+
+ <com:TRequiredFieldValidator
+ ControlToValidate="text1"
+ ErrorMessage="*" />
+
+ <com:TButton ID="button1" Text="submit 1" />
+
+ <com:TButton ID="button2" Text="submit 2" />
+
+ <com:THtmlArea ID="text2" />
+
+ <com:TRequiredFieldValidator
+ ControlToValidate="text2"
+ ValidationGroup="group2"
+ ErrorMessage="*" />
+
+ <com:TButton ID="button3" ValidationGroup="group2" Text="submit 3" />
+
+ <com:TButton ID="button4" ValidationGroup="group2" Text="submit 4" />
+
+</com:TContent>
\ No newline at end of file |