From 36f2ce766bde98c11d57b889fd9e1a7f8dff6010 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 1 Oct 2006 03:09:18 +0000 Subject: Fixed #350 and #148, Add TActiveRatingList, should remove TRatingList from WebControls. --- framework/Web/UI/WebControls/TButton.php | 18 +++++++++- framework/Web/UI/WebControls/TCheckBox.php | 24 +++++++++++-- framework/Web/UI/WebControls/TCheckBoxList.php | 43 +++++++++++++++++------ framework/Web/UI/WebControls/TImageButton.php | 31 ++++++++++++---- framework/Web/UI/WebControls/TLinkButton.php | 18 +++++++++- framework/Web/UI/WebControls/TListControl.php | 22 +++++++++++- framework/Web/UI/WebControls/TRadioButton.php | 23 +++++++++++- framework/Web/UI/WebControls/TRadioButtonList.php | 20 +++++------ framework/Web/UI/WebControls/TTextBox.php | 23 +++++++++++- 9 files changed, 188 insertions(+), 34 deletions(-) (limited to 'framework/Web/UI/WebControls') diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index 59df8f7c..0b118495 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -57,6 +57,22 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr return 'input'; } + /** + * @return boolean whether to render javascript. + */ + public function getEnableClientScript() + { + return $this->getViewState('EnableClientScript',true); + } + + /** + * @param boolean whether to render javascript. + */ + public function setEnableClientScript($value) + { + $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); + } + /** * Adds attribute name-value pairs to renderer. * This overrides the parent implementation with additional button specific attributes. @@ -72,7 +88,7 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr $writer->addAttribute('value',$this->getText()); if($this->getEnabled(true)) { - if($this->needPostBackScript()) + if($this->needPostBackScript() && $this->getEnableClientScript()) $this->renderClientControlScript($writer); } else if($this->getEnabled()) // in this case, parent will not render 'disabled' diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index 2b9fd6b7..fefc9331 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -336,6 +336,22 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl } } + /** + * @return boolean whether to render javascript. + */ + public function getEnableClientScript() + { + return $this->getViewState('EnableClientScript',true); + } + + /** + * @param boolean whether to render javascript. + */ + public function setEnableClientScript($value) + { + $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); + } + /** * Renders a label beside the checkbox. * @param THtmlWriter the writer for the rendering purpose @@ -375,8 +391,13 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $writer->addAttribute('disabled','disabled'); $page=$this->getPage(); - if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript()) + if($this->getEnabled(true) + && $this->getEnableClientScript() + && $this->getAutoPostBack() + && $page->getClientSupportsJavaScript()) + { $this->renderClientControlScript($writer); + } if(($accesskey=$this->getAccessKey())!=='') $writer->addAttribute('accesskey',$accesskey); @@ -419,7 +440,6 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $options['EventTarget'] = $this->getUniqueID(); return $options; } - } /** diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index 89357b55..09b771eb 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -105,16 +105,6 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont return new TTableStyle; } - /** - * 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 TTextAlign the alignment of the text caption, defaults to TTextAlign::Right. */ @@ -296,6 +286,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont $repeatedControl->setChecked($item->getSelected()); $repeatedControl->setAttribute('value',$item->getValue()); $repeatedControl->setEnabled($this->_isEnabled && $item->getEnabled()); + $repeatedControl->setEnableClientScript(false); $repeatedControl->renderControl($writer); } @@ -389,6 +380,14 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont $this->setAccessKey($accessKey); $this->setTabIndex($tabIndex); } + //checkbox skipped the client control script in addAttributesToRender + if($this->getEnabled(true) + && $this->getEnableClientScript() + && $this->getAutoPostBack() + && $this->getPage()->getClientSupportsJavaScript()) + { + $this->renderClientControlScript($writer); + } } /** @@ -400,6 +399,30 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont { return $this->getSelectedValue(); } + + /** + * 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'; + } + + /** + * Gets the post back options for this checkbox. + * @return array + */ + protected function getPostBackOptions() + { + $options['ListID'] = $this->getClientID(); + $options['ValidationGroup'] = $this->getValidationGroup(); + $options['CausesValidation'] = $this->getCausesValidation(); + $options['ListName'] = $this->getUniqueID(); + $options['ItemCount'] = $this->getItemCount(); + return $options; + } } ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php index ad5d7bf0..3e96abdc 100644 --- a/framework/Web/UI/WebControls/TImageButton.php +++ b/framework/Web/UI/WebControls/TImageButton.php @@ -75,6 +75,22 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven return 'input'; } + /** + * @return boolean whether to render javascript. + */ + public function getEnableClientScript() + { + return $this->getViewState('EnableClientScript',true); + } + + /** + * @param boolean whether to render javascript. + */ + public function setEnableClientScript($value) + { + $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); + } + /** * Adds attribute name-value pairs to renderer. * This overrides the parent implementation with additional button specific attributes. @@ -87,8 +103,12 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven $writer->addAttribute('type','image'); if(($uniqueID=$this->getUniqueID())!=='') $writer->addAttribute('name',$uniqueID); - if($this->getEnabled(true)) + if($this->getEnabled(true) + && $this-canCauseValidation() + && $this->getEnableClientScript()) + { $this->renderClientControlScript($writer); + } else if($this->getEnabled()) // in this case, parent will not render 'disabled' $writer->addAttribute('disabled','disabled'); parent::addAttributesToRender($writer); @@ -99,12 +119,9 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven */ protected function renderClientControlScript($writer) { - if($this->canCauseValidation()) - { - $writer->addAttribute('id',$this->getClientID()); - $cs = $this->getPage()->getClientScript(); - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); - } + $writer->addAttribute('id',$this->getClientID()); + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); } /** diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index d7586bde..ffa83d02 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -64,6 +64,22 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC return 'a'; } + /** + * @return boolean whether to render javascript. + */ + public function getEnableClientScript() + { + return $this->getViewState('EnableClientScript',true); + } + + /** + * @param boolean whether to render javascript. + */ + public function setEnableClientScript($value) + { + $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); + } + /** * Adds attribute name-value pairs to renderer. * This overrides the parent implementation with additional button specific attributes. @@ -80,7 +96,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC // may be overwritten in the following parent::addAttributesToRender($writer); - if($this->getEnabled(true)) + if($this->getEnabled(true) && $this->getEnableClientScript()) { $this->renderLinkButtonHref($writer); $this->renderClientControlScript($writer); diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index 7576154e..056a8548 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -105,6 +105,22 @@ abstract class TListControl extends TDataBoundControl return 'select'; } + /** + * @return boolean whether to render javascript. + */ + public function getEnableClientScript() + { + return $this->getViewState('EnableClientScript',true); + } + + /** + * @param boolean whether to render javascript. + */ + public function setEnableClientScript($value) + { + $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); + } + /** * Adds attributes to renderer. * @param THtmlWriter the renderer @@ -117,8 +133,12 @@ abstract class TListControl extends TDataBoundControl $writer->addAttribute('multiple','multiple'); if($this->getEnabled(true)) { - if($this->getAutoPostBack() && $page->getClientSupportsJavaScript()) + if($this->getAutoPostBack() + && $this->getEnableClientScript() + && $page->getClientSupportsJavaScript()) + { $this->renderClientControlScript($writer); + } } else if($this->getEnabled()) $writer->addAttribute('disabled','disabled'); diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index dac194b7..9b6bf794 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -233,6 +233,22 @@ class TRadioButton extends TCheckBox return $value; } + /** + * @return boolean whether to render javascript. + */ + public function getEnableClientScript() + { + return $this->getViewState('EnableClientScript',true); + } + + /** + * @param boolean whether to render javascript. + */ + public function setEnableClientScript($value) + { + $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); + } + /** * Renders a radiobutton input element. * @param THtmlWriter the writer for the rendering purpose @@ -254,8 +270,13 @@ class TRadioButton extends TCheckBox $writer->addAttribute('disabled','disabled'); $page=$this->getPage(); - if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript()) + if($this->getEnabled(true) + && $this->getEnableClientScript() + && $this->getAutoPostBack() + && $page->getClientSupportsJavaScript()) + { $this->renderClientControlScript($writer); + } if(($accesskey=$this->getAccessKey())!=='') $writer->addAttribute('accesskey',$accesskey); diff --git a/framework/Web/UI/WebControls/TRadioButtonList.php b/framework/Web/UI/WebControls/TRadioButtonList.php index b314b963..97328c73 100644 --- a/framework/Web/UI/WebControls/TRadioButtonList.php +++ b/framework/Web/UI/WebControls/TRadioButtonList.php @@ -52,16 +52,6 @@ class TRadioButtonList extends TCheckBoxList return new TRadioButton; } - /** - * 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. @@ -97,6 +87,16 @@ class TRadioButtonList extends TCheckBoxList { throw new TNotSupportedException('radiobuttonlist_selectedindices_unsupported'); } + + /** + * 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'; + } } ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index ad6de40c..588830f0 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -75,6 +75,22 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable return ($this->getTextMode()==='MultiLine')?'textarea':'input'; } + /** + * @return boolean whether to render javascript. + */ + public function getEnableClientScript() + { + return $this->getViewState('EnableClientScript',true); + } + + /** + * @param boolean whether to render javascript. + */ + public function setEnableClientScript($value) + { + $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); + } + /** * Adds attribute name-value pairs to renderer. * This method overrides the parent implementation with additional textbox specific attributes. @@ -138,8 +154,13 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable $isEnabled=$this->getEnabled(true); if(!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled' $writer->addAttribute('disabled','disabled'); - if($isEnabled && $this->getAutoPostBack() && $page->getClientSupportsJavaScript()) + if($isEnabled + && $this->getEnableClientScript() + && $this->getAutoPostBack() + && $page->getClientSupportsJavaScript()) + { $this->renderClientControlScript($writer); + } parent::addAttributesToRender($writer); } -- cgit v1.2.3