summaryrefslogtreecommitdiff
path: root/framework/Web/UI/ActiveControls
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/ActiveControls')
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCheckBox.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveControlAdapter.php20
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCustomValidator.php4
-rwxr-xr-xframework/Web/UI/ActiveControls/TActiveDatePicker.php27
-rw-r--r--framework/Web/UI/ActiveControls/TActiveDropDownList.php5
-rwxr-xr-xframework/Web/UI/ActiveControls/TActiveFileUpload.php29
-rw-r--r--framework/Web/UI/ActiveControls/TActiveListBox.php5
-rw-r--r--framework/Web/UI/ActiveControls/TActivePageAdapter.php738
-rw-r--r--framework/Web/UI/ActiveControls/TActivePanel.php31
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRadioButton.php7
-rw-r--r--framework/Web/UI/ActiveControls/TAutoComplete.php4
-rw-r--r--framework/Web/UI/ActiveControls/TBaseActiveControl.php10
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientScript.php150
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientSide.php20
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackOptions.php4
-rwxr-xr-xframework/Web/UI/ActiveControls/TDropContainer.php10
-rw-r--r--framework/Web/UI/ActiveControls/TInPlaceTextBox.php44
17 files changed, 583 insertions, 533 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBox.php b/framework/Web/UI/ActiveControls/TActiveCheckBox.php
index 55244372..3e078876 100644
--- a/framework/Web/UI/ActiveControls/TActiveCheckBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveCheckBox.php
@@ -121,6 +121,9 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
/**
* Ensure that the ID attribute is rendered and registers the javascript code
* for initializing the active control.
+ *
+ * Since 3.1.4, the javascript code is not rendered if {@link setAutoPostBack AutoPostBack} is false
+ *
* @param THtmlWriter the writer for the rendering purpose
* @param string checkbox id
* @param string onclick js
@@ -128,8 +131,9 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
protected function renderInputTag($writer,$clientID,$onclick)
{
parent::renderInputTag($writer,$clientID,$onclick);
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
+ if ($this->getAutoPostBack())
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
index 34872f98..8c6ba430 100644
--- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
@@ -64,7 +64,7 @@ class TActiveControlAdapter extends TControlAdapter
*/
protected function setBaseControlClass($type)
{
- if(is_null($type))
+ if($type===null)
{
if($this->getControl() instanceof ICallbackEventHandler)
$this->_activeControlType = 'TBaseActiveCallbackControl';
@@ -117,7 +117,7 @@ class TActiveControlAdapter extends TControlAdapter
*/
public function getBaseActiveControl()
{
- if(is_null($this->_baseActiveControl))
+ if($this->_baseActiveControl===null)
{
$type = $this->_activeControlType;
$this->_baseActiveControl = new $type($this->getControl());
@@ -161,7 +161,7 @@ class TActiveControlAdapter extends TControlAdapter
*/
public function saveState()
{
- if(!is_null($this->_stateTracker)
+ if(($this->_stateTracker!==null)
&& $this->getControl()->getActiveControl()->canUpdateClientSide())
{
$this->_stateTracker->respondToChanges();
@@ -353,7 +353,7 @@ class TCallbackPageStateTracker
*/
protected function updateStyle($style)
{
- if(!is_null($style['CssClass']))
+ if($style['CssClass']!==null)
$this->client()->setAttribute($this->_control, 'class', $style['CssClass']);
if(count($style['Style']) > 0)
$this->client()->setStyle($this->_control, $style['Style']);
@@ -487,9 +487,9 @@ class TStyleDiff extends TViewStateDiff
*/
protected function getCssClassDiff()
{
- if(is_null($this->_old))
+ if($this->_old===null)
{
- return !is_null($this->_new) && $this->_new->hasCssClass()
+ return ($this->_new!==null) && $this->_new->hasCssClass()
? $this->_new->getCssClass() : null;
}
else
@@ -515,13 +515,13 @@ class TStyleDiff extends TViewStateDiff
*/
public function getDifference()
{
- if(is_null($this->_new))
+ if($this->_new===null)
return $this->_null;
else
{
$css = $this->getCssClassDiff();
$style = $this->getStyleDiff();
- if(!is_null($css) || !is_null($style))
+ if(($css!==null) || ($style!==null))
return array('CssClass' => $css, 'Style' => $style);
else
$this->_null;
@@ -546,9 +546,9 @@ class TMapCollectionDiff extends TViewStateDiff
*/
public function getDifference()
{
- if(is_null($this->_old))
+ if($this->_old===null)
{
- return !is_null($this->_new) ? $this->_new->toArray() : $this->_null;
+ return ($this->_new!==null) ? $this->_new->toArray() : $this->_null;
}
else
{
diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
index 6c74aa7d..1f719bf6 100644
--- a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
+++ b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
@@ -4,7 +4,7 @@
*
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -236,6 +236,6 @@ class TActiveCustomValidatorClientSide extends TCallbackClientSide
public function getObserveChanges()
{
$changes = $this->getOption('ObserveChanges');
- return is_null($changes) ? true : $changes;
+ return ($changes===null) ? true : $changes;
}
}
diff --git a/framework/Web/UI/ActiveControls/TActiveDatePicker.php b/framework/Web/UI/ActiveControls/TActiveDatePicker.php
index 052ed199..fafd21e5 100755
--- a/framework/Web/UI/ActiveControls/TActiveDatePicker.php
+++ b/framework/Web/UI/ActiveControls/TActiveDatePicker.php
@@ -39,6 +39,7 @@ class TActiveDatePicker extends TDatePicker implements ICallbackEventHandler, I
protected function getDatePickerOptions(){
$options = parent::getDatePickerOptions();
$options['EventTarget'] = $this->getUniqueID();
+ $options['ShowCalendar'] = $this->getShowCalendar();
return $options;
}
@@ -108,22 +109,20 @@ class TActiveDatePicker extends TDatePicker implements ICallbackEventHandler, I
*/
protected function registerCalendarClientScript()
{
- if($this->getShowCalendar())
- {
- $cs = $this->getPage()->getClientScript();
- $cs->registerPradoScript("activedatepicker");
-
- if(!$cs->isEndScriptRegistered('TDatePicker.spacer'))
- {
- $spacer = $this->getAssetUrl('spacer.gif');
- $code = "Prado.WebUI.TDatePicker.spacer = '$spacer';";
- $cs->registerEndScript('TDatePicker.spacer', $code);
- }
+
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPradoScript("activedatepicker");
- $options = TJavaScript::encode($this->getDatePickerOptions());
- $code = "new Prado.WebUI.TActiveDatePicker($options);";
- $cs->registerEndScript("prado:".$this->getClientID(), $code);
+ if(!$cs->isEndScriptRegistered('TDatePicker.spacer'))
+ {
+ $spacer = $this->getAssetUrl('spacer.gif');
+ $code = "Prado.WebUI.TDatePicker.spacer = '$spacer';";
+ $cs->registerEndScript('TDatePicker.spacer', $code);
}
+
+ $options = TJavaScript::encode($this->getDatePickerOptions());
+ $code = "new Prado.WebUI.TActiveDatePicker($options);";
+ $cs->registerEndScript("prado:".$this->getClientID(), $code);
}
}
?>
diff --git a/framework/Web/UI/ActiveControls/TActiveDropDownList.php b/framework/Web/UI/ActiveControls/TActiveDropDownList.php
index e66b4cbd..c9458494 100644
--- a/framework/Web/UI/ActiveControls/TActiveDropDownList.php
+++ b/framework/Web/UI/ActiveControls/TActiveDropDownList.php
@@ -105,8 +105,9 @@ class TActiveDropDownList extends TDropDownList implements ICallbackEventHandler
{
parent::addAttributesToRender($writer);
$writer->addAttribute('id',$this->getClientID());
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
+ if ($this->getAutoPostBack())
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveFileUpload.php b/framework/Web/UI/ActiveControls/TActiveFileUpload.php
index e1b85f0d..b935936b 100755
--- a/framework/Web/UI/ActiveControls/TActiveFileUpload.php
+++ b/framework/Web/UI/ActiveControls/TActiveFileUpload.php
@@ -133,7 +133,30 @@ EOS;
* default "Application.runtime.*"
*/
public function setTempPath($value){
- $this->setViewState('TempNamespace',$value,'Application.runtime.*');
+ $this->setViewState('TempPath',$value,'Application.runtime.*');
+ }
+
+ /**
+ * @return boolean a value indicating whether an automatic callback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component. Defaults to true.
+ * Note: When set to false, you will need to trigger the callback yourself.
+ */
+ public function getAutoPostBack(){
+ return $this->getViewState('AutoPostBack', true);
+ }
+
+ /**
+ * @param boolean a value indicating whether an automatic callback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component. Defaults to true.
+ * Note: When set to false, you will need to trigger the callback yourself.
+ */
+ public function setAutoPostBack($value){
+ $this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
+ * @return string A chuck of javascript that will need to be called if {{@link getAutoPostBack AutoPostBack} is set to false}
+ */
+ public function getCallbackJavascript(){
+ return "Prado.WebUI.TActiveFileUpload.fileChanged(\"{$this->getClientID()}\")";
}
/**
@@ -172,6 +195,7 @@ EOS;
*/
public function onPreRender($param){
parent::onPreRender($param);
+ $this->getPage()->getClientScript()->registerPradoScript('effects');
$this->getPage()->getClientScript()->registerPradoScript('activefileupload');
}
@@ -266,6 +290,7 @@ EOS;
$options['indicatorID'] = $this->_busy->getClientID();
$options['completeID'] = $this->_success->getClientID();
$options['errorID'] = $this->_error->getClientID();
+ $options['autoPostBack'] = $this->getAutoPostBack();
return $options;
}
@@ -312,4 +337,4 @@ EOS;
$this->ensureChildControls();
return $this->_busy;
}
-} \ No newline at end of file
+}
diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php
index 3deb9a0f..29857ee5 100644
--- a/framework/Web/UI/ActiveControls/TActiveListBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveListBox.php
@@ -149,8 +149,9 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH
{
parent::addAttributesToRender($writer);
$writer->addAttribute('id',$this->getClientID());
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
+ if ($this->getAutoPostBack())
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
}
}
diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
index c52f0775..90eed970 100644
--- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
@@ -1,369 +1,369 @@
-<?php
-/**
- * TActivePageAdapter, TCallbackErrorHandler and TInvalidCallbackException class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * Load callback response adapter class.
- */
-Prado::using('System.Web.UI.ActiveControls.TCallbackResponseAdapter');
-Prado::using('System.Web.UI.ActiveControls.TCallbackClientScript');
-Prado::using('System.Web.UI.ActiveControls.TCallbackEventParameter');
-
-/**
- * TActivePageAdapter class.
- *
- * Callback request handler.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TActivePageAdapter extends TControlAdapter
-{
- /**
- * Callback response data header name.
- */
- const CALLBACK_DATA_HEADER = 'X-PRADO-DATA';
- /**
- * Callback response client-side action header name.
- */
- const CALLBACK_ACTION_HEADER = 'X-PRADO-ACTIONS';
- /**
- * Callback error header name.
- */
- const CALLBACK_ERROR_HEADER = 'X-PRADO-ERROR';
- /**
- * Callback page state header name.
- */
- const CALLBACK_PAGESTATE_HEADER = 'X-PRADO-PAGESTATE';
-
- /**
- * Callback redirect url header name.
- */
- const CALLBACK_REDIRECT = 'X-PRADO-REDIRECT';
-
- /**
- * @var ICallbackEventHandler callback event handler.
- */
- private $_callbackEventTarget;
- /**
- * @var mixed callback event parameter.
- */
- private $_callbackEventParameter;
- /**
- * @var TCallbackClientScript callback client script handler
- */
- private $_callbackClient;
-
- private $_controlsToRender=array();
-
- /**
- * Constructor, trap errors and exception to let the callback response
- * handle them.
- */
- public function __construct(TPage $control)
- {
- parent::__construct($control);
-
- //TODO: can this be done later?
- $response = $this->getApplication()->getResponse();
- $response->setAdapter(new TCallbackResponseAdapter($response));
-
- $this->trapCallbackErrorsExceptions();
- }
-
- /**
- * Process the callback request.
- * @param THtmlWriter html content writer.
- */
- public function processCallbackEvent($writer)
- {
- Prado::trace("ActivePage raiseCallbackEvent()",'System.Web.UI.ActiveControls.TActivePageAdapter');
- $this->raiseCallbackEvent();
- }
-
- /**
- * Register a control for defered render() call.
- * @param TControl control for defered rendering
- * @param THtmlWriter the renderer
- */
- public function registerControlToRender($control,$writer)
- {
- $id = $control->getUniqueID();
- if(!isset($this->_controlsToRender[$id]))
- $this->_controlsToRender[$id] = array($control,$writer);
- }
-
- /**
- * Trap errors and exceptions to be handled by TCallbackErrorHandler.
- */
- protected function trapCallbackErrorsExceptions()
- {
- $this->getApplication()->setErrorHandler(new TCallbackErrorHandler);
- }
-
- /**
- * Render the callback response.
- * @param THtmlWriter html content writer.
- */
- public function renderCallbackResponse($writer)
- {
- Prado::trace("ActivePage renderCallbackResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter');
- 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)
- {
- Prado::trace("ActivePage redirect()",'System.Web.UI.ActiveControls.TActivePageAdapter');
- $this->appendContentPart($this->getResponse(), self::CALLBACK_REDIRECT, $url);
- //$this->getResponse()->appendHeader(self::CALLBACK_REDIRECT.': '.$url);
- }
-
- /**
- * Renders the callback response by adding additional callback data and
- * javascript actions in the header and page state if required.
- * @param THtmlWriter html content writer.
- */
- protected function renderResponse($writer)
- {
- Prado::trace("ActivePage renderResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter');
- //renders all the defered render() calls.
- foreach($this->_controlsToRender as $rid => $forRender)
- $forRender[0]->render($forRender[1]);
-
- $response = $this->getResponse();
-
- //send response data in header
- if($response->getHasAdapter())
- {
- $responseData = $response->getAdapter()->getResponseData();
- if(!is_null($responseData))
- {
- $data = TJavaScript::jsonEncode($responseData);
-
- $this->appendContentPart($response, self::CALLBACK_DATA_HEADER, $data);
- //$response->appendHeader(self::CALLBACK_DATA_HEADER.': '.$data);
- }
- }
-
- //sends page state in header
- if(($handler = $this->getCallbackEventTarget()) !== null)
- {
- if($handler->getActiveControl()->getClientSide()->getEnablePageStateUpdate())
- {
- $pagestate = $this->getPage()->getClientState();
- $this->appendContentPart($response, self::CALLBACK_PAGESTATE_HEADER, $pagestate);
- //$response->appendHeader(self::CALLBACK_PAGESTATE_HEADER.': '.$pagestate);
- }
- }
-
- //safari must receive at least 1 byte of data.
- $writer->write(" ");
-
- //output the end javascript
- if($this->getPage()->getClientScript()->hasEndScripts())
- {
- $writer = $response->createHtmlWriter();
- $this->getPage()->getClientScript()->renderEndScripts($writer);
- $this->getPage()->getCallbackClient()->evaluateScript($writer);
- }
-
- //output the actions
- $executeJavascript = $this->getCallbackClientHandler()->getClientFunctionsToExecute();
- $actions = TJavaScript::jsonEncode($executeJavascript);
- $this->appendContentPart($response, self::CALLBACK_ACTION_HEADER, $actions);
- //$response->appendHeader(self::CALLBACK_ACTION_HEADER.': '.$actions);
- }
-
- /**
- * Appends data or javascript code to the body content surrounded with delimiters
- */
- private function appendContentPart($response, $delimiter, $data)
- {
- $content = $response->createHtmlWriter();
- $content->getWriter()->setBoundary($delimiter);
- $content->write($data);
- }
-
- /**
- * Trys to find the callback event handler and raise its callback event.
- * @throws TInvalidCallbackException if call back target is not found.
- * @throws TInvalidCallbackException if the requested target does not
- * implement ICallbackEventHandler.
- */
- private function raiseCallbackEvent()
- {
- if(($callbackHandler=$this->getCallbackEventTarget())!==null)
- {
- if($callbackHandler instanceof ICallbackEventHandler)
- {
- $param = $this->getCallbackEventParameter();
- $result = new TCallbackEventParameter($this->getResponse(), $param);
- $callbackHandler->raiseCallbackEvent($result);
- }
- else
- {
- throw new TInvalidCallbackException(
- 'callback_invalid_handler', $callbackHandler->getUniqueID());
- }
- }
- else
- {
- $target = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET);
- throw new TInvalidCallbackException('callback_invalid_target', $target);
- }
- }
-
- /**
- * @return TControl the control responsible for the current callback event,
- * null if nonexistent
- */
- public function getCallbackEventTarget()
- {
- if($this->_callbackEventTarget===null)
- {
- $eventTarget=$this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET);
- if(!empty($eventTarget))
- $this->_callbackEventTarget=$this->getPage()->findControl($eventTarget);
- }
- return $this->_callbackEventTarget;
- }
-
- /**
- * Registers a control to raise callback event in the current request.
- * @param TControl control registered to raise callback event.
- */
- public function setCallbackEventTarget(TControl $control)
- {
- $this->_callbackEventTarget=$control;
- }
-
- /**
- * Gets callback parameter. JSON encoding is assumed.
- * @return string postback event parameter
- */
- public function getCallbackEventParameter()
- {
- if($this->_callbackEventParameter===null)
- {
- $param = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER);
- if(strlen($param) > 0)
- $this->_callbackEventParameter=TJavaScript::jsonDecode((string)$param);
- }
- return $this->_callbackEventParameter;
- }
-
- /**
- * @param mixed postback event parameter
- */
- public function setCallbackEventParameter($value)
- {
- $this->_callbackEventParameter=$value;
- }
-
- /**
- * Gets the callback client script handler. It handlers the javascript functions
- * to be executed during the callback response.
- * @return TCallbackClientScript callback client handler.
- */
- public function getCallbackClientHandler()
- {
- if(is_null($this->_callbackClient))
- $this->_callbackClient = new TCallbackClientScript;
- return $this->_callbackClient;
- }
-}
-
-/**
- * TCallbackErrorHandler class.
- *
- * Captures errors and exceptions and send them back during callback response.
- * When the application is in debug mode, the error and exception stack trace
- * are shown. A TJavascriptLogger must be present on the client-side to view
- * the error stack trace.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TCallbackErrorHandler extends TErrorHandler
-{
- /**
- * Displays the exceptions to the client-side TJavascriptLogger.
- * A HTTP 500 status code is sent and the stack trace is sent as JSON encoded.
- * @param Exception exception details.
- */
- protected function displayException($exception)
- {
- if($this->getApplication()->getMode()===TApplication::STATE_DEBUG)
- {
- $response = $this->getApplication()->getResponse();
- $trace = TJavaScript::jsonEncode($this->getExceptionStackTrace($exception));
- $response->appendHeader('HTTP/1.0 500 Internal Error');
- $response->appendHeader(TActivePageAdapter::CALLBACK_ERROR_HEADER.': '.$trace);
- }
- else
- {
- error_log("Error happened while processing an existing error:\n".$exception->__toString());
- header('HTTP/1.0 500 Internal Error');
- }
- $this->getApplication()->getResponse()->flush();
- }
-
- /**
- * @param Exception exception details.
- * @return array exception stack trace details.
- */
- private function getExceptionStackTrace($exception)
- {
- $data['code']=$exception->getCode() > 0 ? $exception->getCode() : 500;
- $data['file']=$exception->getFile();
- $data['line']=$exception->getLine();
- $data['trace']=$exception->getTrace();
- if($exception instanceof TPhpErrorException)
- {
- // if PHP exception, we want to show the 2nd stack level context
- // because the 1st stack level is of little use (it's in error handler)
- if(isset($trace[0]) && isset($trace[0]['file']) && isset($trace[0]['line']))
- {
- $data['file']=$trace[0]['file'];
- $data['line']=$trace[0]['line'];
- }
- }
- $data['type']=get_class($exception);
- $data['message']=$exception->getMessage();
- $data['version']=$_SERVER['SERVER_SOFTWARE'].' '.Prado::getVersion();
- $data['time']=@strftime('%Y-%m-%d %H:%M',time());
- return $data;
- }
-}
-
-/**
- * TInvalidCallbackException class.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TInvalidCallbackException extends TException
-{
-}
-
+<?php
+/**
+ * TActivePageAdapter, TCallbackErrorHandler and TInvalidCallbackException class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load callback response adapter class.
+ */
+Prado::using('System.Web.UI.ActiveControls.TCallbackResponseAdapter');
+Prado::using('System.Web.UI.ActiveControls.TCallbackClientScript');
+Prado::using('System.Web.UI.ActiveControls.TCallbackEventParameter');
+
+/**
+ * TActivePageAdapter class.
+ *
+ * Callback request handler.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TActivePageAdapter extends TControlAdapter
+{
+ /**
+ * Callback response data header name.
+ */
+ const CALLBACK_DATA_HEADER = 'X-PRADO-DATA';
+ /**
+ * Callback response client-side action header name.
+ */
+ const CALLBACK_ACTION_HEADER = 'X-PRADO-ACTIONS';
+ /**
+ * Callback error header name.
+ */
+ const CALLBACK_ERROR_HEADER = 'X-PRADO-ERROR';
+ /**
+ * Callback page state header name.
+ */
+ const CALLBACK_PAGESTATE_HEADER = 'X-PRADO-PAGESTATE';
+
+ /**
+ * Callback redirect url header name.
+ */
+ const CALLBACK_REDIRECT = 'X-PRADO-REDIRECT';
+
+ /**
+ * @var ICallbackEventHandler callback event handler.
+ */
+ private $_callbackEventTarget;
+ /**
+ * @var mixed callback event parameter.
+ */
+ private $_callbackEventParameter;
+ /**
+ * @var TCallbackClientScript callback client script handler
+ */
+ private $_callbackClient;
+
+ private $_controlsToRender=array();
+
+ /**
+ * Constructor, trap errors and exception to let the callback response
+ * handle them.
+ */
+ public function __construct(TPage $control)
+ {
+ parent::__construct($control);
+
+ //TODO: can this be done later?
+ $response = $this->getApplication()->getResponse();
+ $response->setAdapter(new TCallbackResponseAdapter($response));
+
+ $this->trapCallbackErrorsExceptions();
+ }
+
+ /**
+ * Process the callback request.
+ * @param THtmlWriter html content writer.
+ */
+ public function processCallbackEvent($writer)
+ {
+ Prado::trace("ActivePage raiseCallbackEvent()",'System.Web.UI.ActiveControls.TActivePageAdapter');
+ $this->raiseCallbackEvent();
+ }
+
+ /**
+ * Register a control for defered render() call.
+ * @param TControl control for defered rendering
+ * @param THtmlWriter the renderer
+ */
+ public function registerControlToRender($control,$writer)
+ {
+ $id = $control->getUniqueID();
+ if(!isset($this->_controlsToRender[$id]))
+ $this->_controlsToRender[$id] = array($control,$writer);
+ }
+
+ /**
+ * Trap errors and exceptions to be handled by TCallbackErrorHandler.
+ */
+ protected function trapCallbackErrorsExceptions()
+ {
+ $this->getApplication()->setErrorHandler(new TCallbackErrorHandler);
+ }
+
+ /**
+ * Render the callback response.
+ * @param THtmlWriter html content writer.
+ */
+ public function renderCallbackResponse($writer)
+ {
+ Prado::trace("ActivePage renderCallbackResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter');
+ 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)
+ {
+ Prado::trace("ActivePage redirect()",'System.Web.UI.ActiveControls.TActivePageAdapter');
+ $this->appendContentPart($this->getResponse(), self::CALLBACK_REDIRECT, $url);
+ //$this->getResponse()->appendHeader(self::CALLBACK_REDIRECT.': '.$url);
+ }
+
+ /**
+ * Renders the callback response by adding additional callback data and
+ * javascript actions in the header and page state if required.
+ * @param THtmlWriter html content writer.
+ */
+ protected function renderResponse($writer)
+ {
+ Prado::trace("ActivePage renderResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter');
+ //renders all the defered render() calls.
+ foreach($this->_controlsToRender as $rid => $forRender)
+ $forRender[0]->render($forRender[1]);
+
+ $response = $this->getResponse();
+
+ //send response data in header
+ if($response->getHasAdapter())
+ {
+ $responseData = $response->getAdapter()->getResponseData();
+ if($responseData!==null)
+ {
+ $data = TJavaScript::jsonEncode($responseData);
+
+ $this->appendContentPart($response, self::CALLBACK_DATA_HEADER, $data);
+ //$response->appendHeader(self::CALLBACK_DATA_HEADER.': '.$data);
+ }
+ }
+
+ //sends page state in header
+ if(($handler = $this->getCallbackEventTarget()) !== null)
+ {
+ if($handler->getActiveControl()->getClientSide()->getEnablePageStateUpdate())
+ {
+ $pagestate = $this->getPage()->getClientState();
+ $this->appendContentPart($response, self::CALLBACK_PAGESTATE_HEADER, $pagestate);
+ //$response->appendHeader(self::CALLBACK_PAGESTATE_HEADER.': '.$pagestate);
+ }
+ }
+
+ //safari must receive at least 1 byte of data.
+ $writer->write(" ");
+
+ //output the end javascript
+ if($this->getPage()->getClientScript()->hasEndScripts())
+ {
+ $writer = $response->createHtmlWriter();
+ $this->getPage()->getClientScript()->renderEndScripts($writer);
+ $this->getPage()->getCallbackClient()->evaluateScript($writer);
+ }
+
+ //output the actions
+ $executeJavascript = $this->getCallbackClientHandler()->getClientFunctionsToExecute();
+ $actions = TJavaScript::jsonEncode($executeJavascript);
+ $this->appendContentPart($response, self::CALLBACK_ACTION_HEADER, $actions);
+ //$response->appendHeader(self::CALLBACK_ACTION_HEADER.': '.$actions);
+ }
+
+ /**
+ * Appends data or javascript code to the body content surrounded with delimiters
+ */
+ private function appendContentPart($response, $delimiter, $data)
+ {
+ $content = $response->createHtmlWriter();
+ $content->getWriter()->setBoundary($delimiter);
+ $content->write($data);
+ }
+
+ /**
+ * Trys to find the callback event handler and raise its callback event.
+ * @throws TInvalidCallbackException if call back target is not found.
+ * @throws TInvalidCallbackException if the requested target does not
+ * implement ICallbackEventHandler.
+ */
+ private function raiseCallbackEvent()
+ {
+ if(($callbackHandler=$this->getCallbackEventTarget())!==null)
+ {
+ if($callbackHandler instanceof ICallbackEventHandler)
+ {
+ $param = $this->getCallbackEventParameter();
+ $result = new TCallbackEventParameter($this->getResponse(), $param);
+ $callbackHandler->raiseCallbackEvent($result);
+ }
+ else
+ {
+ throw new TInvalidCallbackException(
+ 'callback_invalid_handler', $callbackHandler->getUniqueID());
+ }
+ }
+ else
+ {
+ $target = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET);
+ throw new TInvalidCallbackException('callback_invalid_target', $target);
+ }
+ }
+
+ /**
+ * @return TControl the control responsible for the current callback event,
+ * null if nonexistent
+ */
+ public function getCallbackEventTarget()
+ {
+ if($this->_callbackEventTarget===null)
+ {
+ $eventTarget=$this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET);
+ if(!empty($eventTarget))
+ $this->_callbackEventTarget=$this->getPage()->findControl($eventTarget);
+ }
+ return $this->_callbackEventTarget;
+ }
+
+ /**
+ * Registers a control to raise callback event in the current request.
+ * @param TControl control registered to raise callback event.
+ */
+ public function setCallbackEventTarget(TControl $control)
+ {
+ $this->_callbackEventTarget=$control;
+ }
+
+ /**
+ * Gets callback parameter. JSON encoding is assumed.
+ * @return string postback event parameter
+ */
+ public function getCallbackEventParameter()
+ {
+ if($this->_callbackEventParameter===null)
+ {
+ $param = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER);
+ if(strlen($param) > 0)
+ $this->_callbackEventParameter=TJavaScript::jsonDecode((string)$param);
+ }
+ return $this->_callbackEventParameter;
+ }
+
+ /**
+ * @param mixed postback event parameter
+ */
+ public function setCallbackEventParameter($value)
+ {
+ $this->_callbackEventParameter=$value;
+ }
+
+ /**
+ * Gets the callback client script handler. It handlers the javascript functions
+ * to be executed during the callback response.
+ * @return TCallbackClientScript callback client handler.
+ */
+ public function getCallbackClientHandler()
+ {
+ if($this->_callbackClient===null)
+ $this->_callbackClient = new TCallbackClientScript;
+ return $this->_callbackClient;
+ }
+}
+
+/**
+ * TCallbackErrorHandler class.
+ *
+ * Captures errors and exceptions and send them back during callback response.
+ * When the application is in debug mode, the error and exception stack trace
+ * are shown. A TJavascriptLogger must be present on the client-side to view
+ * the error stack trace.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TCallbackErrorHandler extends TErrorHandler
+{
+ /**
+ * Displays the exceptions to the client-side TJavascriptLogger.
+ * A HTTP 500 status code is sent and the stack trace is sent as JSON encoded.
+ * @param Exception exception details.
+ */
+ protected function displayException($exception)
+ {
+ if($this->getApplication()->getMode()===TApplication::STATE_DEBUG)
+ {
+ $response = $this->getApplication()->getResponse();
+ $trace = TJavaScript::jsonEncode($this->getExceptionStackTrace($exception));
+ $response->appendHeader('HTTP/1.0 500 Internal Error');
+ $response->appendHeader(TActivePageAdapter::CALLBACK_ERROR_HEADER.': '.$trace);
+ }
+ else
+ {
+ error_log("Error happened while processing an existing error:\n".$exception->__toString());
+ header('HTTP/1.0 500 Internal Error');
+ }
+ $this->getApplication()->getResponse()->flush();
+ }
+
+ /**
+ * @param Exception exception details.
+ * @return array exception stack trace details.
+ */
+ private function getExceptionStackTrace($exception)
+ {
+ $data['code']=$exception->getCode() > 0 ? $exception->getCode() : 500;
+ $data['file']=$exception->getFile();
+ $data['line']=$exception->getLine();
+ $data['trace']=$exception->getTrace();
+ if($exception instanceof TPhpErrorException)
+ {
+ // if PHP exception, we want to show the 2nd stack level context
+ // because the 1st stack level is of little use (it's in error handler)
+ if(isset($trace[0]) && isset($trace[0]['file']) && isset($trace[0]['line']))
+ {
+ $data['file']=$trace[0]['file'];
+ $data['line']=$trace[0]['line'];
+ }
+ }
+ $data['type']=get_class($exception);
+ $data['message']=$exception->getMessage();
+ $data['version']=$_SERVER['SERVER_SOFTWARE'].' '.Prado::getVersion();
+ $data['time']=@strftime('%Y-%m-%d %H:%M',time());
+ return $data;
+ }
+}
+
+/**
+ * TInvalidCallbackException class.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TInvalidCallbackException extends TException
+{
+}
+
diff --git a/framework/Web/UI/ActiveControls/TActivePanel.php b/framework/Web/UI/ActiveControls/TActivePanel.php
index 51e9fb08..25a42eb7 100644
--- a/framework/Web/UI/ActiveControls/TActivePanel.php
+++ b/framework/Web/UI/ActiveControls/TActivePanel.php
@@ -4,7 +4,7 @@
*
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -58,6 +58,15 @@ class TActivePanel extends TPanel implements IActiveControl
}
/**
+ * Adds attribute id to the renderer.
+ * @param THtmlWriter the writer used for the rendering purpose
+ */
+ protected function addAttributesToRender($writer) {
+ $writer->addAttribute('id',$this->getClientID());
+ parent::addAttributesToRender($writer);
+ }
+
+ /**
* Renders and replaces the panel's content on the client-side.
* When render() is called before the OnPreRender event, such as when render()
* is called during a callback event handler, the rendering
@@ -74,16 +83,16 @@ class TActivePanel extends TPanel implements IActiveControl
}
else
{
- $this->getPage()->getAdapter()->registerControlToRender($this,$writer);
- if ($this->getHasControls())
- {
- // If we update a TActivePanel on callback,
- // We shouldn't update all childs, because the whole content will be replaced by
- // the parent
- foreach ($this->findControlsByType('IActiveControl', false) as $control)
- {
- $control->getActiveControl()->setEnableUpdate(false);
- }
+ $this->getPage()->getAdapter()->registerControlToRender($this,$writer);
+ if ($this->getHasControls())
+ {
+ // If we update a TActivePanel on callback,
+ // We shouldn't update all childs, because the whole content will be replaced by
+ // the parent
+ foreach ($this->findControlsByType('IActiveControl', false) as $control)
+ {
+ $control->getActiveControl()->setEnableUpdate(false);
+ }
}
}
}
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButton.php b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
index f7e9a286..8e2195d3 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
@@ -120,12 +120,15 @@ class TActiveRadioButton extends TRadioButton implements IActiveControl, ICallba
/**
* Ensure that the ID attribute is rendered and registers the javascript code
* for initializing the active control.
+ * Since 3.1.4, the javascript code is not rendered if {@link setAutoPostBack AutoPostBack} is false
+ *
*/
protected function renderInputTag($writer,$clientID,$onclick)
{
parent::renderInputTag($writer,$clientID,$onclick);
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
+ if ($this->getAutoPostBack())
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
}
/**
diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php
index 5a3633ec..13200e51 100644
--- a/framework/Web/UI/ActiveControls/TAutoComplete.php
+++ b/framework/Web/UI/ActiveControls/TAutoComplete.php
@@ -235,7 +235,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
*/
public function getResultPanel()
{
- if(is_null($this->_resultPanel))
+ if($this->_resultPanel===null)
$this->_resultPanel = $this->createResultPanel();
return $this->_resultPanel;
}
@@ -256,7 +256,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
*/
public function getSuggestions()
{
- if(is_null($this->_repeater))
+ if($this->_repeater===null)
$this->_repeater = $this->createRepeater();
return $this->_repeater;
}
diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
index 8f55e27b..f301f2c3 100644
--- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php
+++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
@@ -58,8 +58,8 @@ class TBaseActiveControl extends TComponent
*/
protected function setOption($name,$value,$default=null)
{
- $value = is_null($value) ? $default : $value;
- if(!is_null($value))
+ $value = ($value===null) ? $default : $value;
+ if($value!==null)
$this->_options->add($name,$value);
}
@@ -73,7 +73,7 @@ class TBaseActiveControl extends TComponent
protected function getOption($name,$default=null)
{
$item = $this->_options->itemAt($name);
- return is_null($item) ? $default : $item;
+ return ($item===null) ? $default : $item;
}
/**
@@ -168,7 +168,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
*/
public function getClientSide()
{
- if(is_null($client = $this->getOption('ClientSide')))
+ if(($client = $this->getOption('ClientSide'))===null)
{
$client = $this->createClientSide();
$this->setOption('ClientSide', $client);
@@ -182,7 +182,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
*/
public function setClientSide($client)
{
- if(is_null($this->getOption('ClientSide')))
+ if( $this->getOption('ClientSide')===null)
$this->setOption('ClientSide', $client);
else
throw new TConfigurationException(
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
index 8f275ef8..062f63dc 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
@@ -4,7 +4,7 @@
*
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -104,7 +104,7 @@ class TCallbackClientScript extends TApplicationComponent
{
$method = TPropertyValue::ensureEnum($method,
'Value', 'Index', 'Clear', 'Indices', 'Values', 'All', 'Invert');
- $type = is_null($type) ? $this->getSelectionControlType($control) : $type;
+ $type = ($type===null) ? $this->getSelectionControlType($control) : $type;
$total = $this->getSelectionControlIsListType($control) ? $control->getItemCount() : 1;
$this->callClientFunction('Prado.Element.select',
array($control, $type.$method, $value, $total));
@@ -164,8 +164,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function setAttribute($control, $name, $value)
{
- if ($control instanceof ISurroundable)
- $control=$control->getSurroundingTagID();
+ if ($control instanceof ISurroundable)
+ $control=$control->getSurroundingTagID();
$this->callClientFunction('Prado.Element.setAttribute',array($control, $name, $value));
}
@@ -177,6 +177,18 @@ class TCallbackClientScript extends TApplicationComponent
public function setListItems($control, $items)
{
$options = array();
+ if($control instanceof TListControl)
+ {
+ $promptText = $control->getPromptText();
+ $promptValue = $control->getPromptValue();
+
+ if($promptValue==='')
+ $promptValue = $promptText;
+
+ if($promptValue!=='')
+ $options[] = array($promptText, $promptValue);
+ }
+
foreach($items as $item)
{
if($item->getHasAttributes())
@@ -193,8 +205,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function show($element)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->callClientFunction('Element.show', $element);
}
@@ -204,8 +216,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function hide($element)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->callClientFunction('Element.hide', $element);
}
@@ -217,8 +229,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function toggle($element, $effect=null, $options=array())
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->callClientFunction('Element.toggle', array($element,$effect,$options));
}
@@ -228,8 +240,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function remove($element)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->callClientFunction('Element.remove', $element);
}
@@ -246,8 +258,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function update($element, $content)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->replace($element, $content, 'Element.update');
}
@@ -258,8 +270,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function addCssClass($element, $cssClass)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->callClientFunction('Element.addClassName', array($element, $cssClass));
}
@@ -270,8 +282,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function removeCssClass($element, $cssClass)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->callClientFunction('Element.removeClassName', array($element, $cssClass));
}
@@ -292,8 +304,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function scrollTo($element)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->callClientFunction('Element.scrollTo', $element);
}
@@ -313,9 +325,9 @@ class TCallbackClientScript extends TApplicationComponent
* @param array list of key-value pairs as style property and style value.
*/
public function setStyle($element, $styles)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->callClientFunction('Prado.Element.setStyle', array($element, $styles));
}
@@ -326,8 +338,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function appendContent($element, $content)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->replace($element, $content, 'Prado.Element.Insert.append');
}
@@ -338,8 +350,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function prependContent($element, $content)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->replace($element, $content, 'Prado.Element.Insert.prepend');
}
@@ -350,8 +362,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function insertContentAfter($element, $content)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->replace($element, $content, 'Prado.Element.Insert.after');
}
@@ -362,8 +374,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function insertContentBefore($element, $content)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->replace($element, $content, 'Prado.Element.Insert.before');
}
@@ -406,8 +418,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function replaceContent($element,$content)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->replace($element, $content);
}
@@ -458,8 +470,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function visualEffect($type, $element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->callClientFunction($type, array($element, $options));
}
@@ -470,8 +482,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function appear($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.Appear', $element, $options);
}
@@ -482,8 +494,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function blindDown($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.BlindDown', $element, $options);
}
@@ -494,8 +506,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function blindUp($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.BlindUp', $element, $options);
}
@@ -507,8 +519,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function dropOut($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.DropOut', $element, $options);
}
@@ -519,8 +531,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function fade($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.Fade', $element, $options);
}
@@ -531,8 +543,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function fold($element, $options = null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.Fold', $element, $options);
}
@@ -543,8 +555,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function grow($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.Grow', $element, $options);
}
@@ -555,8 +567,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function puff($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.Puff', $element, $options);
}
@@ -567,8 +579,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function pulsate($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.Pulsate', $element, $options);
}
@@ -579,8 +591,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function shake($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.Shake', $element, $options);
}
@@ -591,8 +603,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function shrink($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.Shrink', $element, $options);
}
@@ -603,8 +615,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function slideDown($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.SlideDown', $element, $options);
}
@@ -615,8 +627,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function slideUp($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.SlideUp', $element, $options);
}
@@ -627,8 +639,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function squish($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.Squish', $element, $options);
}
@@ -639,8 +651,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function switchOff($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Effect.SwitchOff', $element, $options);
}
@@ -651,8 +663,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function highlight($element, $options=null)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$this->visualEffect('Prado.Effect.Highlight', $element, $options);
}
@@ -663,8 +675,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function setOpacity($element, $value)
{
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
$value = TPropertyValue::ensureFloat($value);
$this->callClientFunction('Element.setOpacity', array($element,$value));
}
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSide.php b/framework/Web/UI/ActiveControls/TCallbackClientSide.php
index 57436278..31b806c3 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientSide.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientSide.php
@@ -4,7 +4,7 @@
*
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -22,13 +22,13 @@
* - <b>onLoaded</b>* executed when callback request begins.
* - <b>onInteractive</b> executed when callback request is in progress.
* - <b>onComplete</b>executed when callback response returns.
- *
- * * Note that theses 2 events are not fired correctly by Opera. To make
- * them work in this browser, Prado will fire them just after onPreDispatch.
- *
- * In a general way, onUninitialized, onLoading, onLoaded and onInteractive events
- * are not implemented consistently in all browsers.When cross browser compatibility is
- * needed, it is best to avoid use them
+ *
+ * * Note that theses 2 events are not fired correctly by Opera. To make
+ * them work in this browser, Prado will fire them just after onPreDispatch.
+ *
+ * In a general way, onUninitialized, onLoading, onLoaded and onInteractive events
+ * are not implemented consistently in all browsers.When cross browser compatibility is
+ * needed, it is best to avoid use them
*
* The OnSuccess and OnFailure events are raised when the
* response is returned. A successful request/response will raise
@@ -247,7 +247,7 @@ class TCallbackClientSide extends TClientSideOptions
public function getHasPriority()
{
$option = $this->getOption('HasPriority');
- return is_null($option) ? true : $option;
+ return ($option===null) ? true : $option;
}
/**
@@ -284,7 +284,7 @@ class TCallbackClientSide extends TClientSideOptions
public function getEnablePageStateUpdate()
{
$option = $this->getOption('EnablePageStateUpdate');
- return is_null($option) ? true : $option;
+ return ($option===null) ? true : $option;
}
/**
diff --git a/framework/Web/UI/ActiveControls/TCallbackOptions.php b/framework/Web/UI/ActiveControls/TCallbackOptions.php
index 7c48b795..c9b649d8 100644
--- a/framework/Web/UI/ActiveControls/TCallbackOptions.php
+++ b/framework/Web/UI/ActiveControls/TCallbackOptions.php
@@ -4,7 +4,7 @@
*
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -37,7 +37,7 @@ class TCallbackOptions extends TControl
*/
public function getClientSide()
{
- if(is_null($this->_clientSide))
+ if($this->_clientSide===null)
$this->_clientSide = $this->createClientSide();
return $this->_clientSide;
}
diff --git a/framework/Web/UI/ActiveControls/TDropContainer.php b/framework/Web/UI/ActiveControls/TDropContainer.php
index 5d090d95..75a80625 100755
--- a/framework/Web/UI/ActiveControls/TDropContainer.php
+++ b/framework/Web/UI/ActiveControls/TDropContainer.php
@@ -123,12 +123,8 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan
{
// Find the control
// Warning, this will not work if you have a '_' in your control Id !
- $control=$this->getPage();
- $namingContainers=explode(TControl::CLIENT_ID_SEPARATOR, $dropControlId);
- foreach ($namingContainers as $nc)
- {
- $control=$control->findControl($nc);
- }
+ $dropControlId=str_replace(TControl::CLIENT_ID_SEPARATOR,TControl::ID_SEPARATOR,$dropControlId);
+ $control=$this->getPage()->findControl($dropControlId);
$this->raiseEvent('OnDrop', $this, new TDropContainerEventParameter ($control));
}
@@ -196,7 +192,7 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan
if ($this->_container===null)
{
$this->_container=Prado::CreateComponent('System.Web.UI.ActiveControls.TActivePanel');
- $this->_container->setId($this->getId().'_content');
+ $this->_container->setId($this->getId(false).'_content');
parent::getControls()->add($this->_container);
}
}
diff --git a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
index 6e1c6b7a..b8dd666b 100644
--- a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
+++ b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
@@ -4,7 +4,7 @@
*
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -35,9 +35,9 @@ Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
* After the callback request returns sucessfully, the textbox is enabled.
* If the {@link setAutoHideTextBox AutoHideTextBox} property is true, then
* the textbox will be hidden and the label is then shown.
- *
- * Since 3.1.2, you can set the {@link setReadOnly ReadOnly} property to make
- * the control not editable. This property can be also changed on callback
+ *
+ * Since 3.1.2, you can set the {@link setReadOnly ReadOnly} property to make
+ * the control not editable. This property can be also changed on callback
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Id$
@@ -124,7 +124,7 @@ class TInPlaceTextBox extends TActiveTextBox
protected function getExternalControlID()
{
$extID = $this->getEditTriggerControlID();
- if(is_null($extID)) return '';
+ if($extID===null) return '';
if(($control = $this->findControl($extID))!==null)
return $control->getClientID();
return $extID;
@@ -144,21 +144,21 @@ class TInPlaceTextBox extends TActiveTextBox
$client->update($this->getLabelClientID(), $value);
$client->setValue($this, $value);
}
- }
-
- /**
- * Update ClientSide Readonly property
- * @param boolean value
- * @since 3.1.2
- */
- public function setReadOnly ($value)
- {
- $value=TPropertyValue::ensureBoolean($value);
- TTextBox::setReadOnly($value);
- if ($this->getActiveControl()->canUpdateClientSide())
- {
- $this->callClientFunction('setReadOnly', $value);
- }
+ }
+
+ /**
+ * Update ClientSide Readonly property
+ * @param boolean value
+ * @since 3.1.2
+ */
+ public function setReadOnly ($value)
+ {
+ $value=TPropertyValue::ensureBoolean($value);
+ TTextBox::setReadOnly($value);
+ if ($this->getActiveControl()->canUpdateClientSide())
+ {
+ $this->callClientFunction('setReadOnly', $value);
+ }
}
/**
@@ -231,8 +231,8 @@ class TInPlaceTextBox extends TActiveTextBox
}
if($this->hasEventHandler('OnLoadingText'))
- $options['LoadTextOnEdit'] = true;
-
+ $options['LoadTextOnEdit'] = true;
+
$options['ReadOnly']=$this->getReadOnly();
return $options;
}