From 3c03a42d1edb0ec26110ace00f42e156cabff67b Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 9 Dec 2006 09:17:22 +0000 Subject: Fixed #433, #384, #439, #477, #435, #422, #401, #359. Add more class docs for sqlmap. --- .../Web/UI/ActiveControls/TActiveLinkButton.php | 2 +- .../Web/UI/ActiveControls/TActivePageAdapter.php | 21 +++++++++- framework/Web/UI/ActiveControls/TAutoComplete.php | 32 ++++++++++----- .../UI/ActiveControls/TCallbackResponseAdapter.php | 21 ++++++++++ .../UI/ActiveControls/TTimeTriggeredCallback.php | 47 +--------------------- .../UI/ActiveControls/TValueTriggeredCallback.php | 26 ++++++------ 6 files changed, 76 insertions(+), 73 deletions(-) (limited to 'framework/Web/UI/ActiveControls') diff --git a/framework/Web/UI/ActiveControls/TActiveLinkButton.php b/framework/Web/UI/ActiveControls/TActiveLinkButton.php index 019c002c..9b30fffc 100644 --- a/framework/Web/UI/ActiveControls/TActiveLinkButton.php +++ b/framework/Web/UI/ActiveControls/TActiveLinkButton.php @@ -93,7 +93,7 @@ class TActiveLinkButton extends TLinkButton implements IActiveControl, ICallback { parent::setText($value); if($this->getActiveControl()->canUpdateClientSide()) - $this->getPage()->getCallbackClient()->replaceContent($this, $value); + $this->getPage()->getCallbackClient()->update($this, $value); } /** diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index 2df19053..514b6880 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -45,6 +45,11 @@ class TActivePageAdapter extends TControlAdapter */ const CALLBACK_PAGESTATE_HEADER = 'X-PRADO-PAGESTATE'; + /** + * Callback redirect url header name. + */ + const CALLBACK_REDIRECT = 'X-PRADO-REDIRECT'; + /** * @var ICallbackEventHandler callback event handler. */ @@ -112,7 +117,21 @@ class TActivePageAdapter extends TControlAdapter public function renderCallbackResponse($writer) { Prado::trace("ActivePage renderCallbackResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter'); - $this->renderResponse($writer); + if(($url = $this->getResponse()->getAdapter()->getRedirectedUrl())===null) + $this->renderResponse($writer); + else + $this->redirect($url); + } + + /** + * Redirect url on the client-side using javascript. + * @param string new url to load. + */ + protected function redirect($url) + { + if(!$this->getApplication()->getRequestCompleted()) + $this->getApplication()->onEndRequest(); + $this->getResponse()->appendHeader(self::CALLBACK_REDIRECT.': '.$url); } /** diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php index a886e732..07fa652b 100644 --- a/framework/Web/UI/ActiveControls/TAutoComplete.php +++ b/framework/Web/UI/ActiveControls/TAutoComplete.php @@ -36,18 +36,20 @@ Prado::using('System.Web.UI.ActiveControls.TActiveTextBox'); * other properties of the repeater can be access via the {@link getSuggestions Suggestions} * property (e.g. they can be set in the .page templates). * - * To return the list of suggestions back to the browser, in your {@link onSuggestion OnSuggestion} - * event handler, do + * To return the list of suggestions back to the browser, supply a non-empty data source + * and call databind. For example, * * function autocomplete_suggestion($sender, $param) * { * $token = $param->getCallbackParameter(); //the partial word to match * $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions * $sender->dataBind(); - * $sender->render($param->getNewWriter()); //sends suggestion back to browser. * } * * + * The suggestion will be rendered when the {@link dataBind()} method is called + * during a callback request. + * * TAutoComplete allows multiple suggestions within one textbox with each * word or phrase separated by any characters specified in the * {@link setSeparator Separator} property. The {@link setFrequency Frequency} @@ -168,6 +170,17 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer $this->getSuggestions()->setDataSource($data); } + /** + * Overrides parent implementation. Callback {@link renderSuggestions()} when + * page's IsCallback property is true. + */ + public function dataBind() + { + parent::dataBind(); + if($this->getPage()->getIsCallback()) + $this->renderSuggestions($this->getResponse()->createHtmlWriter()); + } + /** * @return TPanel suggestion results panel. */ @@ -232,24 +245,21 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer } /** - * Flush and returns the suggestions content back to the browser client. + * Renders the suggestions during a callback respones. * @param THtmlWriter the renderer. */ - public function render($writer) + public function renderCallback($writer) { - if(!$this->getPage()->getIsCallback()) - parent::render($writer); - if($this->getActiveControl()->canUpdateClientSide()) - $this->renderSuggestions($writer); + $this->renderSuggestions($writer); } /** * Renders the suggestions repeater. * @param THtmlWriter the renderer. */ - protected function renderSuggestions($writer) + public function renderSuggestions($writer) { - if($this->getSuggestions()->getItems()->getCount() > 0) + if($this->getActiveControl()->canUpdateClientSide()) { $this->getSuggestions()->render($writer); $boundary = $writer->getWriter()->getBoundary(); diff --git a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php index 922e6cc6..6e3fb01e 100755 --- a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php +++ b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php @@ -37,6 +37,8 @@ class TCallbackResponseAdapter extends THttpResponseAdapter */ private $_data; + private $_redirectUrl=null; + /** * Returns a new instance of THtmlWriter. * An instance of TCallbackResponseWriter is created to hold the content. @@ -75,6 +77,25 @@ class TCallbackResponseAdapter extends THttpResponseAdapter { return $this->_data; } + + /** + * Delay the redirect until we process the rest of the page. + * @param string new url to redirect to. + */ + public function httpRedirect($url) + { + if($url[0]==='/') + $url=$this->getRequest()->getBaseUrl().$url; + $this->_redirectUrl=str_replace('&','&',$url); + } + + /** + * @return string new url for callback response to redirect to. + */ + public function getRedirectedUrl() + { + return $this->_redirectUrl; + } } /** diff --git a/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php index 10923d03..45e33f81 100644 --- a/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php +++ b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php @@ -25,11 +25,6 @@ Prado::using('System.Web.UI.ActiveControls.TCallback'); * {@link stopTimer()}. The timer can be automatically started when * {@link setStartTimerOnLoad StartTimerOnLoad} is true. * - * The intervals between each request can be increased when the browser is inactive - * by changing the {@link setDecayRate DecayRate} to a positive number. The - * default decay rate, {@link setDecayType DecayType}, is linear and can be changed to - * 'Exponential', 'Linear', 'Quadratic' or 'Cubic'. - * * @author Wei Zhuo * @version $Id$ * @package System.Web.UI.ActiveControls @@ -56,44 +51,6 @@ class TTimeTriggeredCallback extends TCallback $this->setViewState('Interval', $interval, 1); } - /** - * Gets the decay rate between callbacks. Default is 0; - * @return float decay rate between callbacks. - */ - public function getDecayRate() - { - return $this->getViewState('Decay', 0); - } - - /** - * Sets the decay rate between callback. Default is 0; - * @param float decay rate between callbacks. - */ - public function setDecayRate($value) - { - $decay = TPropertyValue::ensureFloat($value); - if($decay < 0) - throw new TConfigurationException('callback_decay_be_not_negative', $this->getID()); - $this->setViewState('Decay', $decay); - } - - /** - * @param string Decay type, allows 'Exponential', 'Linear', 'Quadratic' and 'Cubic'. Default is 'Linear'. - */ - public function setDecayType($value) - { - $this->setViewState('DecayType', TPropertyValue::ensureEnum($value, - 'Exponential', 'Linear', 'Quadratic', 'Cubic'), 'Linear'); - } - - /** - * @return string decay type, default is 'Linear', valid types are 'Exponential', 'Linear', 'Quadratic' and 'Cubic'. - */ - public function getDecayType() - { - return $this->getViewState('DecayType', 'Linear'); - } - /** * Registers the javascript code to start the timer. */ @@ -121,7 +78,7 @@ class TTimeTriggeredCallback extends TCallback */ public function setStartTimerOnLoad($value) { - $this->setViewState('StartTimerOnLoad', + $this->setViewState('StartTimerOnLoad', TPropertyValue::ensureBoolean($value), false); } @@ -141,8 +98,6 @@ class TTimeTriggeredCallback extends TCallback $options['ID'] = $this->getClientID(); $options['EventTarget']= $this->getUniqueID(); $options['Interval'] = $this->getInterval(); - $options['DecayRate'] = $this->getDecayRate(); - $options['DecayType'] = $this->getDecayType(); return $options; } diff --git a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php index 3ec830b8..e0320c6b 100644 --- a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php +++ b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php @@ -15,10 +15,8 @@ * * Observes the value with {@link setPropertyName PropertyName} of a * control with {@link setControlID ControlID}. Changes to the observed - * property value will trigger a new callback request. The values are - * observed using a {@link setPollingInterval PollingInterval} (in seconds). - * That is, the property is checked for changes every - * {@link setPollingInterval PollingInterval} seconds. + * property value will trigger a new callback request. The property value is checked + * for changes every{@link setInterval Interval} seconds. * * A {@link setDecayRate DecayRate} can be set to increase the polling * interval linearly if no changes are observed. Once a change is @@ -53,11 +51,19 @@ class TValueTriggeredCallback extends TTriggeredCallback * Default is 1 second. * @param float polling interval in seconds. */ - public function setPollingInterval($value) + public function setInterval($value) { $this->setViewState('Interval', TPropertyValue::ensureFloat($value), 1); } + /** + * @return float polling interval, 1 second default. + */ + public function getInterval() + { + return $this->getViewState('Interval', 1); + } + /** * Gets the decay rate between callbacks. Default is 0; * @return float decay rate between callbacks. @@ -79,14 +85,6 @@ class TValueTriggeredCallback extends TTriggeredCallback $this->setViewState('Decay', $decay); } - /** - * @return float polling interval, 1 second default. - */ - public function getPollingInterval() - { - return $this->getViewState('Interval', 1); - } - /** * @return array list of timer options for client-side. */ @@ -94,7 +92,7 @@ class TValueTriggeredCallback extends TTriggeredCallback { $options = parent::getTriggerOptions(); $options['PropertyName'] = $this->getPropertyName(); - $options['Interval'] = $this->getPollingInterval(); + $options['Interval'] = $this->getInterval(); $options['Decay'] = $this->getDecayRate(); return $options; } -- cgit v1.2.3