summaryrefslogtreecommitdiff
path: root/framework/Web/UI/ActiveControls
diff options
context:
space:
mode:
authorctrlaltca <>2012-07-12 11:21:01 +0000
committerctrlaltca <>2012-07-12 11:21:01 +0000
commit903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch)
treee08bf04f0823650a231227ac3499121270172a23 /framework/Web/UI/ActiveControls
parent3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff)
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'framework/Web/UI/ActiveControls')
-rw-r--r--framework/Web/UI/ActiveControls/TActiveButton.php264
-rwxr-xr-xframework/Web/UI/ActiveControls/TActiveClientScript.php164
-rw-r--r--framework/Web/UI/ActiveControls/TActiveControlAdapter.php1150
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCustomValidator.php530
-rw-r--r--framework/Web/UI/ActiveControls/TActiveLabel.php2
-rw-r--r--framework/Web/UI/ActiveControls/TActivePageAdapter.php802
-rw-r--r--framework/Web/UI/ActiveControls/TActivePanel.php200
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRatingList.php266
-rw-r--r--framework/Web/UI/ActiveControls/TActiveTextBox.php250
-rw-r--r--framework/Web/UI/ActiveControls/TAutoComplete.php880
-rw-r--r--framework/Web/UI/ActiveControls/TBaseActiveControl.php784
-rw-r--r--framework/Web/UI/ActiveControls/TCallback.php202
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientScript.php1410
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientSide.php644
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackEventParameter.php174
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackOptions.php106
-rw-r--r--framework/Web/UI/ActiveControls/TEventTriggeredCallback.php190
-rw-r--r--framework/Web/UI/ActiveControls/TInPlaceTextBox.php580
-rw-r--r--framework/Web/UI/ActiveControls/TTriggeredCallback.php142
-rw-r--r--framework/Web/UI/ActiveControls/TValueTriggeredCallback.php240
20 files changed, 4490 insertions, 4490 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveButton.php b/framework/Web/UI/ActiveControls/TActiveButton.php
index aaa10168..15b33692 100644
--- a/framework/Web/UI/ActiveControls/TActiveButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveButton.php
@@ -1,132 +1,132 @@
-<?php
-/**
- * TActiveButton class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * Load active control adapter.
- */
-Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
-
-/**
- * TActiveButton is the active control counter part to TButton.
- *
- * When a TActiveButton is clicked, rather than a normal post back request a
- * callback request is initiated.
- *
- * The {@link onCallback OnCallback} event is raised during a callback request
- * and it is raise <b>after</b> the {@link onClick OnClick} event.
- *
- * When the {@link TBaseActiveCallbackControl::setEnableUpdate ActiveControl.EnableUpdate}
- * property is true, changing the {@link setText Text} property during callback request
- * will update the button's caption upon callback response completion.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TActiveButton extends TButton implements ICallbackEventHandler, IActiveControl
-{
- /**
- * Creates a new callback control, sets the adapter to
- * TActiveControlAdapter. If you override this class, be sure to set the
- * adapter appropriately by, for example, by calling this constructor.
- */
- public function __construct()
- {
- parent::__construct();
- $this->setAdapter(new TActiveControlAdapter($this));
- }
-
- /**
- * @return TBaseActiveCallbackControl standard callback control options.
- */
- public function getActiveControl()
- {
- return $this->getAdapter()->getBaseActiveControl();
- }
-
- /**
- * @return TCallbackClientSide client side request options.
- */
- public function getClientSide()
- {
- return $this->getAdapter()->getBaseActiveControl()->getClientSide();
- }
-
- /**
- * Raises the callback event. This method is required by
- * {@link ICallbackEventHandler} interface. If {@link getCausesValidation CausesValidation}
- * is true, it will invoke the page's {@link TPage::validate validate}
- * method first. It will raise {@link onClick OnClick} event first
- * and then the {@link onCallback OnCallback} event.
- * This method is mainly used by framework and control developers.
- * @param TCallbackEventParameter the event parameter
- */
- public function raiseCallbackEvent($param)
- {
- $this->raisePostBackEvent($param);
- $this->onCallback($param);
- }
-
- /**
- * This method is invoked when a callback is requested. The method raises
- * 'OnCallback' event to fire up the event handlers. If you override this
- * method, be sure to call the parent implementation so that the event
- * handler can be invoked.
- * @param TCallbackEventParameter event parameter to be passed to the event handlers
- */
- public function onCallback($param)
- {
- $this->raiseEvent('OnCallback', $this, $param);
- }
-
- /**
- * Updates the button text on the client-side if the
- * {@link setEnableUpdate EnableUpdate} property is set to true.
- * @param string caption of the button
- */
- public function setText($value)
- {
- parent::setText($value);
- if($this->getActiveControl()->canUpdateClientSide())
- $this->getPage()->getCallbackClient()->setAttribute($this, 'value', $value);
- }
-
- /**
- * Override parent implementation, no javascript is rendered here instead
- * the javascript required for active control is registered in {@link addAttributesToRender}.
- */
- protected function renderClientControlScript($writer)
- {
- }
-
- /**
- * Ensure that the ID attribute is rendered and registers the javascript code
- * for initializing the active control.
- */
- protected function addAttributesToRender($writer)
- {
- parent::addAttributesToRender($writer);
- $writer->addAttribute('id',$this->getClientID());
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
- }
-
- /**
- * @return string corresponding javascript class name for this TActiveButton.
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TActiveButton';
- }
-}
-
+<?php
+/**
+ * TActiveButton class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load active control adapter.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
+
+/**
+ * TActiveButton is the active control counter part to TButton.
+ *
+ * When a TActiveButton is clicked, rather than a normal post back request a
+ * callback request is initiated.
+ *
+ * The {@link onCallback OnCallback} event is raised during a callback request
+ * and it is raise <b>after</b> the {@link onClick OnClick} event.
+ *
+ * When the {@link TBaseActiveCallbackControl::setEnableUpdate ActiveControl.EnableUpdate}
+ * property is true, changing the {@link setText Text} property during callback request
+ * will update the button's caption upon callback response completion.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TActiveButton extends TButton implements ICallbackEventHandler, IActiveControl
+{
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
+ * Raises the callback event. This method is required by
+ * {@link ICallbackEventHandler} interface. If {@link getCausesValidation CausesValidation}
+ * is true, it will invoke the page's {@link TPage::validate validate}
+ * method first. It will raise {@link onClick OnClick} event first
+ * and then the {@link onCallback OnCallback} event.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->raisePostBackEvent($param);
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * Updates the button text on the client-side if the
+ * {@link setEnableUpdate EnableUpdate} property is set to true.
+ * @param string caption of the button
+ */
+ public function setText($value)
+ {
+ parent::setText($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'value', $value);
+ }
+
+ /**
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getClientID());
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
+
+ /**
+ * @return string corresponding javascript class name for this TActiveButton.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TActiveButton';
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TActiveClientScript.php b/framework/Web/UI/ActiveControls/TActiveClientScript.php
index 423918d9..2e58b6b0 100755
--- a/framework/Web/UI/ActiveControls/TActiveClientScript.php
+++ b/framework/Web/UI/ActiveControls/TActiveClientScript.php
@@ -1,82 +1,82 @@
-<?php
-/**
- * TActiveClientScript class file
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id: TActiveClientScript.php 3144 2012-05-19 10:07:03Z ctrlaltca $
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * TActiveClientScript class
- *
- * This is the active counterpart of the {@link TClientScript} class.
- *
- * TActiveClientScript has the ability to render itself on ajax
- * callbacks. This means that every variable or function declared in javascript
- * code will be available to the page.
- *
- * Beware that when rendered on normal (postback) or ajax callbacks, some
- * javascript code won't behave in the same way.
- * When rendered as part of a normal/postback response, scripts will execute instantly
- * where they are in the page and in a synchronous fashion.
- * Instead, when they are rendered as part of a callback response,
- * they will be executed when all DOM modifications are complete and any dynamic
- * script file includes are loaded, out-of-band and practically all blocks at once,
- * regardless of where they actually occour in the original template/markup code.
- * This can potentially hurt compatibility and graceful fallback.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id: TActiveClientScript.php 3144 2012-05-19 10:07:03Z ctrlaltca $
- * @package System.Web.UI.ActiveControls
- * @since 3.2
- */
-
-class TActiveClientScript extends TClientScript
-{
- /**
- * Renders the custom script file.
- * @param THtmLWriter the renderer
- */
- protected function renderCustomScriptFile($writer)
- {
- if(($scriptUrl = $this->getScriptUrl())!=='')
- {
- if($this->getPage()->getIsCallback())
- {
- $cs = $this->getPage()->getClientScript();
- $uniqueid=$this->ClientID.'_custom';
- if(!$cs->isScriptFileRegistered($uniqueid))
- $cs->registerScriptFile($uniqueid, $scriptUrl);
- } else {
- $writer->write("<script type=\"text/javascript\" src=\"$scriptUrl\"></script>\n");
- }
- }
- }
-
- /**
- * Registers the body content as javascript.
- * @param THtmlWriter the renderer
- */
- protected function renderCustomScript($writer)
- {
- if($this->getHasControls())
- {
- if($this->getPage()->getIsCallback())
- {
- $extWriter= $this->getPage()->getResponse()->createHtmlWriter();
- $extWriter->write("/*<![CDATA[*/\n");
- $this->renderChildren($extWriter);
- $extWriter->write("\n/*]]>*/");
- $this->getPage()->getCallbackClient()->appendScriptBlock($extWriter);
- } else {
- $writer->write("<script type=\"text/javascript\">\n/*<![CDATA[*/\n");
- $this->renderChildren($writer);
- $writer->write("\n/*]]>*/\n</script>\n");
- }
- }
- }
-}
+<?php
+/**
+ * TActiveClientScript class file
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id: TActiveClientScript.php 3144 2012-05-19 10:07:03Z ctrlaltca $
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * TActiveClientScript class
+ *
+ * This is the active counterpart of the {@link TClientScript} class.
+ *
+ * TActiveClientScript has the ability to render itself on ajax
+ * callbacks. This means that every variable or function declared in javascript
+ * code will be available to the page.
+ *
+ * Beware that when rendered on normal (postback) or ajax callbacks, some
+ * javascript code won't behave in the same way.
+ * When rendered as part of a normal/postback response, scripts will execute instantly
+ * where they are in the page and in a synchronous fashion.
+ * Instead, when they are rendered as part of a callback response,
+ * they will be executed when all DOM modifications are complete and any dynamic
+ * script file includes are loaded, out-of-band and practically all blocks at once,
+ * regardless of where they actually occour in the original template/markup code.
+ * This can potentially hurt compatibility and graceful fallback.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id: TActiveClientScript.php 3144 2012-05-19 10:07:03Z ctrlaltca $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.2
+ */
+
+class TActiveClientScript extends TClientScript
+{
+ /**
+ * Renders the custom script file.
+ * @param THtmLWriter the renderer
+ */
+ protected function renderCustomScriptFile($writer)
+ {
+ if(($scriptUrl = $this->getScriptUrl())!=='')
+ {
+ if($this->getPage()->getIsCallback())
+ {
+ $cs = $this->getPage()->getClientScript();
+ $uniqueid=$this->ClientID.'_custom';
+ if(!$cs->isScriptFileRegistered($uniqueid))
+ $cs->registerScriptFile($uniqueid, $scriptUrl);
+ } else {
+ $writer->write("<script type=\"text/javascript\" src=\"$scriptUrl\"></script>\n");
+ }
+ }
+ }
+
+ /**
+ * Registers the body content as javascript.
+ * @param THtmlWriter the renderer
+ */
+ protected function renderCustomScript($writer)
+ {
+ if($this->getHasControls())
+ {
+ if($this->getPage()->getIsCallback())
+ {
+ $extWriter= $this->getPage()->getResponse()->createHtmlWriter();
+ $extWriter->write("/*<![CDATA[*/\n");
+ $this->renderChildren($extWriter);
+ $extWriter->write("\n/*]]>*/");
+ $this->getPage()->getCallbackClient()->appendScriptBlock($extWriter);
+ } else {
+ $writer->write("<script type=\"text/javascript\">\n/*<![CDATA[*/\n");
+ $this->renderChildren($writer);
+ $writer->write("\n/*]]>*/\n</script>\n");
+ }
+ }
+ }
+}
diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
index 8a0c8aec..7e7a82fe 100644
--- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
@@ -1,575 +1,575 @@
-<?php
-/**
- * TActiveControlAdapter and TCallbackPageStateTracker class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/*
- * Load common active control options.
- */
-Prado::using('System.Web.UI.ActiveControls.TBaseActiveControl');
-
-/**
- * TActiveControlAdapter class.
- *
- * Customize the parent TControl class for active control classes.
- * TActiveControlAdapter instantiates a common base active control class
- * throught the {@link getBaseActiveControl BaseActiveControl} property.
- * The type of BaseActiveControl can be provided in the second parameter in the
- * constructor. Default is TBaseActiveControl or TBaseActiveCallbackControl if
- * the control adapted implements ICallbackEventHandler.
- *
- * TActiveControlAdapter will tracking viewstate changes to update the
- * corresponding client-side properties.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TActiveControlAdapter extends TControlAdapter
-{
- /**
- * @var string base active control class name.
- */
- private $_activeControlType;
- /**
- * @var TBaseActiveControl base active control instance.
- */
- private $_baseActiveControl;
- /**
- * @var TCallbackPageStateTracker view state tracker.
- */
- private $_stateTracker;
-
- /**
- * Constructor.
- * @param IActiveControl active control to adapt.
- * @param string Base active control class name.
- */
- public function __construct(IActiveControl $control, $baseCallbackClass=null)
- {
- parent::__construct($control);
- $this->setBaseControlClass($baseCallbackClass);
- }
-
- /**
- * @param string base active control instance
- */
- protected function setBaseControlClass($type)
- {
- if($type===null)
- {
- if($this->getControl() instanceof ICallbackEventHandler)
- $this->_activeControlType = 'TBaseActiveCallbackControl';
- else
- $this->_activeControlType = 'TBaseActiveControl';
- }
- else
- $this->_activeControlType = $type;
- }
-
- /**
- * Publish the ajax script
- */
- public function onPreRender($param)
- {
- parent::onPreRender($param);
- }
-
- /**
- * Renders the callback client scripts.
- */
- public function render($writer)
- {
- $this->getPage()->getClientScript()->registerPradoScript('ajax');
- $this->renderCallbackClientScripts();
- if($this->_control->getVisible(false))
- {
- parent::render($writer);
- } else {
- $writer->write("<span id=\"".$this->_control->getClientID()."\" style=\"display:none\"></span>");
- }
- }
-
- /**
- * Register the callback clientscripts and sets the post loader IDs.
- */
- protected function renderCallbackClientScripts()
- {
- $cs = $this->getPage()->getClientScript();
- $key = 'Prado.CallbackRequest.addPostLoaders';
- if(!$cs->isEndScriptRegistered($key))
- {
- $data = $this->getPage()->getPostDataLoaders();
- if(count($data) > 0)
- {
- $options = TJavaScript::encode($data,false);
- $script = "Prado.CallbackRequest.addPostLoaders({$options});";
- $cs->registerEndScript($key, $script);
- }
- }
- }
-
- /**
- * @param TBaseActiveControl change base active control
- */
- public function setBaseActiveControl($control)
- {
- $this->_baseActiveControl=$control;
- }
-
- /**
- * @return TBaseActiveControl Common active control options.
- */
- public function getBaseActiveControl()
- {
- if($this->_baseActiveControl===null)
- {
- $type = $this->_activeControlType;
- $this->_baseActiveControl = new $type($this->getControl());
- }
- return $this->_baseActiveControl;
- }
-
- /**
- * @return boolean true if the viewstate needs to be tracked.
- */
- protected function getIsTrackingPageState()
- {
- if($this->getPage()->getIsCallback())
- {
- $target = $this->getPage()->getCallbackEventTarget();
- if($target instanceof ICallbackEventHandler)
- {
- $client = $target->getActiveControl()->getClientSide();
- return $client->getEnablePageStateUpdate();
- }
- }
- return false;
- }
-
- /**
- * Starts viewstate tracking if necessary after when controls has been loaded
- */
- public function onLoad($param)
- {
- if($this->getIsTrackingPageState())
- {
- $this->_stateTracker = new TCallbackPageStateTracker($this->getControl());
- $this->_stateTracker->trackChanges();
- }
- parent::onLoad($param);
- }
-
- /**
- * Saves additional persistent control state. Respond to viewstate changes
- * if necessary.
- */
- public function saveState()
- {
- if(($this->_stateTracker!==null)
- && $this->getControl()->getActiveControl()->canUpdateClientSide(true))
- {
- $this->_stateTracker->respondToChanges();
- }
- parent::saveState();
- }
-
- /**
- * @return TCallbackPageStateTracker state tracker.
- */
- public function getStateTracker()
- {
- return $this->_stateTracker;
- }
-}
-
-/**
- * TCallbackPageStateTracker class.
- *
- * Tracking changes to the page state during callback.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TCallbackPageStateTracker
-{
- /**
- * @var TMap new view state data
- */
- private $_states;
- /**
- * @var TMap old view state data
- */
- private $_existingState;
- /**
- * @var TControl the control tracked
- */
- private $_control;
- /**
- * @var object null object.
- */
- private $_nullObject;
-
- /**
- * Constructor. Add a set of default states to track.
- * @param TControl control to track.
- */
- public function __construct($control)
- {
- $this->_control = $control;
- $this->_existingState = new TMap;
- $this->_nullObject = new stdClass;
- $this->_states = new TMap;
- $this->addStatesToTrack();
- }
-
- /**
- * Add a list of view states to track. Each state is added
- * to the StatesToTrack property with the view state name as key.
- * The value should be an array with two enteries. The first entery
- * is the name of the class that will calculate the state differences.
- * The second entry is a php function/method callback that handles
- * the changes in the viewstate.
- */
- protected function addStatesToTrack()
- {
- $states = $this->getStatesToTrack();
- $states['Visible'] = array('TScalarDiff', array($this, 'updateVisible'));
- $states['Enabled'] = array('TScalarDiff', array($this, 'updateEnabled'));
- $states['Attributes'] = array('TMapCollectionDiff', array($this, 'updateAttributes'));
- $states['Style'] = array('TStyleDiff', array($this, 'updateStyle'));
- $states['TabIndex'] = array('TScalarDiff', array($this, 'updateTabIndex'));
- $states['ToolTip'] = array('TScalarDiff', array($this, 'updateToolTip'));
- $states['AccessKey'] = array('TScalarDiff', array($this, 'updateAccessKey'));
- }
-
- /**
- * @return TMap list of viewstates to track.
- */
- protected function getStatesToTrack()
- {
- return $this->_states;
- }
-
- /**
- * Start tracking view state changes. The clone function on objects are called
- * for those viewstate having an object as value.
- */
- public function trackChanges()
- {
- foreach($this->_states as $name => $value)
- {
- $obj = $this->_control->getViewState($name);
- $this->_existingState[$name] = is_object($obj) ? clone($obj) : $obj;
- }
- }
-
- /**
- * @return array list of viewstate and the changed data.
- */
- protected function getChanges()
- {
- $changes = array();
- foreach($this->_states as $name => $details)
- {
- $new = $this->_control->getViewState($name);
- $old = $this->_existingState[$name];
- if($new !== $old)
- {
- $diff = new $details[0]($new, $old, $this->_nullObject);
- if(($change = $diff->getDifference()) !== $this->_nullObject)
- $changes[] = array($details[1],array($change));
- }
- }
- return $changes;
- }
-
- /**
- * For each of the changes call the corresponding change handlers.
- */
- public function respondToChanges()
- {
- foreach($this->getChanges() as $change)
- call_user_func_array($change[0], $change[1]);
- }
-
- /**
- * @return TCallbackClientScript callback client scripting
- */
- protected function client()
- {
- return $this->_control->getPage()->getCallbackClient();
- }
-
- /**
- * Updates the tooltip.
- * @param string new tooltip
- */
- protected function updateToolTip($value)
- {
- $this->client()->setAttribute($this->_control, 'title', $value);
- }
-
- /**
- * Updates the tab index.
- * @param integer tab index
- */
- protected function updateTabIndex($value)
- {
- $this->client()->setAttribute($this->_control, 'tabindex', $value);
- }
-
- /**
- * Updates the modifier access key
- * @param string access key
- */
- protected function updateAccessKey($value)
- {
- $this->client()->setAttribute($this->_control, 'accesskey', $value);
- }
-
- /**
- * Hides or shows the control on the client-side. The control must be
- * already rendered on the client-side.
- * @param boolean true to show the control, false to hide.
- */
- protected function updateVisible($visible)
- {
- if($visible === false)
- $this->client()->replaceContent($this->_control,"<span id=\"".$this->_control->getClientID()."\" style=\"display:none\" ></span>");
- else
- $this->client()->replaceContent($this->_control,$this->_control);
- }
-
- /**
- * Enables or Disables the control on the client-side.
- * @param boolean true to enable the control, false to disable.
- */
- protected function updateEnabled($enable)
- {
- $this->client()->setAttribute($this->_control, 'disabled', $enable===false);
- }
-
- /**
- * Updates the CSS style on the control on the client-side.
- * @param array list of new CSS style declarations.
- */
- protected function updateStyle($style)
- {
- if($style['CssClass']!==null)
- $this->client()->setAttribute($this->_control, 'class', $style['CssClass']);
- if(count($style['Style']) > 0)
- $this->client()->setStyle($this->_control, $style['Style']);
- }
-
- /**
- * Updates/adds a list of attributes on the control.
- * @param array list of attribute name-value pairs.
- */
- protected function updateAttributes($attributes)
- {
- foreach($attributes as $name => $value)
- $this->client()->setAttribute($this->_control, $name, $value);
- }
-}
-
-/**
- * Calculates the viewstate changes during the request.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-abstract class TViewStateDiff
-{
- /**
- * @var mixed updated viewstate
- */
- protected $_new;
- /**
- * @var mixed viewstate value at the begining of the request.
- */
- protected $_old;
- /**
- * @var object null value.
- */
- protected $_null;
-
- /**
- * Constructor.
- * @param mixed updated viewstate value.
- * @param mixed viewstate value at the begining of the request.
- * @param object representing the null value.
- */
- public function __construct($new, $old, $null)
- {
- $this->_new = $new;
- $this->_old = $old;
- $this->_null = $null;
- }
-
- /**
- * @return mixed view state changes, nullObject if no difference.
- */
- public abstract function getDifference();
-}
-
-/**
- * TScalarDiff class.
- *
- * Calculate the changes to a scalar value.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TScalarDiff extends TViewStateDiff
-{
- /**
- * @return mixed update viewstate value.
- */
- public function getDifference()
- {
- if(gettype($this->_new) === gettype($this->_old)
- && $this->_new === $this->_old)
- return $this->_null;
- else
- return $this->_new;
- }
-}
-
-/**
- * TStyleDiff class.
- *
- * Calculates the changes to the Style properties.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TStyleDiff extends TViewStateDiff
-{
- /**
- * @param TStyle control style
- * @return array all the style properties combined.
- */
- protected function getCombinedStyle($obj)
- {
- if(!($obj instanceof TStyle))
- return array();
- $style = $obj->getStyleFields();
- $style = array_merge($style,$this->getStyleFromString($obj->getCustomStyle()));
- if($obj->hasFont())
- $style = array_merge($style, $this->getStyleFromString($obj->getFont()->toString()));
- return $style;
- }
-
- /**
- * @param string CSS custom style string.
- * @param array CSS style as name-value array.
- */
- protected function getStyleFromString($string)
- {
- $style = array();
- if(!is_string($string)) return $style;
-
- foreach(explode(';',$string) as $sub)
- {
- $arr=explode(':',$sub);
- if(isset($arr[1]) && trim($arr[0])!=='')
- $style[trim($arr[0])] = trim($arr[1]);
- }
- return $style;
- }
-
- /**
- * @return string changes to the CSS class name.
- */
- protected function getCssClassDiff()
- {
- if($this->_old===null)
- {
- return ($this->_new!==null) && $this->_new->hasCssClass()
- ? $this->_new->getCssClass() : null;
- }
- else
- {
- return $this->_old->getCssClass() !== $this->_new->getCssClass() ?
- $this->_new->getCssClass() : null;
- }
- }
-
- /**
- * @return array list of changes to the control style.
- */
- protected function getStyleDiff()
- {
- $diff = array_diff_assoc(
- $this->getCombinedStyle($this->_new),
- $this->getCombinedStyle($this->_old));
- return count($diff) > 0 ? $diff : null;
- }
-
- /**
- * @return array list of changes to the control style and CSS class name.
- */
- public function getDifference()
- {
- if($this->_new===null)
- return $this->_null;
- else
- {
- $css = $this->getCssClassDiff();
- $style = $this->getStyleDiff();
- if(($css!==null) || ($style!==null))
- return array('CssClass' => $css, 'Style' => $style);
- else
- $this->_null;
- }
- }
-}
-
-/**
- * TAttributesDiff class.
- *
- * Calculate the changes to attributes collection.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TMapCollectionDiff extends TViewStateDiff
-{
- /**
- * @return array updates to the attributes collection.
- */
- public function getDifference()
- {
- if($this->_old===null)
- {
- return ($this->_new!==null) ? $this->_new->toArray() : $this->_null;
- }
- else
- {
- $new = $this->_new->toArray();
- $old = $this->_old->toArray();
- $diff = array_diff_assoc($new, $old);
- return count($diff) > 0 ? $diff : $this->_null;
- }
- }
-}
-
+<?php
+/**
+ * TActiveControlAdapter and TCallbackPageStateTracker class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/*
+ * Load common active control options.
+ */
+Prado::using('System.Web.UI.ActiveControls.TBaseActiveControl');
+
+/**
+ * TActiveControlAdapter class.
+ *
+ * Customize the parent TControl class for active control classes.
+ * TActiveControlAdapter instantiates a common base active control class
+ * throught the {@link getBaseActiveControl BaseActiveControl} property.
+ * The type of BaseActiveControl can be provided in the second parameter in the
+ * constructor. Default is TBaseActiveControl or TBaseActiveCallbackControl if
+ * the control adapted implements ICallbackEventHandler.
+ *
+ * TActiveControlAdapter will tracking viewstate changes to update the
+ * corresponding client-side properties.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TActiveControlAdapter extends TControlAdapter
+{
+ /**
+ * @var string base active control class name.
+ */
+ private $_activeControlType;
+ /**
+ * @var TBaseActiveControl base active control instance.
+ */
+ private $_baseActiveControl;
+ /**
+ * @var TCallbackPageStateTracker view state tracker.
+ */
+ private $_stateTracker;
+
+ /**
+ * Constructor.
+ * @param IActiveControl active control to adapt.
+ * @param string Base active control class name.
+ */
+ public function __construct(IActiveControl $control, $baseCallbackClass=null)
+ {
+ parent::__construct($control);
+ $this->setBaseControlClass($baseCallbackClass);
+ }
+
+ /**
+ * @param string base active control instance
+ */
+ protected function setBaseControlClass($type)
+ {
+ if($type===null)
+ {
+ if($this->getControl() instanceof ICallbackEventHandler)
+ $this->_activeControlType = 'TBaseActiveCallbackControl';
+ else
+ $this->_activeControlType = 'TBaseActiveControl';
+ }
+ else
+ $this->_activeControlType = $type;
+ }
+
+ /**
+ * Publish the ajax script
+ */
+ public function onPreRender($param)
+ {
+ parent::onPreRender($param);
+ }
+
+ /**
+ * Renders the callback client scripts.
+ */
+ public function render($writer)
+ {
+ $this->getPage()->getClientScript()->registerPradoScript('ajax');
+ $this->renderCallbackClientScripts();
+ if($this->_control->getVisible(false))
+ {
+ parent::render($writer);
+ } else {
+ $writer->write("<span id=\"".$this->_control->getClientID()."\" style=\"display:none\"></span>");
+ }
+ }
+
+ /**
+ * Register the callback clientscripts and sets the post loader IDs.
+ */
+ protected function renderCallbackClientScripts()
+ {
+ $cs = $this->getPage()->getClientScript();
+ $key = 'Prado.CallbackRequest.addPostLoaders';
+ if(!$cs->isEndScriptRegistered($key))
+ {
+ $data = $this->getPage()->getPostDataLoaders();
+ if(count($data) > 0)
+ {
+ $options = TJavaScript::encode($data,false);
+ $script = "Prado.CallbackRequest.addPostLoaders({$options});";
+ $cs->registerEndScript($key, $script);
+ }
+ }
+ }
+
+ /**
+ * @param TBaseActiveControl change base active control
+ */
+ public function setBaseActiveControl($control)
+ {
+ $this->_baseActiveControl=$control;
+ }
+
+ /**
+ * @return TBaseActiveControl Common active control options.
+ */
+ public function getBaseActiveControl()
+ {
+ if($this->_baseActiveControl===null)
+ {
+ $type = $this->_activeControlType;
+ $this->_baseActiveControl = new $type($this->getControl());
+ }
+ return $this->_baseActiveControl;
+ }
+
+ /**
+ * @return boolean true if the viewstate needs to be tracked.
+ */
+ protected function getIsTrackingPageState()
+ {
+ if($this->getPage()->getIsCallback())
+ {
+ $target = $this->getPage()->getCallbackEventTarget();
+ if($target instanceof ICallbackEventHandler)
+ {
+ $client = $target->getActiveControl()->getClientSide();
+ return $client->getEnablePageStateUpdate();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Starts viewstate tracking if necessary after when controls has been loaded
+ */
+ public function onLoad($param)
+ {
+ if($this->getIsTrackingPageState())
+ {
+ $this->_stateTracker = new TCallbackPageStateTracker($this->getControl());
+ $this->_stateTracker->trackChanges();
+ }
+ parent::onLoad($param);
+ }
+
+ /**
+ * Saves additional persistent control state. Respond to viewstate changes
+ * if necessary.
+ */
+ public function saveState()
+ {
+ if(($this->_stateTracker!==null)
+ && $this->getControl()->getActiveControl()->canUpdateClientSide(true))
+ {
+ $this->_stateTracker->respondToChanges();
+ }
+ parent::saveState();
+ }
+
+ /**
+ * @return TCallbackPageStateTracker state tracker.
+ */
+ public function getStateTracker()
+ {
+ return $this->_stateTracker;
+ }
+}
+
+/**
+ * TCallbackPageStateTracker class.
+ *
+ * Tracking changes to the page state during callback.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TCallbackPageStateTracker
+{
+ /**
+ * @var TMap new view state data
+ */
+ private $_states;
+ /**
+ * @var TMap old view state data
+ */
+ private $_existingState;
+ /**
+ * @var TControl the control tracked
+ */
+ private $_control;
+ /**
+ * @var object null object.
+ */
+ private $_nullObject;
+
+ /**
+ * Constructor. Add a set of default states to track.
+ * @param TControl control to track.
+ */
+ public function __construct($control)
+ {
+ $this->_control = $control;
+ $this->_existingState = new TMap;
+ $this->_nullObject = new stdClass;
+ $this->_states = new TMap;
+ $this->addStatesToTrack();
+ }
+
+ /**
+ * Add a list of view states to track. Each state is added
+ * to the StatesToTrack property with the view state name as key.
+ * The value should be an array with two enteries. The first entery
+ * is the name of the class that will calculate the state differences.
+ * The second entry is a php function/method callback that handles
+ * the changes in the viewstate.
+ */
+ protected function addStatesToTrack()
+ {
+ $states = $this->getStatesToTrack();
+ $states['Visible'] = array('TScalarDiff', array($this, 'updateVisible'));
+ $states['Enabled'] = array('TScalarDiff', array($this, 'updateEnabled'));
+ $states['Attributes'] = array('TMapCollectionDiff', array($this, 'updateAttributes'));
+ $states['Style'] = array('TStyleDiff', array($this, 'updateStyle'));
+ $states['TabIndex'] = array('TScalarDiff', array($this, 'updateTabIndex'));
+ $states['ToolTip'] = array('TScalarDiff', array($this, 'updateToolTip'));
+ $states['AccessKey'] = array('TScalarDiff', array($this, 'updateAccessKey'));
+ }
+
+ /**
+ * @return TMap list of viewstates to track.
+ */
+ protected function getStatesToTrack()
+ {
+ return $this->_states;
+ }
+
+ /**
+ * Start tracking view state changes. The clone function on objects are called
+ * for those viewstate having an object as value.
+ */
+ public function trackChanges()
+ {
+ foreach($this->_states as $name => $value)
+ {
+ $obj = $this->_control->getViewState($name);
+ $this->_existingState[$name] = is_object($obj) ? clone($obj) : $obj;
+ }
+ }
+
+ /**
+ * @return array list of viewstate and the changed data.
+ */
+ protected function getChanges()
+ {
+ $changes = array();
+ foreach($this->_states as $name => $details)
+ {
+ $new = $this->_control->getViewState($name);
+ $old = $this->_existingState[$name];
+ if($new !== $old)
+ {
+ $diff = new $details[0]($new, $old, $this->_nullObject);
+ if(($change = $diff->getDifference()) !== $this->_nullObject)
+ $changes[] = array($details[1],array($change));
+ }
+ }
+ return $changes;
+ }
+
+ /**
+ * For each of the changes call the corresponding change handlers.
+ */
+ public function respondToChanges()
+ {
+ foreach($this->getChanges() as $change)
+ call_user_func_array($change[0], $change[1]);
+ }
+
+ /**
+ * @return TCallbackClientScript callback client scripting
+ */
+ protected function client()
+ {
+ return $this->_control->getPage()->getCallbackClient();
+ }
+
+ /**
+ * Updates the tooltip.
+ * @param string new tooltip
+ */
+ protected function updateToolTip($value)
+ {
+ $this->client()->setAttribute($this->_control, 'title', $value);
+ }
+
+ /**
+ * Updates the tab index.
+ * @param integer tab index
+ */
+ protected function updateTabIndex($value)
+ {
+ $this->client()->setAttribute($this->_control, 'tabindex', $value);
+ }
+
+ /**
+ * Updates the modifier access key
+ * @param string access key
+ */
+ protected function updateAccessKey($value)
+ {
+ $this->client()->setAttribute($this->_control, 'accesskey', $value);
+ }
+
+ /**
+ * Hides or shows the control on the client-side. The control must be
+ * already rendered on the client-side.
+ * @param boolean true to show the control, false to hide.
+ */
+ protected function updateVisible($visible)
+ {
+ if($visible === false)
+ $this->client()->replaceContent($this->_control,"<span id=\"".$this->_control->getClientID()."\" style=\"display:none\" ></span>");
+ else
+ $this->client()->replaceContent($this->_control,$this->_control);
+ }
+
+ /**
+ * Enables or Disables the control on the client-side.
+ * @param boolean true to enable the control, false to disable.
+ */
+ protected function updateEnabled($enable)
+ {
+ $this->client()->setAttribute($this->_control, 'disabled', $enable===false);
+ }
+
+ /**
+ * Updates the CSS style on the control on the client-side.
+ * @param array list of new CSS style declarations.
+ */
+ protected function updateStyle($style)
+ {
+ if($style['CssClass']!==null)
+ $this->client()->setAttribute($this->_control, 'class', $style['CssClass']);
+ if(count($style['Style']) > 0)
+ $this->client()->setStyle($this->_control, $style['Style']);
+ }
+
+ /**
+ * Updates/adds a list of attributes on the control.
+ * @param array list of attribute name-value pairs.
+ */
+ protected function updateAttributes($attributes)
+ {
+ foreach($attributes as $name => $value)
+ $this->client()->setAttribute($this->_control, $name, $value);
+ }
+}
+
+/**
+ * Calculates the viewstate changes during the request.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+abstract class TViewStateDiff
+{
+ /**
+ * @var mixed updated viewstate
+ */
+ protected $_new;
+ /**
+ * @var mixed viewstate value at the begining of the request.
+ */
+ protected $_old;
+ /**
+ * @var object null value.
+ */
+ protected $_null;
+
+ /**
+ * Constructor.
+ * @param mixed updated viewstate value.
+ * @param mixed viewstate value at the begining of the request.
+ * @param object representing the null value.
+ */
+ public function __construct($new, $old, $null)
+ {
+ $this->_new = $new;
+ $this->_old = $old;
+ $this->_null = $null;
+ }
+
+ /**
+ * @return mixed view state changes, nullObject if no difference.
+ */
+ public abstract function getDifference();
+}
+
+/**
+ * TScalarDiff class.
+ *
+ * Calculate the changes to a scalar value.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TScalarDiff extends TViewStateDiff
+{
+ /**
+ * @return mixed update viewstate value.
+ */
+ public function getDifference()
+ {
+ if(gettype($this->_new) === gettype($this->_old)
+ && $this->_new === $this->_old)
+ return $this->_null;
+ else
+ return $this->_new;
+ }
+}
+
+/**
+ * TStyleDiff class.
+ *
+ * Calculates the changes to the Style properties.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TStyleDiff extends TViewStateDiff
+{
+ /**
+ * @param TStyle control style
+ * @return array all the style properties combined.
+ */
+ protected function getCombinedStyle($obj)
+ {
+ if(!($obj instanceof TStyle))
+ return array();
+ $style = $obj->getStyleFields();
+ $style = array_merge($style,$this->getStyleFromString($obj->getCustomStyle()));
+ if($obj->hasFont())
+ $style = array_merge($style, $this->getStyleFromString($obj->getFont()->toString()));
+ return $style;
+ }
+
+ /**
+ * @param string CSS custom style string.
+ * @param array CSS style as name-value array.
+ */
+ protected function getStyleFromString($string)
+ {
+ $style = array();
+ if(!is_string($string)) return $style;
+
+ foreach(explode(';',$string) as $sub)
+ {
+ $arr=explode(':',$sub);
+ if(isset($arr[1]) && trim($arr[0])!=='')
+ $style[trim($arr[0])] = trim($arr[1]);
+ }
+ return $style;
+ }
+
+ /**
+ * @return string changes to the CSS class name.
+ */
+ protected function getCssClassDiff()
+ {
+ if($this->_old===null)
+ {
+ return ($this->_new!==null) && $this->_new->hasCssClass()
+ ? $this->_new->getCssClass() : null;
+ }
+ else
+ {
+ return $this->_old->getCssClass() !== $this->_new->getCssClass() ?
+ $this->_new->getCssClass() : null;
+ }
+ }
+
+ /**
+ * @return array list of changes to the control style.
+ */
+ protected function getStyleDiff()
+ {
+ $diff = array_diff_assoc(
+ $this->getCombinedStyle($this->_new),
+ $this->getCombinedStyle($this->_old));
+ return count($diff) > 0 ? $diff : null;
+ }
+
+ /**
+ * @return array list of changes to the control style and CSS class name.
+ */
+ public function getDifference()
+ {
+ if($this->_new===null)
+ return $this->_null;
+ else
+ {
+ $css = $this->getCssClassDiff();
+ $style = $this->getStyleDiff();
+ if(($css!==null) || ($style!==null))
+ return array('CssClass' => $css, 'Style' => $style);
+ else
+ $this->_null;
+ }
+ }
+}
+
+/**
+ * TAttributesDiff class.
+ *
+ * Calculate the changes to attributes collection.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TMapCollectionDiff extends TViewStateDiff
+{
+ /**
+ * @return array updates to the attributes collection.
+ */
+ public function getDifference()
+ {
+ if($this->_old===null)
+ {
+ return ($this->_new!==null) ? $this->_new->toArray() : $this->_null;
+ }
+ else
+ {
+ $new = $this->_new->toArray();
+ $old = $this->_old->toArray();
+ $diff = array_diff_assoc($new, $old);
+ return count($diff) > 0 ? $diff : $this->_null;
+ }
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
index 9e09eb88..df8f45d9 100644
--- a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
+++ b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
@@ -1,265 +1,265 @@
-<?php
-/**
- * TActiveCustomValidator class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-Prado::using('System.Web.UI.ActiveControls.TCallbackClientSide');
-
-/**
- * TActiveCustomValidator Class
- *
- * Performs custom validation using only server-side {@link onServerValidate onServerValidate}
- * validation event. The client-side uses callbacks to raise
- * the {@link onServerValidate onServerValidate} event.
- *
- * Beware that the {@link onServerValidate onServerValidate} may be
- * raised when the control to validate on the client side
- * changes value, that is, the server validation may be called many times.
- *
- * After the callback or postback, the {@link onServerValidate onServerValidate}
- * is raised once more. The {@link getIsCallback IsCallback} property
- * will be true when validation is made during a callback request.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TActiveCustomValidator extends TCustomValidator
- implements ICallbackEventHandler, IActiveControl
-{
- /**
- * @var boolean true if validation is made during a callback request.
- */
- private $_isCallback = false;
-
- /**
- * @return boolean true if validation is made during a callback request.
- */
- public function getIsCallback()
- {
- return $this->_isCallback;
- }
-
- /**
- * Creates a new callback control, sets the adapter to
- * TActiveControlAdapter. If you override this class, be sure to set the
- * adapter appropriately by, for example, by calling this constructor.
- */
- public function __construct()
- {
- parent::__construct();
- $this->setAdapter(new TActiveControlAdapter($this));
- $this->getActiveControl()->setClientSide(new TActiveCustomValidatorClientSide);
- }
-
- /**
- * @return TBaseActiveCallbackControl standard callback control options.
- */
- public function getActiveControl()
- {
- return $this->getAdapter()->getBaseActiveControl();
- }
-
- /**
- * @return TCallbackClientSide client side request options.
- */
- public function getClientSide()
- {
- return $this->getAdapter()->getBaseActiveControl()->getClientSide();
- }
-
- /**
- * Client validation function is NOT supported.
- */
- public function setClientValidationFunction($value)
- {
- throw new TNotSupportedException('tactivecustomvalidator_clientfunction_unsupported',
- get_class($this));
- }
-
- /**
- * Raises the callback event. This method is required by {@link
- * ICallbackEventHandler} interface. The {@link onServerValidate
- * OnServerValidate} event is raised first and then the
- * {@link onCallback OnCallback} event.
- * This method is mainly used by framework and control developers.
- * @param TCallbackEventParameter the event parameter
- */
- public function raiseCallbackEvent($param)
- {
- $this->_isCallback = true;
- $result = $this->onServerValidate($param->getCallbackParameter());
- $param->setResponseData($result);
- $this->onCallback($param);
- }
-
- /**
- * @param boolean whether the value is valid; this method will trigger a clientside update if needed
- */
- public function setIsValid($value)
- {
- parent::setIsValid($value);
- if($this->getActiveControl()->canUpdateClientSide())
- {
- $client = $this->getPage()->getCallbackClient();
- $func = 'Prado.Validation.updateActiveCustomValidator';
- $client->callClientFunction($func, array($this, $value));
- }
- }
-
- /**
- * This method is invoked when a callback is requested. The method raises
- * 'OnCallback' event to fire up the event handlers. If you override this
- * method, be sure to call the parent implementation so that the event
- * handler can be invoked.
- * @param TCallbackEventParameter event parameter to be passed to the event handlers
- */
- public function onCallback($param)
- {
- $this->raiseEvent('OnCallback', $this, $param);
- }
-
- /**
- * Returns an array of javascript validator options.
- * @return array javascript validator options.
- */
- protected function getClientScriptOptions()
- {
- $options=TBaseValidator::getClientScriptOptions();
- $options['EventTarget'] = $this->getUniqueID();
- return $options;
- }
-
- /**
- * Sets the text for the error message. Updates client-side erorr message.
- * @param string the error message
- */
- public function setErrorMessage($value)
- {
- parent::setErrorMessage($value);
- if($this->getActiveControl()->canUpdateClientSide())
- {
- $client = $this->getPage()->getCallbackClient();
- $func = 'Prado.Validation.setErrorMessage';
- $client->callClientFunction($func, array($this, $value));
- }
- }
-
-
- /**
- * It's mandatory for the EnableClientScript to be activated or the TActiveCustomValidator won't work.
- * @return boolean whether client-side validation is enabled.
- */
- public function getEnableClientScript()
- {
- return true;
- }
-
- /**
- * Ensure that the ID attribute is rendered and registers the javascript code
- * for initializing the active control.
- */
- protected function addAttributesToRender($writer)
- {
- parent::addAttributesToRender($writer);
- TBaseValidator::registerClientScriptValidator();
- }
-
- /**
- * @return string corresponding javascript class name for this this.
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TActiveCustomValidator';
- }
-}
-
-/**
- * Custom Validator callback client side options class.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TActiveCustomValidatorClientSide extends TCallbackClientSide
-{
- /**
- * @return string javascript code for client-side OnValidate event.
- */
- public function getOnValidate()
- {
- return $this->getOption('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->setFunction('OnValidate', $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 setOnValidationSuccess($javascript)
- {
- $this->setFunction('OnValidationSuccess', $javascript);
- }
-
- /**
- * @return string javascript code for client-side OnSuccess event.
- */
- public function getOnValidationSuccess()
- {
- return $this->getOption('OnValidationSuccess');
- }
-
- /**
- * 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 setOnValidationError($javascript)
- {
- $this->setFunction('OnValidationError', $javascript);
- }
-
- /**
- * @return string javascript code for client-side OnError event.
- */
- public function getOnValidationError()
- {
- return $this->getOption('OnValidationError');
- }
-
- /**
- * @param boolean true to revalidate when the control to validate changes value.
- */
- public function setObserveChanges($value)
- {
- $this->setOption('ObserveChanges', TPropertyValue::ensureBoolean($value));
- }
-
- /**
- * @return boolean true to observe changes.
- */
- public function getObserveChanges()
- {
- $changes = $this->getOption('ObserveChanges');
- return ($changes===null) ? true : $changes;
- }
-}
+<?php
+/**
+ * TActiveCustomValidator class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TCallbackClientSide');
+
+/**
+ * TActiveCustomValidator Class
+ *
+ * Performs custom validation using only server-side {@link onServerValidate onServerValidate}
+ * validation event. The client-side uses callbacks to raise
+ * the {@link onServerValidate onServerValidate} event.
+ *
+ * Beware that the {@link onServerValidate onServerValidate} may be
+ * raised when the control to validate on the client side
+ * changes value, that is, the server validation may be called many times.
+ *
+ * After the callback or postback, the {@link onServerValidate onServerValidate}
+ * is raised once more. The {@link getIsCallback IsCallback} property
+ * will be true when validation is made during a callback request.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TActiveCustomValidator extends TCustomValidator
+ implements ICallbackEventHandler, IActiveControl
+{
+ /**
+ * @var boolean true if validation is made during a callback request.
+ */
+ private $_isCallback = false;
+
+ /**
+ * @return boolean true if validation is made during a callback request.
+ */
+ public function getIsCallback()
+ {
+ return $this->_isCallback;
+ }
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ $this->getActiveControl()->setClientSide(new TActiveCustomValidatorClientSide);
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
+ * Client validation function is NOT supported.
+ */
+ public function setClientValidationFunction($value)
+ {
+ throw new TNotSupportedException('tactivecustomvalidator_clientfunction_unsupported',
+ get_class($this));
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface. The {@link onServerValidate
+ * OnServerValidate} event is raised first and then the
+ * {@link onCallback OnCallback} event.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->_isCallback = true;
+ $result = $this->onServerValidate($param->getCallbackParameter());
+ $param->setResponseData($result);
+ $this->onCallback($param);
+ }
+
+ /**
+ * @param boolean whether the value is valid; this method will trigger a clientside update if needed
+ */
+ public function setIsValid($value)
+ {
+ parent::setIsValid($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ {
+ $client = $this->getPage()->getCallbackClient();
+ $func = 'Prado.Validation.updateActiveCustomValidator';
+ $client->callClientFunction($func, array($this, $value));
+ }
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * Returns an array of javascript validator options.
+ * @return array javascript validator options.
+ */
+ protected function getClientScriptOptions()
+ {
+ $options=TBaseValidator::getClientScriptOptions();
+ $options['EventTarget'] = $this->getUniqueID();
+ return $options;
+ }
+
+ /**
+ * Sets the text for the error message. Updates client-side erorr message.
+ * @param string the error message
+ */
+ public function setErrorMessage($value)
+ {
+ parent::setErrorMessage($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ {
+ $client = $this->getPage()->getCallbackClient();
+ $func = 'Prado.Validation.setErrorMessage';
+ $client->callClientFunction($func, array($this, $value));
+ }
+ }
+
+
+ /**
+ * It's mandatory for the EnableClientScript to be activated or the TActiveCustomValidator won't work.
+ * @return boolean whether client-side validation is enabled.
+ */
+ public function getEnableClientScript()
+ {
+ return true;
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+ TBaseValidator::registerClientScriptValidator();
+ }
+
+ /**
+ * @return string corresponding javascript class name for this this.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TActiveCustomValidator';
+ }
+}
+
+/**
+ * Custom Validator callback client side options class.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TActiveCustomValidatorClientSide extends TCallbackClientSide
+{
+ /**
+ * @return string javascript code for client-side OnValidate event.
+ */
+ public function getOnValidate()
+ {
+ return $this->getOption('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->setFunction('OnValidate', $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 setOnValidationSuccess($javascript)
+ {
+ $this->setFunction('OnValidationSuccess', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side OnSuccess event.
+ */
+ public function getOnValidationSuccess()
+ {
+ return $this->getOption('OnValidationSuccess');
+ }
+
+ /**
+ * 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 setOnValidationError($javascript)
+ {
+ $this->setFunction('OnValidationError', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side OnError event.
+ */
+ public function getOnValidationError()
+ {
+ return $this->getOption('OnValidationError');
+ }
+
+ /**
+ * @param boolean true to revalidate when the control to validate changes value.
+ */
+ public function setObserveChanges($value)
+ {
+ $this->setOption('ObserveChanges', TPropertyValue::ensureBoolean($value));
+ }
+
+ /**
+ * @return boolean true to observe changes.
+ */
+ public function getObserveChanges()
+ {
+ $changes = $this->getOption('ObserveChanges');
+ return ($changes===null) ? true : $changes;
+ }
+}
diff --git a/framework/Web/UI/ActiveControls/TActiveLabel.php b/framework/Web/UI/ActiveControls/TActiveLabel.php
index 32d91cd2..c05b1744 100644
--- a/framework/Web/UI/ActiveControls/TActiveLabel.php
+++ b/framework/Web/UI/ActiveControls/TActiveLabel.php
@@ -80,7 +80,7 @@ class TActiveLabel extends TLabel implements IActiveControl
/**
* Adds attribute id to the renderer.
- * @param THtmlWriter the writer used for the rendering purpose
+ * @param THtmlWriter the writer used for the rendering purpose
*/
protected function addAttributesToRender($writer) {
$writer->addAttribute('id',$this->getClientID());
diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
index 726dd8ba..144f621e 100644
--- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
@@ -1,401 +1,401 @@
-<?php
-/**
- * TActivePageAdapter, TCallbackErrorHandler and TInvalidCallbackException class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @author Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering)
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 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>
- * @author Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering)
- * @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';
- /**
- * Script list header name.
- */
- const CALLBACK_SCRIPTLIST_HEADER = 'X-PRADO-SCRIPTLIST';
- /**
- * Stylesheet list header name.
- */
- const CALLBACK_STYLESHEETLIST_HEADER = 'X-PRADO-STYLESHEETLIST';
- /**
- * Hidden field list header name.
- */
- const CALLBACK_HIDDENFIELDLIST_HEADER = 'X-PRADO-HIDDENFIELDLIST';
-
- /**
- * 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);
-
-
- $cs = $this->Page->getClientScript();
-
- // collect all stylesheet file references
- $stylesheets = $cs->getStyleSheetUrls();
- if (count($stylesheets)>0)
- $this->appendContentPart($response, self::CALLBACK_STYLESHEETLIST_HEADER, TJavaScript::jsonEncode($stylesheets));
-
- // collect all script file references
- $scripts = $cs->getScriptUrls();
- if (count($scripts)>0)
- $this->appendContentPart($response, self::CALLBACK_SCRIPTLIST_HEADER, TJavaScript::jsonEncode($scripts));
-
- // collect all hidden field references
- $fields = $cs->getHiddenFields();
- if (count($fields)>0)
- $this->appendContentPart($response, self::CALLBACK_HIDDENFIELDLIST_HEADER, TJavaScript::jsonEncode($fields));
- }
-
- /**
- * 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->setStatusCode(500, 'Internal Server 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 Server Error', true, 500);
- }
- $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>
+ * @author Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering)
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 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>
+ * @author Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering)
+ * @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';
+ /**
+ * Script list header name.
+ */
+ const CALLBACK_SCRIPTLIST_HEADER = 'X-PRADO-SCRIPTLIST';
+ /**
+ * Stylesheet list header name.
+ */
+ const CALLBACK_STYLESHEETLIST_HEADER = 'X-PRADO-STYLESHEETLIST';
+ /**
+ * Hidden field list header name.
+ */
+ const CALLBACK_HIDDENFIELDLIST_HEADER = 'X-PRADO-HIDDENFIELDLIST';
+
+ /**
+ * 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);
+
+
+ $cs = $this->Page->getClientScript();
+
+ // collect all stylesheet file references
+ $stylesheets = $cs->getStyleSheetUrls();
+ if (count($stylesheets)>0)
+ $this->appendContentPart($response, self::CALLBACK_STYLESHEETLIST_HEADER, TJavaScript::jsonEncode($stylesheets));
+
+ // collect all script file references
+ $scripts = $cs->getScriptUrls();
+ if (count($scripts)>0)
+ $this->appendContentPart($response, self::CALLBACK_SCRIPTLIST_HEADER, TJavaScript::jsonEncode($scripts));
+
+ // collect all hidden field references
+ $fields = $cs->getHiddenFields();
+ if (count($fields)>0)
+ $this->appendContentPart($response, self::CALLBACK_HIDDENFIELDLIST_HEADER, TJavaScript::jsonEncode($fields));
+ }
+
+ /**
+ * 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->setStatusCode(500, 'Internal Server 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 Server Error', true, 500);
+ }
+ $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 ae1dd09f..1edfa57c 100644
--- a/framework/Web/UI/ActiveControls/TActivePanel.php
+++ b/framework/Web/UI/ActiveControls/TActivePanel.php
@@ -1,100 +1,100 @@
-<?php
-/**
- * TActivePanel file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * Load active control adapter.
- */
-Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
-
-/**
- * TActivePanel is the TPanel active control counterpart.
- *
- * TActivePanel allows the client-side panel contents to be updated during a
- * callback response using the {@link render} method.
- *
- * Example: Assume $param is an instance of TCallbackEventParameter attached to
- * the OnCallback event of a TCallback with ID "callback1", and
- * "panel1" is the ID of a TActivePanel.
- * <code>
- * function callback1_requested($sender, $param)
- * {
- * $this->panel1->render($param->getNewWriter());
- * }
- * </code>
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TActivePanel extends TPanel implements IActiveControl
-{
- /**
- * Creates a new callback control, sets the adapter to
- * TActiveControlAdapter. If you override this class, be sure to set the
- * adapter appropriately by, for example, by calling this constructor.
- */
- public function __construct()
- {
- parent::__construct();
- $this->setAdapter(new TActiveControlAdapter($this));
- }
-
- /**
- * @return TBaseActiveControl standard active control options.
- */
- public function getActiveControl()
- {
- return $this->getAdapter()->getBaseActiveControl();
- }
-
- /**
- * 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
- * is defered until OnPreRender event is raised.
- * @param THtmlWriter html writer
- */
- public function render($writer)
- {
- if($this->getHasPreRendered())
- {
- parent::render($writer);
- if($this->getActiveControl()->canUpdateClientSide())
- $this->getPage()->getCallbackClient()->replaceContent($this,$writer);
- }
- 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);
- }
- }
- }
- }
-}
-
+<?php
+/**
+ * TActivePanel file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load active control adapter.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
+
+/**
+ * TActivePanel is the TPanel active control counterpart.
+ *
+ * TActivePanel allows the client-side panel contents to be updated during a
+ * callback response using the {@link render} method.
+ *
+ * Example: Assume $param is an instance of TCallbackEventParameter attached to
+ * the OnCallback event of a TCallback with ID "callback1", and
+ * "panel1" is the ID of a TActivePanel.
+ * <code>
+ * function callback1_requested($sender, $param)
+ * {
+ * $this->panel1->render($param->getNewWriter());
+ * }
+ * </code>
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TActivePanel extends TPanel implements IActiveControl
+{
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveControl standard active control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * 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
+ * is defered until OnPreRender event is raised.
+ * @param THtmlWriter html writer
+ */
+ public function render($writer)
+ {
+ if($this->getHasPreRendered())
+ {
+ parent::render($writer);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->replaceContent($this,$writer);
+ }
+ 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);
+ }
+ }
+ }
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TActiveRatingList.php b/framework/Web/UI/ActiveControls/TActiveRatingList.php
index 7c878dd8..81f50dd1 100644
--- a/framework/Web/UI/ActiveControls/TActiveRatingList.php
+++ b/framework/Web/UI/ActiveControls/TActiveRatingList.php
@@ -1,133 +1,133 @@
-<?php
-/**
- * TActiveRatingList class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * TActiveRatingList Class
- *
- * Displays clickable images that represent a TRadioButtonList
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TActiveRatingList extends TRatingList implements IActiveControl, ICallbackEventHandler
-{
- /**
- * Creates a new callback control, sets the adapter to
- * TActiveListControlAdapter. If you override this class, be sure to set the
- * adapter appropriately by, for example, by calling this constructor.
- */
- public function __construct()
- {
- $this->setAdapter(new TActiveListControlAdapter($this));
- $this->setAutoPostBack(true);
- parent::__construct();
- }
-
- /**
- * @return TBaseActiveCallbackControl standard callback control options.
- */
- public function getActiveControl()
- {
- return $this->getAdapter()->getBaseActiveControl();
- }
-
- /**
- * @return TCallbackClientSide client side request options.
- */
- public function getClientSide()
- {
- return $this->getAdapter()->getBaseActiveControl()->getClientSide();
- }
-
- /**
- * Raises the callback event. This method is required by {@link
- * ICallbackEventHandler} interface.
- * This method is mainly used by framework and control developers.
- * @param TCallbackEventParameter the event parameter
- */
- public function raiseCallbackEvent($param)
- {
- $this->onCallback($param);
- }
-
- /**
- * This method is invoked when a callback is requested. The method raises
- * 'OnCallback' event to fire up the event handlers. If you override this
- * method, be sure to call the parent implementation so that the event
- * handler can be invoked.
- * @param TCallbackEventParameter event parameter to be passed to the event handlers
- */
- public function onCallback($param)
- {
- $this->raiseEvent('OnCallback', $this, $param);
- }
-
- /**
- * @param boolean whether the items in the column can be edited
- */
- public function setReadOnly($value)
- {
- parent::setReadOnly($value);
- $value = $this->getReadOnly();
- $this->callClientFunction('setReadOnly',$value);
- }
-
- /**
- * @param float rating value, also sets the selected Index
- */
- public function setRating($value)
- {
- parent::setRating($value);
- $value = $this->getRating();
- $this->callClientFunction('setRating',$value);
- }
-
- /**
- * Calls the client-side static method for this control class.
- * @param string static method name
- * @param mixed method parmaeter
- */
- protected function callClientFunction($func,$value)
- {
- if($this->getActiveControl()->canUpdateClientSide())
- {
- $client = $this->getPage()->getCallbackClient();
- $code = parent::getClientClassName().'.'.$func;
- $client->callClientFunction($code,array($this,$value));
- }
- }
-
- /**
- * @param string caption text
- */
- public function setCaption($value)
- {
- parent::setCaption($value);
- // if it's an active control, this should not be needed.
- $this->callClientFunction('setCaption',$value);
- }
-
- /**
- * 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.TActiveRatingList';
- }
-}
-
+<?php
+/**
+ * TActiveRatingList class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * TActiveRatingList Class
+ *
+ * Displays clickable images that represent a TRadioButtonList
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TActiveRatingList extends TRatingList implements IActiveControl, ICallbackEventHandler
+{
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveListControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ $this->setAdapter(new TActiveListControlAdapter($this));
+ $this->setAutoPostBack(true);
+ parent::__construct();
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * @param boolean whether the items in the column can be edited
+ */
+ public function setReadOnly($value)
+ {
+ parent::setReadOnly($value);
+ $value = $this->getReadOnly();
+ $this->callClientFunction('setReadOnly',$value);
+ }
+
+ /**
+ * @param float rating value, also sets the selected Index
+ */
+ public function setRating($value)
+ {
+ parent::setRating($value);
+ $value = $this->getRating();
+ $this->callClientFunction('setRating',$value);
+ }
+
+ /**
+ * Calls the client-side static method for this control class.
+ * @param string static method name
+ * @param mixed method parmaeter
+ */
+ protected function callClientFunction($func,$value)
+ {
+ if($this->getActiveControl()->canUpdateClientSide())
+ {
+ $client = $this->getPage()->getCallbackClient();
+ $code = parent::getClientClassName().'.'.$func;
+ $client->callClientFunction($code,array($this,$value));
+ }
+ }
+
+ /**
+ * @param string caption text
+ */
+ public function setCaption($value)
+ {
+ parent::setCaption($value);
+ // if it's an active control, this should not be needed.
+ $this->callClientFunction('setCaption',$value);
+ }
+
+ /**
+ * 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.TActiveRatingList';
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TActiveTextBox.php b/framework/Web/UI/ActiveControls/TActiveTextBox.php
index 1e2fc46f..562f59cd 100644
--- a/framework/Web/UI/ActiveControls/TActiveTextBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveTextBox.php
@@ -1,125 +1,125 @@
-<?php
-/**
- * TActiveTextBox class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * Load active control adapter.
- */
-Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
-
-/**
- * TActiveTextBox class.
- *
- * TActiveTextBox allows the {@link setText Text} property of the textbox to
- * be changed during callback. When {@link setAutoPostBack AutoPostBack} property
- * is true, changes to the textbox contents will perform a callback request causing
- * {@link onTextChanged OnTextChanged} to be fired first followed by {@link onCallback OnCallback}
- * event.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveControl
-{
- /**
- * Creates a new callback control, sets the adapter to
- * TActiveControlAdapter. If you override this class, be sure to set the
- * adapter appropriately by, for example, by calling this constructor.
- */
- public function __construct()
- {
- parent::__construct();
- $this->setAdapter(new TActiveControlAdapter($this));
- }
-
- /**
- * @return TBaseActiveCallbackControl standard callback control options.
- */
- public function getActiveControl()
- {
- return $this->getAdapter()->getBaseActiveControl();
- }
-
- /**
- * @return TCallbackClientSide client side request options.
- */
- public function getClientSide()
- {
- return $this->getAdapter()->getBaseActiveControl()->getClientSide();
- }
-
- /**
- * Client-side Text property can only be updated after the OnLoad stage.
- * @param string text content for the textbox
- */
- public function setText($value)
- {
- parent::setText($value);
- if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData())
- $this->getPage()->getCallbackClient()->setValue($this, $value);
- }
-
- /**
- * Raises the callback event. This method is required by {@link
- * ICallbackEventHandler} interface.
- * This method is mainly used by framework and control developers.
- * @param TCallbackEventParameter the event parameter
- */
- public function raiseCallbackEvent($param)
- {
- $this->onCallback($param);
- }
-
- /**
- * This method is invoked when a callback is requested. The method raises
- * 'OnCallback' event to fire up the event handlers. If you override this
- * method, be sure to call the parent implementation so that the event
- * handler can be invoked.
- * @param TCallbackEventParameter event parameter to be passed to the event handlers
- */
- public function onCallback($param)
- {
- $this->raiseEvent('OnCallback', $this, $param);
- }
-
- /**
- * 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.TActiveTextBox';
- }
-
- /**
- * Override parent implementation, no javascript is rendered here instead
- * the javascript required for active control is registered in {@link addAttributesToRender}.
- */
- protected function renderClientControlScript($writer)
- {
- }
-
- /**
- * Ensure that the ID attribute is rendered and registers the javascript code
- * for initializing the active control.
- */
- protected function addAttributesToRender($writer)
- {
- parent::addAttributesToRender($writer);
- $writer->addAttribute('id',$this->getClientID());
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
- }
-}
-
+<?php
+/**
+ * TActiveTextBox class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load active control adapter.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
+
+/**
+ * TActiveTextBox class.
+ *
+ * TActiveTextBox allows the {@link setText Text} property of the textbox to
+ * be changed during callback. When {@link setAutoPostBack AutoPostBack} property
+ * is true, changes to the textbox contents will perform a callback request causing
+ * {@link onTextChanged OnTextChanged} to be fired first followed by {@link onCallback OnCallback}
+ * event.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveControl
+{
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
+ * Client-side Text property can only be updated after the OnLoad stage.
+ * @param string text content for the textbox
+ */
+ public function setText($value)
+ {
+ parent::setText($value);
+ if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData())
+ $this->getPage()->getCallbackClient()->setValue($this, $value);
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * 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.TActiveTextBox';
+ }
+
+ /**
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getClientID());
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php
index 413d5c21..ce648b02 100644
--- a/framework/Web/UI/ActiveControls/TAutoComplete.php
+++ b/framework/Web/UI/ActiveControls/TAutoComplete.php
@@ -1,440 +1,440 @@
-<?php
-/**
- * TAutoComplete class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * Load active text box.
- */
-Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
-Prado::using('System.Web.UI.ActiveControls.TCallbackEventParameter');
-
-/**
- * TAutoComplete class.
- *
- * TAutoComplete is a textbox that provides a list of suggestion on
- * the current partial word typed in the textbox. The suggestions are
- * requested using callbacks, and raises the {@link onSuggestion OnSuggestion}
- * event. The events of the TActiveText (from which TAutoComplete is extended from)
- * and {@link onSuggestion OnSuggestion} are mutually exculsive. That is,
- * if {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback}
- * events are raise, then {@link onSuggestion OnSuggestion} will not be raise, and
- * vice versa.
- *
- * The list of suggestions should be set in the {@link onSuggestion OnSuggestion}
- * event handler. The partial word to match the suggestion is in the
- * {@link TCallbackEventParameter::getCallbackParameter TCallbackEventParameter::CallbackParameter}
- * property. The datasource of the TAutoComplete must be set using {@link setDataSource}
- * method. This sets the datasource for the suggestions repeater, available through
- * the {@link getSuggestions Suggestions} property. Header, footer templates and
- * other properties of the repeater can be access via the {@link getSuggestions Suggestions}
- * property and its sub-properties.
- *
- * The {@link setTextCssClass TextCssClass} property if set is used to find
- * the element within the Suggestions.ItemTemplate and Suggestions.AlternatingItemTemplate
- * that contains the actual text for the suggestion selected. That is,
- * only text inside elements with CSS class name equal to {@link setTextCssClass TextCssClass}
- * will be used as suggestions.
- *
- * To return the list of suggestions back to the browser, supply a non-empty data source
- * and call databind. For example,
- * <code>
- * function autocomplete_suggestion($sender, $param)
- * {
- * $token = $param->getToken(); //the partial word to match
- * $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions
- * $sender->dataBind();
- * }
- * </code>
- *
- * The suggestion will be rendered when the {@link dataBind()} method is called
- * <strong>during a callback request</strong>.
- *
- * When an suggestion is selected, that is, when the use has clicked, pressed
- * the "Enter" key, or pressed the "Tab" key, the {@link onSuggestionSelected OnSuggestionSelected}
- * event is raised. The
- * {@link TCallbackEventParameter::getCallbackParameter TCallbackEventParameter::CallbackParameter}
- * property contains the index of the selected suggestion.
- *
- * 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}
- * and {@link setMinChars MinChars} properties sets the delay and minimum number
- * of characters typed, respectively, before requesting for sugggestions.
- *
- * Use {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback} events
- * to handle post backs due to {@link setAutoPostBack AutoPostBack}.
- *
- * In the {@link getSuggestions Suggestions} TRepater item template, all HTML text elements
- * are considered as text for the suggestion. Text within HTML elements with CSS class name
- * "informal" are ignored as text for suggestions.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TAutoComplete extends TActiveTextBox implements INamingContainer
-{
- /**
- * @var ITemplate template for repeater items
- */
- private $_repeater=null;
- /**
- * @var TPanel result panel holding the suggestion items.
- */
- private $_resultPanel=null;
-
- /**
- * @return string word or token separators (delimiters).
- */
- public function getSeparator()
- {
- return $this->getViewState('tokens', '');
- }
-
- /**
- * @return string word or token separators (delimiters).
- */
- public function setSeparator($value)
- {
- $this->setViewState('tokens', TPropertyValue::ensureString($value), '');
- }
-
- /**
- * @return float maximum delay (in seconds) before requesting a suggestion.
- */
- public function getFrequency()
- {
- return $this->getViewState('frequency', '');
- }
-
- /**
- * @param float maximum delay (in seconds) before requesting a suggestion.
- * Default is 0.4.
- */
- public function setFrequency($value)
- {
- $this->setViewState('frequency', TPropertyValue::ensureFloat($value),'');
- }
-
- /**
- * @return integer minimum number of characters before requesting a suggestion.
- */
- public function getMinChars()
- {
- return $this->getViewState('minChars','');
- }
-
- /**
- * @param integer minimum number of characters before requesting a suggestion.
- */
- public function setMinChars($value)
- {
- $this->setViewState('minChars', TPropertyValue::ensureInteger($value), '');
- }
-
- /**
- * @param string Css class name of the element to use for suggestion.
- */
- public function setTextCssClass($value)
- {
- $this->setViewState('TextCssClass', $value);
- }
-
- /**
- * @return string Css class name of the element to use for suggestion.
- */
- public function getTextCssClass()
- {
- return $this->getViewState('TextCssClass');
- }
-
- /**
- * Raises the callback event. This method is overrides the parent implementation.
- * If {@link setAutoPostBack AutoPostBack} is enabled it will raise
- * {@link onTextChanged OnTextChanged} event event and then the
- * {@link onCallback OnCallback} event. The {@link onSuggest OnSuggest} event is
- * raise if the request is to find sugggestions, the {@link onTextChanged OnTextChanged}
- * and {@link onCallback OnCallback} events are <b>NOT</b> raised.
- * This method is mainly used by framework and control developers.
- * @param TCallbackEventParameter the event parameter
- */
- public function raiseCallbackEvent($param)
- {
- $token = $param->getCallbackParameter();
- if(is_array($token) && count($token) == 2)
- {
- if($token[1] === '__TAutoComplete_onSuggest__')
- {
- $parameter = new TAutoCompleteEventParameter($this->getResponse(), $token[0]);
- $this->onSuggest($parameter);
- }
- else if($token[1] === '__TAutoComplete_onSuggestionSelected__')
- {
- $parameter = new TAutoCompleteEventParameter($this->getResponse(), null, $token[0]);
- $this->onSuggestionSelected($parameter);
- }
- }
- else if($this->getAutoPostBack())
- parent::raiseCallbackEvent($param);
- }
-
- /**
- * This method is invoked when an autocomplete suggestion is requested.
- * The method raises 'OnSuggest' event. If you override this
- * method, be sure to call the parent implementation so that the event
- * handler can be invoked.
- * @param TCallbackEventParameter event parameter to be passed to the event handlers
- */
- public function onSuggest($param)
- {
- $this->raiseEvent('OnSuggest', $this, $param);
- }
-
- /**
- * This method is invoked when an autocomplete suggestion is selected.
- * The method raises 'OnSuggestionSelected' event. If you override this
- * method, be sure to call the parent implementation so that the event
- * handler can be invoked.
- * @param TCallbackEventParameter event parameter to be passed to the event handlers
- */
- public function onSuggestionSelected($param)
- {
- $this->raiseEvent('OnSuggestionSelected', $this, $param);
- }
-
- /**
- * @param array data source for suggestions.
- */
- public function setDataSource($data)
- {
- $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.
- */
- public function getResultPanel()
- {
- if($this->_resultPanel===null)
- $this->_resultPanel = $this->createResultPanel();
- return $this->_resultPanel;
- }
-
- /**
- * @return TPanel new instance of result panel. Default uses TPanel.
- */
- protected function createResultPanel()
- {
- $panel = Prado::createComponent('System.Web.UI.WebControls.TPanel');
- $this->getControls()->add($panel);
- $panel->setID('result');
- return $panel;
- }
-
- /**
- * @return TRepeater suggestion list repeater
- */
- public function getSuggestions()
- {
- if($this->_repeater===null)
- $this->_repeater = $this->createRepeater();
- return $this->_repeater;
- }
-
- /**
- * @return TRepeater new instance of TRepater to render the list of suggestions.
- */
- protected function createRepeater()
- {
- $repeater = Prado::createComponent('System.Web.UI.WebControls.TRepeater');
- $repeater->setHeaderTemplate(new TAutoCompleteTemplate('<ul>'));
- $repeater->setFooterTemplate(new TAutoCompleteTemplate('</ul>'));
- $repeater->setItemTemplate(new TTemplate('<li><%# $this->DataItem %></li>',null));
- $this->getControls()->add($repeater);
- return $repeater;
- }
-
- /**
- * Renders the end tag and registers javascript effects library.
- */
- public function renderEndTag($writer)
- {
- $this->getPage()->getClientScript()->registerPradoScript('effects');
- parent::renderEndTag($writer);
- $this->renderResultPanel($writer);
- }
-
- /**
- * Renders the result panel.
- * @param THtmlWriter the renderer.
- */
- protected function renderResultPanel($writer)
- {
- $this->getResultPanel()->render($writer);
- }
-
- /**
- * Renders the suggestions during a callback respones.
- * @param THtmlWriter the renderer.
- */
- public function renderCallback($writer)
- {
- $this->renderSuggestions($writer);
- }
-
- /**
- * Renders the suggestions repeater.
- * @param THtmlWriter the renderer.
- */
- public function renderSuggestions($writer)
- {
- if($this->getActiveControl()->canUpdateClientSide())
- {
- $this->getSuggestions()->render($writer);
- $boundary = $writer->getWriter()->getBoundary();
- $this->getResponse()->getAdapter()->setResponseData($boundary);
- }
- }
-
- /**
- * @return array list of callback options.
- */
- protected function getPostBackOptions()
- {
- //disallow page state update ?
- //$this->getActiveControl()->getClientSide()->setEnablePageStateUpdate(false);
- $options = array();
- if(strlen($string = $this->getSeparator()))
- {
- $string = strtr($string,array('\t'=>"\t",'\n'=>"\n",'\r'=>"\r"));
- $token = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
- $options['tokens'] = $token;
- }
- if($this->getAutoPostBack())
- {
- $options = array_merge($options,parent::getPostBackOptions());
- $options['AutoPostBack'] = true;
- }
- if(strlen($select = $this->getTextCssClass()))
- $options['select'] = $select;
- $options['ResultPanel'] = $this->getResultPanel()->getClientID();
- $options['ID'] = $this->getClientID();
- $options['EventTarget'] = $this->getUniqueID();
- if(($minchars=$this->getMinChars())!=='')
- $options['minChars'] = $minchars;
- if(($frequency=$this->getFrequency())!=='')
- $options['frequency'] = $frequency;
- $options['CausesValidation'] = $this->getCausesValidation();
- $options['ValidationGroup'] = $this->getValidationGroup();
- return $options;
- }
-
- /**
- * Override parent implementation, no javascript is rendered here instead
- * the javascript required for active control is registered in {@link addAttributesToRender}.
- */
- protected function renderClientControlScript($writer)
- {
- }
-
- /**
- * @return string corresponding javascript class name for this TActiveButton.
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TAutoComplete';
- }
-}
-
-/**
- * TAutCompleteEventParameter contains the {@link getToken Token} requested by
- * the user for a partial match of the suggestions.
- *
- * The {@link getSelectedIndex SelectedIndex} is a zero-based index of the
- * suggestion selected by the user, -1 if not suggestion is selected.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TAutoCompleteEventParameter extends TCallbackEventParameter
-{
- private $_selectedIndex=-1;
-
- /**
- * Creates a new TCallbackEventParameter.
- */
- public function __construct($response, $parameter, $index=-1)
- {
- parent::__construct($response, $parameter);
- $this->_selectedIndex=$index;
- }
-
- /**
- * @return int selected suggestion zero-based index, -1 if not selected.
- */
- public function getSelectedIndex()
- {
- return $this->_selectedIndex;
- }
-
- /**
- * @return string token for matching a list of suggestions.
- */
- public function getToken()
- {
- return $this->getCallbackParameter();
- }
-}
-
-/**
- * TAutoCompleteTemplate class.
- *
- * TAutoCompleteTemplate is the default template for TAutoCompleteTemplate
- * item template.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TAutoCompleteTemplate extends TComponent implements ITemplate
-{
- private $_template;
-
- public function __construct($template)
- {
- $this->_template = $template;
- }
- /**
- * Instantiates the template.
- * It creates a {@link TDataList} control.
- * @param TControl parent to hold the content within the template
- */
- public function instantiateIn($parent)
- {
- $parent->getControls()->add($this->_template);
- }
-}
-
+<?php
+/**
+ * TAutoComplete class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load active text box.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
+Prado::using('System.Web.UI.ActiveControls.TCallbackEventParameter');
+
+/**
+ * TAutoComplete class.
+ *
+ * TAutoComplete is a textbox that provides a list of suggestion on
+ * the current partial word typed in the textbox. The suggestions are
+ * requested using callbacks, and raises the {@link onSuggestion OnSuggestion}
+ * event. The events of the TActiveText (from which TAutoComplete is extended from)
+ * and {@link onSuggestion OnSuggestion} are mutually exculsive. That is,
+ * if {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback}
+ * events are raise, then {@link onSuggestion OnSuggestion} will not be raise, and
+ * vice versa.
+ *
+ * The list of suggestions should be set in the {@link onSuggestion OnSuggestion}
+ * event handler. The partial word to match the suggestion is in the
+ * {@link TCallbackEventParameter::getCallbackParameter TCallbackEventParameter::CallbackParameter}
+ * property. The datasource of the TAutoComplete must be set using {@link setDataSource}
+ * method. This sets the datasource for the suggestions repeater, available through
+ * the {@link getSuggestions Suggestions} property. Header, footer templates and
+ * other properties of the repeater can be access via the {@link getSuggestions Suggestions}
+ * property and its sub-properties.
+ *
+ * The {@link setTextCssClass TextCssClass} property if set is used to find
+ * the element within the Suggestions.ItemTemplate and Suggestions.AlternatingItemTemplate
+ * that contains the actual text for the suggestion selected. That is,
+ * only text inside elements with CSS class name equal to {@link setTextCssClass TextCssClass}
+ * will be used as suggestions.
+ *
+ * To return the list of suggestions back to the browser, supply a non-empty data source
+ * and call databind. For example,
+ * <code>
+ * function autocomplete_suggestion($sender, $param)
+ * {
+ * $token = $param->getToken(); //the partial word to match
+ * $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions
+ * $sender->dataBind();
+ * }
+ * </code>
+ *
+ * The suggestion will be rendered when the {@link dataBind()} method is called
+ * <strong>during a callback request</strong>.
+ *
+ * When an suggestion is selected, that is, when the use has clicked, pressed
+ * the "Enter" key, or pressed the "Tab" key, the {@link onSuggestionSelected OnSuggestionSelected}
+ * event is raised. The
+ * {@link TCallbackEventParameter::getCallbackParameter TCallbackEventParameter::CallbackParameter}
+ * property contains the index of the selected suggestion.
+ *
+ * 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}
+ * and {@link setMinChars MinChars} properties sets the delay and minimum number
+ * of characters typed, respectively, before requesting for sugggestions.
+ *
+ * Use {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback} events
+ * to handle post backs due to {@link setAutoPostBack AutoPostBack}.
+ *
+ * In the {@link getSuggestions Suggestions} TRepater item template, all HTML text elements
+ * are considered as text for the suggestion. Text within HTML elements with CSS class name
+ * "informal" are ignored as text for suggestions.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TAutoComplete extends TActiveTextBox implements INamingContainer
+{
+ /**
+ * @var ITemplate template for repeater items
+ */
+ private $_repeater=null;
+ /**
+ * @var TPanel result panel holding the suggestion items.
+ */
+ private $_resultPanel=null;
+
+ /**
+ * @return string word or token separators (delimiters).
+ */
+ public function getSeparator()
+ {
+ return $this->getViewState('tokens', '');
+ }
+
+ /**
+ * @return string word or token separators (delimiters).
+ */
+ public function setSeparator($value)
+ {
+ $this->setViewState('tokens', TPropertyValue::ensureString($value), '');
+ }
+
+ /**
+ * @return float maximum delay (in seconds) before requesting a suggestion.
+ */
+ public function getFrequency()
+ {
+ return $this->getViewState('frequency', '');
+ }
+
+ /**
+ * @param float maximum delay (in seconds) before requesting a suggestion.
+ * Default is 0.4.
+ */
+ public function setFrequency($value)
+ {
+ $this->setViewState('frequency', TPropertyValue::ensureFloat($value),'');
+ }
+
+ /**
+ * @return integer minimum number of characters before requesting a suggestion.
+ */
+ public function getMinChars()
+ {
+ return $this->getViewState('minChars','');
+ }
+
+ /**
+ * @param integer minimum number of characters before requesting a suggestion.
+ */
+ public function setMinChars($value)
+ {
+ $this->setViewState('minChars', TPropertyValue::ensureInteger($value), '');
+ }
+
+ /**
+ * @param string Css class name of the element to use for suggestion.
+ */
+ public function setTextCssClass($value)
+ {
+ $this->setViewState('TextCssClass', $value);
+ }
+
+ /**
+ * @return string Css class name of the element to use for suggestion.
+ */
+ public function getTextCssClass()
+ {
+ return $this->getViewState('TextCssClass');
+ }
+
+ /**
+ * Raises the callback event. This method is overrides the parent implementation.
+ * If {@link setAutoPostBack AutoPostBack} is enabled it will raise
+ * {@link onTextChanged OnTextChanged} event event and then the
+ * {@link onCallback OnCallback} event. The {@link onSuggest OnSuggest} event is
+ * raise if the request is to find sugggestions, the {@link onTextChanged OnTextChanged}
+ * and {@link onCallback OnCallback} events are <b>NOT</b> raised.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $token = $param->getCallbackParameter();
+ if(is_array($token) && count($token) == 2)
+ {
+ if($token[1] === '__TAutoComplete_onSuggest__')
+ {
+ $parameter = new TAutoCompleteEventParameter($this->getResponse(), $token[0]);
+ $this->onSuggest($parameter);
+ }
+ else if($token[1] === '__TAutoComplete_onSuggestionSelected__')
+ {
+ $parameter = new TAutoCompleteEventParameter($this->getResponse(), null, $token[0]);
+ $this->onSuggestionSelected($parameter);
+ }
+ }
+ else if($this->getAutoPostBack())
+ parent::raiseCallbackEvent($param);
+ }
+
+ /**
+ * This method is invoked when an autocomplete suggestion is requested.
+ * The method raises 'OnSuggest' event. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onSuggest($param)
+ {
+ $this->raiseEvent('OnSuggest', $this, $param);
+ }
+
+ /**
+ * This method is invoked when an autocomplete suggestion is selected.
+ * The method raises 'OnSuggestionSelected' event. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onSuggestionSelected($param)
+ {
+ $this->raiseEvent('OnSuggestionSelected', $this, $param);
+ }
+
+ /**
+ * @param array data source for suggestions.
+ */
+ public function setDataSource($data)
+ {
+ $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.
+ */
+ public function getResultPanel()
+ {
+ if($this->_resultPanel===null)
+ $this->_resultPanel = $this->createResultPanel();
+ return $this->_resultPanel;
+ }
+
+ /**
+ * @return TPanel new instance of result panel. Default uses TPanel.
+ */
+ protected function createResultPanel()
+ {
+ $panel = Prado::createComponent('System.Web.UI.WebControls.TPanel');
+ $this->getControls()->add($panel);
+ $panel->setID('result');
+ return $panel;
+ }
+
+ /**
+ * @return TRepeater suggestion list repeater
+ */
+ public function getSuggestions()
+ {
+ if($this->_repeater===null)
+ $this->_repeater = $this->createRepeater();
+ return $this->_repeater;
+ }
+
+ /**
+ * @return TRepeater new instance of TRepater to render the list of suggestions.
+ */
+ protected function createRepeater()
+ {
+ $repeater = Prado::createComponent('System.Web.UI.WebControls.TRepeater');
+ $repeater->setHeaderTemplate(new TAutoCompleteTemplate('<ul>'));
+ $repeater->setFooterTemplate(new TAutoCompleteTemplate('</ul>'));
+ $repeater->setItemTemplate(new TTemplate('<li><%# $this->DataItem %></li>',null));
+ $this->getControls()->add($repeater);
+ return $repeater;
+ }
+
+ /**
+ * Renders the end tag and registers javascript effects library.
+ */
+ public function renderEndTag($writer)
+ {
+ $this->getPage()->getClientScript()->registerPradoScript('effects');
+ parent::renderEndTag($writer);
+ $this->renderResultPanel($writer);
+ }
+
+ /**
+ * Renders the result panel.
+ * @param THtmlWriter the renderer.
+ */
+ protected function renderResultPanel($writer)
+ {
+ $this->getResultPanel()->render($writer);
+ }
+
+ /**
+ * Renders the suggestions during a callback respones.
+ * @param THtmlWriter the renderer.
+ */
+ public function renderCallback($writer)
+ {
+ $this->renderSuggestions($writer);
+ }
+
+ /**
+ * Renders the suggestions repeater.
+ * @param THtmlWriter the renderer.
+ */
+ public function renderSuggestions($writer)
+ {
+ if($this->getActiveControl()->canUpdateClientSide())
+ {
+ $this->getSuggestions()->render($writer);
+ $boundary = $writer->getWriter()->getBoundary();
+ $this->getResponse()->getAdapter()->setResponseData($boundary);
+ }
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ //disallow page state update ?
+ //$this->getActiveControl()->getClientSide()->setEnablePageStateUpdate(false);
+ $options = array();
+ if(strlen($string = $this->getSeparator()))
+ {
+ $string = strtr($string,array('\t'=>"\t",'\n'=>"\n",'\r'=>"\r"));
+ $token = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
+ $options['tokens'] = $token;
+ }
+ if($this->getAutoPostBack())
+ {
+ $options = array_merge($options,parent::getPostBackOptions());
+ $options['AutoPostBack'] = true;
+ }
+ if(strlen($select = $this->getTextCssClass()))
+ $options['select'] = $select;
+ $options['ResultPanel'] = $this->getResultPanel()->getClientID();
+ $options['ID'] = $this->getClientID();
+ $options['EventTarget'] = $this->getUniqueID();
+ if(($minchars=$this->getMinChars())!=='')
+ $options['minChars'] = $minchars;
+ if(($frequency=$this->getFrequency())!=='')
+ $options['frequency'] = $frequency;
+ $options['CausesValidation'] = $this->getCausesValidation();
+ $options['ValidationGroup'] = $this->getValidationGroup();
+ return $options;
+ }
+
+ /**
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ }
+
+ /**
+ * @return string corresponding javascript class name for this TActiveButton.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TAutoComplete';
+ }
+}
+
+/**
+ * TAutCompleteEventParameter contains the {@link getToken Token} requested by
+ * the user for a partial match of the suggestions.
+ *
+ * The {@link getSelectedIndex SelectedIndex} is a zero-based index of the
+ * suggestion selected by the user, -1 if not suggestion is selected.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TAutoCompleteEventParameter extends TCallbackEventParameter
+{
+ private $_selectedIndex=-1;
+
+ /**
+ * Creates a new TCallbackEventParameter.
+ */
+ public function __construct($response, $parameter, $index=-1)
+ {
+ parent::__construct($response, $parameter);
+ $this->_selectedIndex=$index;
+ }
+
+ /**
+ * @return int selected suggestion zero-based index, -1 if not selected.
+ */
+ public function getSelectedIndex()
+ {
+ return $this->_selectedIndex;
+ }
+
+ /**
+ * @return string token for matching a list of suggestions.
+ */
+ public function getToken()
+ {
+ return $this->getCallbackParameter();
+ }
+}
+
+/**
+ * TAutoCompleteTemplate class.
+ *
+ * TAutoCompleteTemplate is the default template for TAutoCompleteTemplate
+ * item template.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TAutoCompleteTemplate extends TComponent implements ITemplate
+{
+ private $_template;
+
+ public function __construct($template)
+ {
+ $this->_template = $template;
+ }
+ /**
+ * Instantiates the template.
+ * It creates a {@link TDataList} control.
+ * @param TControl parent to hold the content within the template
+ */
+ public function instantiateIn($parent)
+ {
+ $parent->getControls()->add($this->_template);
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
index d3391b71..c412a2e2 100644
--- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php
+++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
@@ -1,392 +1,392 @@
-<?php
-/**
- * TBaseActiveControl and TBaseActiveCallbackControl class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-Prado::using('System.Web.UI.ActiveControls.TCallbackClientSide');
-
-/**
- * TBaseActiveControl class provided additional basic property for every
- * active control. An instance of TBaseActiveControl or its decendent
- * TBaseActiveCallbackControl is created by {@link TActiveControlAdapter::getBaseActiveControl()}
- * method.
- *
- * The {@link setEnableUpdate EnableUpdate} property determines wether the active
- * control is allowed to update the contents of the client-side when the callback
- * response returns.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TBaseActiveControl extends TComponent
-{
- /**
- * @var TMap map of active control options.
- */
- private $_options;
- /**
- * @var TControl attached control.
- */
- private $_control;
-
- /**
- * Constructor. Attach a base active control to an active control instance.
- * @param TControl active control
- */
- public function __construct($control)
- {
- $this->_control = $control;
- $this->_options = new TMap;
- }
-
- /**
- * Sets a named options with a value. Options are used to store and retrive
- * named values for the base active controls.
- * @param string option name.
- * @param mixed new value.
- * @param mixed default value.
- * @return mixed options value.
- */
- protected function setOption($name,$value,$default=null)
- {
- $value = ($value===null) ? $default : $value;
- if($value!==null)
- $this->_options->add($name,$value);
- }
-
- /**
- * Gets an option named value. Options are used to store and retrive
- * named values for the base active controls.
- * @param string option name.
- * @param mixed default value.
- * @return mixed options value.
- */
- protected function getOption($name,$default=null)
- {
- $item = $this->_options->itemAt($name);
- return ($item===null) ? $default : $item;
- }
-
- /**
- * @return TMap active control options
- */
- protected function getOptions()
- {
- return $this->_options;
- }
-
- /**
- * @return TPage the page containing the attached control.
- */
- protected function getPage()
- {
- return $this->_control->getPage();
- }
-
- /**
- * @return TControl the attached control.
- */
- protected function getControl()
- {
- return $this->_control;
- }
-
- /**
- * @param boolean true to allow fine grain callback updates.
- */
- public function setEnableUpdate($value)
- {
- $this->setOption('EnableUpdate', TPropertyValue::ensureBoolean($value), true);
- }
-
- /**
- * @return boolean true to allow fine grain callback updates.
- */
- public function getEnableUpdate()
- {
- return $this->getOption('EnableUpdate', true);
- }
-
- /**
- * Returns true if callback response is allowed to update the browser contents.
- * Is is true if the control is initilized, and is a callback request and
- * the {@link setEnableUpdate EnableUpdate} property is true and
- * the page is not loading post data.
- * @return boolean true if the callback response is allowed update
- * client-side contents.
- */
- public function canUpdateClientSide($bDontRequireVisibility=false)
- {
- return $this->getControl()->getHasChildInitialized()
- && $this->getPage()->getIsLoadingPostData() == false
- && $this->getPage()->getIsCallback()
- && $this->getEnableUpdate()
- && ($bDontRequireVisibility || $this->getControl()->getVisible());
- }
-}
-
-/**
- * TBaseActiveCallbackControl is a common set of options and functionality for
- * active controls that can perform callback requests.
- *
- * The properties of TBaseActiveCallbackControl can be accessed and changed from
- * each individual active controls' {@link getActiveControl ActiveControl}
- * property.
- *
- * The following example sets the validation group property of a TCallback component.
- * <code>
- * <com:TCallback ActiveControl.ValidationGroup="group1" ... />
- * </code>
- *
- * Additional client-side options and events can be set using the
- * {@link getClientSide ClientSide} property. The following example shows
- * an alert box when a TCallback component response returns successfully.
- * <code>
- * <com:TCallback ActiveControl.ClientSide.OnSuccess="alert('ok!')" ... />
- * </code>
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TBaseActiveCallbackControl extends TBaseActiveControl
-{
- /**
- * Callback client-side options can be set by setting the properties of
- * the ClientSide property. E.g. <com:TCallback ActiveControl.ClientSide.OnSuccess="..." />
- * See {@link TCallbackClientSide} for details on the properties of ClientSide.
- * @return TCallbackClientSide client-side callback options.
- */
- public function getClientSide()
- {
- if(($client = $this->getOption('ClientSide'))===null)
- {
- $client = $this->createClientSide();
- $this->setOption('ClientSide', $client);
- }
- return $client;
- }
-
- /**
- * Sets the client side options. Can only be set when client side is null.
- * @param TCallbackClientSide client side options.
- */
- public function setClientSide($client)
- {
- if( $this->getOption('ClientSide')===null)
- $this->setOption('ClientSide', $client);
- else
- throw new TConfigurationException(
- 'active_controls_client_side_exists', $this->getControl()->getID());
- }
-
- /**
- * @return TCallbackClientSide callback client-side options.
- */
- protected function createClientSide()
- {
- return new TCallbackClientSide;
- }
-
- /**
- * Sets default callback options. Takes the ID of a TCallbackOptions
- * component to duplicate the client-side
- * options for this control. The {@link getClientSide ClientSide}
- * subproperties takes precedence over the CallbackOptions property.
- * @param string ID of a TCallbackOptions control from which ClientSide
- * options are cloned.
- */
- public function setCallbackOptions($value)
- {
- $this->setOption('CallbackOptions', $value, '');
- }
-
- /**
- * @return string ID of a TCallbackOptions control from which ClientSide
- * options are duplicated.
- */
- public function getCallbackOptions()
- {
- return $this->getOption('CallbackOptions', '');
- }
-
- /**
- * Returns an array of default callback client-side options. The default options
- * are obtained from the client-side options of a TCallbackOptions control with
- * ID specified by {@link setCallbackOptions CallbackOptions}.
- * @return array list of default callback client-side options.
- */
- protected function getDefaultClientSideOptions()
- {
- if(($id=$this->getCallbackOptions())!=='')
- {
- if(($pos=strrpos($id,'.'))!==false)
- {
- $control=$this->getControl()->getSubProperty(substr($id,0,$pos));
- $newid=substr($id,$pos+1);
- if ($control!==null)
- $control=$control->$newid;
- }
- else
- {
- $control=$this->getControl()->findControl($id);
- }
-
- if($control instanceof TCallbackOptions)
- return $control->getClientSide()->getOptions()->toArray();
- else
- throw new TConfigurationException('callback_invalid_callback_options', $this->getControl()->getID(), $id);
- }
-
- return array();
- }
-
- /**
- * @return boolean whether callback event trigger by this button will cause
- * input validation, default is true
- */
- public function getCausesValidation()
- {
- return $this->getOption('CausesValidation',true);
- }
-
- /**
- * @param boolean whether callback event trigger by this button will cause
- * input validation
- */
- public function setCausesValidation($value)
- {
- $this->setOption('CausesValidation',TPropertyValue::ensureBoolean($value),true);
- }
-
- /**
- * @return string the group of validators which the button causes validation
- * upon callback
- */
- public function getValidationGroup()
- {
- return $this->getOption('ValidationGroup','');
- }
-
- /**
- * @param string the group of validators which the button causes validation
- * upon callback
- */
- public function setValidationGroup($value)
- {
- $this->setOption('ValidationGroup',$value,'');
- }
-
- /**
- * @return boolean whether to perform validation if the callback is
- * requested.
- */
- public function canCauseValidation()
- {
- if($this->getCausesValidation())
- {
- $group=$this->getValidationGroup();
- return $this->getPage()->getValidators($group)->getCount()>0;
- }
- else
- return false;
- }
-
- /**
- * @param mixed callback parameter value.
- */
- public function setCallbackParameter($value)
- {
- $this->setOption('CallbackParameter', $value, '');
- }
-
- /**
- * @return mixed callback parameter value.
- */
- public function getCallbackParameter()
- {
- return $this->getOption('CallbackParameter', '');
- }
-
-
- /**
- * @return array list of callback javascript options.
- */
- protected function getClientSideOptions()
- {
- $default = $this->getDefaultClientSideOptions();
- $options = array_merge($default,$this->getClientSide()->getOptions()->toArray());
- $validate = $this->getCausesValidation();
- $options['CausesValidation']= $validate ? '' : false;
- $options['ValidationGroup']=$this->getValidationGroup();
- $options['CallbackParameter'] = $this->getCallbackParameter();
- return $options;
- }
-
- /**
- * Registers the callback control javascript code. Client-side options are
- * merged and passed to the javascript code. This method should be called by
- * Active component developers wanting to register the javascript to initialize
- * the active component with additional options offered by the
- * {@link getClientSide ClientSide} property.
- * @param string client side javascript class name.
- * @param array additional callback options.
- */
- public function registerCallbackClientScript($class,$options=null)
- {
- $cs = $this->getPage()->getClientScript();
- if(is_array($options))
- $options = array_merge($this->getClientSideOptions(),$options);
- else
- $options = $this->getClientSideOptions();
-
- //remove true as default to save bytes
- if($options['CausesValidation']===true)
- $options['CausesValidation']='';
- $cs->registerCallbackControl($class, $options);
- }
-
- /**
- * Returns the javascript callback request instance. To invoke a callback
- * request for this control call the <tt>dispatch()</tt> method on the
- * request instance. Example code in javascript
- * <code>
- * var request = <%= $this->mycallback->ActiveControl->Javascript %>;
- * request.setParameter('hello');
- * request.dispatch(); //make the callback request.
- * </code>
- *
- * Alternatively,
- * <code>
- * //dispatches immediately
- * Prado.Callback("<%= $this->mycallback->UniqueID %>",
- * $this->mycallback->ActiveControl->JsCallbackOptions);
- * </code>
- * @return string javascript client-side callback request object (javascript
- * code)
- */
- public function getJavascript()
- {
- $client = $this->getPage()->getClientScript();
- return $client->getCallbackReference($this->getControl(),$this->getClientSideOptions());
- }
-
- /**
- * @param string callback requestion options as javascript code.
- */
- public function getJsCallbackOptions()
- {
- return TJavaScript::encode($this->getClientSideOptions());
- }
-}
-
+<?php
+/**
+ * TBaseActiveControl and TBaseActiveCallbackControl class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TCallbackClientSide');
+
+/**
+ * TBaseActiveControl class provided additional basic property for every
+ * active control. An instance of TBaseActiveControl or its decendent
+ * TBaseActiveCallbackControl is created by {@link TActiveControlAdapter::getBaseActiveControl()}
+ * method.
+ *
+ * The {@link setEnableUpdate EnableUpdate} property determines wether the active
+ * control is allowed to update the contents of the client-side when the callback
+ * response returns.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TBaseActiveControl extends TComponent
+{
+ /**
+ * @var TMap map of active control options.
+ */
+ private $_options;
+ /**
+ * @var TControl attached control.
+ */
+ private $_control;
+
+ /**
+ * Constructor. Attach a base active control to an active control instance.
+ * @param TControl active control
+ */
+ public function __construct($control)
+ {
+ $this->_control = $control;
+ $this->_options = new TMap;
+ }
+
+ /**
+ * Sets a named options with a value. Options are used to store and retrive
+ * named values for the base active controls.
+ * @param string option name.
+ * @param mixed new value.
+ * @param mixed default value.
+ * @return mixed options value.
+ */
+ protected function setOption($name,$value,$default=null)
+ {
+ $value = ($value===null) ? $default : $value;
+ if($value!==null)
+ $this->_options->add($name,$value);
+ }
+
+ /**
+ * Gets an option named value. Options are used to store and retrive
+ * named values for the base active controls.
+ * @param string option name.
+ * @param mixed default value.
+ * @return mixed options value.
+ */
+ protected function getOption($name,$default=null)
+ {
+ $item = $this->_options->itemAt($name);
+ return ($item===null) ? $default : $item;
+ }
+
+ /**
+ * @return TMap active control options
+ */
+ protected function getOptions()
+ {
+ return $this->_options;
+ }
+
+ /**
+ * @return TPage the page containing the attached control.
+ */
+ protected function getPage()
+ {
+ return $this->_control->getPage();
+ }
+
+ /**
+ * @return TControl the attached control.
+ */
+ protected function getControl()
+ {
+ return $this->_control;
+ }
+
+ /**
+ * @param boolean true to allow fine grain callback updates.
+ */
+ public function setEnableUpdate($value)
+ {
+ $this->setOption('EnableUpdate', TPropertyValue::ensureBoolean($value), true);
+ }
+
+ /**
+ * @return boolean true to allow fine grain callback updates.
+ */
+ public function getEnableUpdate()
+ {
+ return $this->getOption('EnableUpdate', true);
+ }
+
+ /**
+ * Returns true if callback response is allowed to update the browser contents.
+ * Is is true if the control is initilized, and is a callback request and
+ * the {@link setEnableUpdate EnableUpdate} property is true and
+ * the page is not loading post data.
+ * @return boolean true if the callback response is allowed update
+ * client-side contents.
+ */
+ public function canUpdateClientSide($bDontRequireVisibility=false)
+ {
+ return $this->getControl()->getHasChildInitialized()
+ && $this->getPage()->getIsLoadingPostData() == false
+ && $this->getPage()->getIsCallback()
+ && $this->getEnableUpdate()
+ && ($bDontRequireVisibility || $this->getControl()->getVisible());
+ }
+}
+
+/**
+ * TBaseActiveCallbackControl is a common set of options and functionality for
+ * active controls that can perform callback requests.
+ *
+ * The properties of TBaseActiveCallbackControl can be accessed and changed from
+ * each individual active controls' {@link getActiveControl ActiveControl}
+ * property.
+ *
+ * The following example sets the validation group property of a TCallback component.
+ * <code>
+ * <com:TCallback ActiveControl.ValidationGroup="group1" ... />
+ * </code>
+ *
+ * Additional client-side options and events can be set using the
+ * {@link getClientSide ClientSide} property. The following example shows
+ * an alert box when a TCallback component response returns successfully.
+ * <code>
+ * <com:TCallback ActiveControl.ClientSide.OnSuccess="alert('ok!')" ... />
+ * </code>
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TBaseActiveCallbackControl extends TBaseActiveControl
+{
+ /**
+ * Callback client-side options can be set by setting the properties of
+ * the ClientSide property. E.g. <com:TCallback ActiveControl.ClientSide.OnSuccess="..." />
+ * See {@link TCallbackClientSide} for details on the properties of ClientSide.
+ * @return TCallbackClientSide client-side callback options.
+ */
+ public function getClientSide()
+ {
+ if(($client = $this->getOption('ClientSide'))===null)
+ {
+ $client = $this->createClientSide();
+ $this->setOption('ClientSide', $client);
+ }
+ return $client;
+ }
+
+ /**
+ * Sets the client side options. Can only be set when client side is null.
+ * @param TCallbackClientSide client side options.
+ */
+ public function setClientSide($client)
+ {
+ if( $this->getOption('ClientSide')===null)
+ $this->setOption('ClientSide', $client);
+ else
+ throw new TConfigurationException(
+ 'active_controls_client_side_exists', $this->getControl()->getID());
+ }
+
+ /**
+ * @return TCallbackClientSide callback client-side options.
+ */
+ protected function createClientSide()
+ {
+ return new TCallbackClientSide;
+ }
+
+ /**
+ * Sets default callback options. Takes the ID of a TCallbackOptions
+ * component to duplicate the client-side
+ * options for this control. The {@link getClientSide ClientSide}
+ * subproperties takes precedence over the CallbackOptions property.
+ * @param string ID of a TCallbackOptions control from which ClientSide
+ * options are cloned.
+ */
+ public function setCallbackOptions($value)
+ {
+ $this->setOption('CallbackOptions', $value, '');
+ }
+
+ /**
+ * @return string ID of a TCallbackOptions control from which ClientSide
+ * options are duplicated.
+ */
+ public function getCallbackOptions()
+ {
+ return $this->getOption('CallbackOptions', '');
+ }
+
+ /**
+ * Returns an array of default callback client-side options. The default options
+ * are obtained from the client-side options of a TCallbackOptions control with
+ * ID specified by {@link setCallbackOptions CallbackOptions}.
+ * @return array list of default callback client-side options.
+ */
+ protected function getDefaultClientSideOptions()
+ {
+ if(($id=$this->getCallbackOptions())!=='')
+ {
+ if(($pos=strrpos($id,'.'))!==false)
+ {
+ $control=$this->getControl()->getSubProperty(substr($id,0,$pos));
+ $newid=substr($id,$pos+1);
+ if ($control!==null)
+ $control=$control->$newid;
+ }
+ else
+ {
+ $control=$this->getControl()->findControl($id);
+ }
+
+ if($control instanceof TCallbackOptions)
+ return $control->getClientSide()->getOptions()->toArray();
+ else
+ throw new TConfigurationException('callback_invalid_callback_options', $this->getControl()->getID(), $id);
+ }
+
+ return array();
+ }
+
+ /**
+ * @return boolean whether callback event trigger by this button will cause
+ * input validation, default is true
+ */
+ public function getCausesValidation()
+ {
+ return $this->getOption('CausesValidation',true);
+ }
+
+ /**
+ * @param boolean whether callback event trigger by this button will cause
+ * input validation
+ */
+ public function setCausesValidation($value)
+ {
+ $this->setOption('CausesValidation',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
+ * @return string the group of validators which the button causes validation
+ * upon callback
+ */
+ public function getValidationGroup()
+ {
+ return $this->getOption('ValidationGroup','');
+ }
+
+ /**
+ * @param string the group of validators which the button causes validation
+ * upon callback
+ */
+ public function setValidationGroup($value)
+ {
+ $this->setOption('ValidationGroup',$value,'');
+ }
+
+ /**
+ * @return boolean whether to perform validation if the callback is
+ * requested.
+ */
+ public function canCauseValidation()
+ {
+ if($this->getCausesValidation())
+ {
+ $group=$this->getValidationGroup();
+ return $this->getPage()->getValidators($group)->getCount()>0;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * @param mixed callback parameter value.
+ */
+ public function setCallbackParameter($value)
+ {
+ $this->setOption('CallbackParameter', $value, '');
+ }
+
+ /**
+ * @return mixed callback parameter value.
+ */
+ public function getCallbackParameter()
+ {
+ return $this->getOption('CallbackParameter', '');
+ }
+
+
+ /**
+ * @return array list of callback javascript options.
+ */
+ protected function getClientSideOptions()
+ {
+ $default = $this->getDefaultClientSideOptions();
+ $options = array_merge($default,$this->getClientSide()->getOptions()->toArray());
+ $validate = $this->getCausesValidation();
+ $options['CausesValidation']= $validate ? '' : false;
+ $options['ValidationGroup']=$this->getValidationGroup();
+ $options['CallbackParameter'] = $this->getCallbackParameter();
+ return $options;
+ }
+
+ /**
+ * Registers the callback control javascript code. Client-side options are
+ * merged and passed to the javascript code. This method should be called by
+ * Active component developers wanting to register the javascript to initialize
+ * the active component with additional options offered by the
+ * {@link getClientSide ClientSide} property.
+ * @param string client side javascript class name.
+ * @param array additional callback options.
+ */
+ public function registerCallbackClientScript($class,$options=null)
+ {
+ $cs = $this->getPage()->getClientScript();
+ if(is_array($options))
+ $options = array_merge($this->getClientSideOptions(),$options);
+ else
+ $options = $this->getClientSideOptions();
+
+ //remove true as default to save bytes
+ if($options['CausesValidation']===true)
+ $options['CausesValidation']='';
+ $cs->registerCallbackControl($class, $options);
+ }
+
+ /**
+ * Returns the javascript callback request instance. To invoke a callback
+ * request for this control call the <tt>dispatch()</tt> method on the
+ * request instance. Example code in javascript
+ * <code>
+ * var request = <%= $this->mycallback->ActiveControl->Javascript %>;
+ * request.setParameter('hello');
+ * request.dispatch(); //make the callback request.
+ * </code>
+ *
+ * Alternatively,
+ * <code>
+ * //dispatches immediately
+ * Prado.Callback("<%= $this->mycallback->UniqueID %>",
+ * $this->mycallback->ActiveControl->JsCallbackOptions);
+ * </code>
+ * @return string javascript client-side callback request object (javascript
+ * code)
+ */
+ public function getJavascript()
+ {
+ $client = $this->getPage()->getClientScript();
+ return $client->getCallbackReference($this->getControl(),$this->getClientSideOptions());
+ }
+
+ /**
+ * @param string callback requestion options as javascript code.
+ */
+ public function getJsCallbackOptions()
+ {
+ return TJavaScript::encode($this->getClientSideOptions());
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TCallback.php b/framework/Web/UI/ActiveControls/TCallback.php
index 7a1f54b7..662bc03f 100644
--- a/framework/Web/UI/ActiveControls/TCallback.php
+++ b/framework/Web/UI/ActiveControls/TCallback.php
@@ -1,101 +1,101 @@
-<?php
-/**
- * TCallback class file.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * Load active control adapter.
- */
-Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
-
-/**
- * TCallback component class.
- *
- * The TCallback provides a basic callback handler that can be invoked from the
- * client side by running the javascript code obtained from the
- * {@link TBaseActiveCallbackControl::getJavascript ActiveControl.Javascript} property.
- * The event {@link onCallback OnCallback} is raised when a callback is requested made.
- *
- * Example usage:
- * <code>
- * <com:TCallback ID="callback1" OnCallback="callback1_Requested" />
- * <script type="text/javascript">
- * function do_callback1()
- * {
- * var request = <%= $this->callback1->ActiveControl->Javascript %>;
- * request.dispatch();
- * }
- * </script>
- * <div onclick="do_callback1()">Click Me!</div>
- * </code>
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TCallback extends TControl implements ICallbackEventHandler, IActiveControl
-{
- /**
- * Creates a new callback control, sets the adapter to
- * TActiveControlAdapter. If you override this class, be sure to set the
- * adapter appropriately by, for example, call this constructor.
- */
- public function __construct()
- {
- parent::__construct();
- $this->setAdapter(new TActiveControlAdapter($this));
- }
-
- /**
- * @return TBaseActiveCallbackControl standard callback options.
- */
- public function getActiveControl()
- {
- return $this->getAdapter()->getBaseActiveControl();
- }
-
- /**
- * @return TCallbackClientSide client side request options.
- */
- public function getClientSide()
- {
- return $this->getAdapter()->getBaseActiveControl()->getClientSide();
- }
-
- /**
- * Raises the callback event. This method is required by
- * {@link ICallbackEventHandler ICallbackEventHandler} interface. If
- * {@link getCausesValidation ActiveControl.CausesValidation} is true,
- * it will invoke the page's {@link TPage::validate validate} method first.
- * It will raise {@link onCallback OnCallback} event. This method is mainly
- * used by framework and control developers.
- * @param TCallbackEventParameter the event parameter
- */
- public function raiseCallbackEvent($param)
- {
- if($this->getActiveControl()->canCauseValidation())
- $this->getPage()->validate($this->getActiveControl()->getValidationGroup());
- $this->onCallback($param);
- }
-
- /**
- * This method is invoked when a callback is requested. The method raises
- * 'OnCallback' event to fire up the event handlers. If you override this
- * method, be sure to call the parent implementation so that the event
- * handler can be invoked.
- * @param TCallbackEventParameter event parameter to be passed to the event handlers
- */
- public function onCallback($param)
- {
- $this->raiseEvent('OnCallback', $this, $param);
- }
-}
-
+<?php
+/**
+ * TCallback class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load active control adapter.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
+
+/**
+ * TCallback component class.
+ *
+ * The TCallback provides a basic callback handler that can be invoked from the
+ * client side by running the javascript code obtained from the
+ * {@link TBaseActiveCallbackControl::getJavascript ActiveControl.Javascript} property.
+ * The event {@link onCallback OnCallback} is raised when a callback is requested made.
+ *
+ * Example usage:
+ * <code>
+ * <com:TCallback ID="callback1" OnCallback="callback1_Requested" />
+ * <script type="text/javascript">
+ * function do_callback1()
+ * {
+ * var request = <%= $this->callback1->ActiveControl->Javascript %>;
+ * request.dispatch();
+ * }
+ * </script>
+ * <div onclick="do_callback1()">Click Me!</div>
+ * </code>
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TCallback extends TControl implements ICallbackEventHandler, IActiveControl
+{
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, call this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ return $this->getAdapter()->getBaseActiveControl()->getClientSide();
+ }
+
+ /**
+ * Raises the callback event. This method is required by
+ * {@link ICallbackEventHandler ICallbackEventHandler} interface. If
+ * {@link getCausesValidation ActiveControl.CausesValidation} is true,
+ * it will invoke the page's {@link TPage::validate validate} method first.
+ * It will raise {@link onCallback OnCallback} event. This method is mainly
+ * used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ if($this->getActiveControl()->canCauseValidation())
+ $this->getPage()->validate($this->getActiveControl()->getValidationGroup());
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
index 6dcbe3d0..291f22f2 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
@@ -1,705 +1,705 @@
-<?php
-/**
- * TCallbackClientScript class file
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * TCallbackClientScript class.
- *
- * The TCallbackClientScript class provides corresponding methods that can be
- * executed on the client-side (i.e. the browser client that is viewing
- * the page) during a callback response.
- *
- * The avaiable methods includes setting/clicking input elements, changing Css
- * styles, hiding/showing elements, and adding visual effects to elements on the
- * page. The client-side methods can be access through the CallbackClient
- * property available in TPage.
- *
- * For example, to hide "$myTextBox" element during callback response, do
- * <code>
- * $this->getPage()->getCallbackClient()->hide($myTextBox);
- * </code>
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TCallbackClientScript extends TApplicationComponent
-{
- /**
- * @var TList list of client functions to execute.
- */
- private $_actions;
-
- /**
- * Constructor.
- */
- public function __construct()
- {
- $this->_actions = new TList;
- }
-
- /**
- * @return array list of client function to be executed during callback
- * response.
- */
- public function getClientFunctionsToExecute()
- {
- return $this->_actions->toArray();
- }
-
- /**
- * Executes a client-side statement.
- * @param string javascript function name
- * @param array list of arguments for the function
- */
- public function callClientFunction($function, $params=null)
- {
- if(!is_array($params))
- $params = array($params);
-
- if(count($params) > 0)
- {
- if($params[0] instanceof TControl)
- $params[0] = $params[0]->getClientID();
- }
- $this->_actions->add(array($function => $params));
- }
-
- /**
- * Client script to set the value of a particular input element.
- * @param TControl control element to set the new value
- * @param string new value
- */
- public function setValue($input, $text)
- {
- $this->callClientFunction('Prado.Element.setValue', array($input, $text));
- }
-
- /**
- * Client script to select/clear/check a drop down list, check box list,
- * or radio button list.
- * The second parameter determines the selection method. Valid methods are
- * - <b>Value</b>, select or check by value
- * - <b>Values</b>, select or check by a list of values
- * - <b>Index</b>, select or check by index (zero based index)
- * - <b>Indices</b>, select or check by a list of index (zero based index)
- * - <b>Clear</b>, clears or selections or checks in the list
- * - <b>All</b>, select all
- * - <b>Invert</b>, invert the selection.
- * @param TControl list control
- * @param string selection method
- * @param string|int the value or index to select/check.
- * @param string selection control type, either 'check' or 'select'
- */
- public function select($control, $method='Value', $value=null, $type=null)
- {
- $method = TPropertyValue::ensureEnum($method,
- 'Value', 'Index', 'Clear', 'Indices', 'Values', 'All', 'Invert');
- $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));
- }
-
- private function getSelectionControlType($control)
- {
- if(is_string($control)) return 'check';
- if($control instanceof TCheckBoxList)
- return 'check';
- if($control instanceof TCheckBox)
- return 'check';
- return 'select';
- }
-
- private function getSelectionControlIsListType($control)
- {
- return $control instanceof TListControl;
- }
-
- /**
- * Client script to click on an element. <b>This client-side function is unpredictable.</b>
- *
- * @param TControl control element or element id
- */
- public function click($control)
- {
- $this->callClientFunction('Prado.Element.click', $control);
- }
-
- /**
- * Client script to check or uncheck a checkbox or radio button.
- * @param TControl control element or element id
- * @param boolean check or uncheck the checkbox or radio button.
- */
- public function check($checkbox, $checked=true)
- {
- $this->select($checkbox, "Value", $checked);
- }
-
- /**
- * Raise the client side event (given by $eventName) on a particular element.
- * @param TControl control element or element id
- * @param string Event name, e.g. "click"
- */
- public function raiseClientEvent($control, $eventName)
- {
- $this->callClientFunction('Event.fireEvent',
- array($control, strtolower($eventName)));
- }
-
- /**
- * Sets the attribute of a particular control.
- * @param TControl control element or element id
- * @param string attribute name
- * @param string attribute value
- */
- public function setAttribute($control, $name, $value)
- {
- // Attributes should be applied on Surrounding tag, except for 'disabled' attribute
- if ($control instanceof ISurroundable && strtolower($name)!=='disabled')
- $control=$control->getSurroundingTagID();
- $this->callClientFunction('Prado.Element.setAttribute',array($control, $name, $value));
- }
-
- /**
- * Sets the options of a select input element.
- * @param TControl control element or element id
- * @param TCollection a list of new options
- */
- 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())
- $options[] = array($item->getText(),$item->getValue(), $item->getAttributes()->itemAt('Group'));
- else
- $options[] = array($item->getText(),$item->getValue());
- }
- $this->callClientFunction('Prado.Element.setOptions', array($control, $options));
- }
-
- /**
- * Shows an element by changing its CSS display style as empty.
- * @param TControl control element or element id
- */
- public function show($element)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->callClientFunction('Element.show', $element);
- }
-
- /**
- * Hides an element by changing its CSS display style to "none".
- * @param TControl control element or element id
- */
- public function hide($element)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->callClientFunction('Element.hide', $element);
- }
-
- /**
- * Toggles the visibility of the element.
- * @param TControl control element or element id
- * @param string visual effect, such as, 'appear' or 'slide' or 'blind'.
- * @param array additional options.
- */
- public function toggle($element, $effect=null, $options=array())
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->callClientFunction('Element.toggle', array($element,$effect,$options));
- }
-
- /**
- * Removes an element from the HTML page.
- * @param TControl control element or element id
- */
- public function remove($element)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->callClientFunction('Element.remove', $element);
- }
-
- public function addPostDataLoader($name)
- {
- $this->callClientFunction('Prado.CallbackRequest.addPostLoaders', $name);
- }
-
- /**
- * Update the element's innerHTML with new content.
- * @param TControl control element or element id
- * @param TControl new HTML content, if content is of a TControl, the
- * controls render method is called.
- */
- public function update($element, $content)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->replace($element, $content, 'Element.update');
- }
-
- /**
- * Add a Css class name to the element.
- * @param TControl control element or element id
- * @param string CssClass name to add.
- */
- public function addCssClass($element, $cssClass)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->callClientFunction('Element.addClassName', array($element, $cssClass));
- }
-
- /**
- * Remove a Css class name from the element.
- * @param TControl control element or element id
- * @param string CssClass name to remove.
- */
- public function removeCssClass($element, $cssClass)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->callClientFunction('Element.removeClassName', array($element, $cssClass));
- }
-
- /**
- * Sets the CssClass of an element.
- * @param TControl control element or element id
- * @param string new CssClass name for the element.
- */
- /*public function setCssClass($element, $cssClass)
- {
- $this->callClientFunction('Prado.Element.CssClass.set', array($element, $cssClass));
- }*/
-
- /**
- * Scroll the top of the browser viewing area to the location of the
- * element.
- * @param TControl control element or element id
- */
- public function scrollTo($element)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->callClientFunction('Element.scrollTo', $element);
- }
-
- /**
- * Focus on a particular element.
- * @param TControl control element or element id.
- */
- public function focus($element)
- {
- $this->callClientFunction('Prado.Element.focus', $element);
- }
-
- /**
- * Sets the style of element. The style must be a key-value array where the
- * key is the style property and the value is the style value.
- * @param TControl control element or element id
- * @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();
- $this->callClientFunction('Prado.Element.setStyle', array($element, $styles));
- }
-
- /**
- * Append a HTML fragement to the element.
- * @param TControl control element or element id
- * @param string HTML fragement or the control to be rendered
- */
- public function appendContent($element, $content)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->replace($element, $content, 'Prado.Element.Insert.append');
- }
-
- /**
- * Prepend a HTML fragement to the element.
- * @param TControl control element or element id
- * @param string HTML fragement or the control to be rendered
- */
- public function prependContent($element, $content)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->replace($element, $content, 'Prado.Element.Insert.prepend');
- }
-
- /**
- * Insert a HTML fragement after the element.
- * @param TControl control element or element id
- * @param string HTML fragement or the control to be rendered
- */
- public function insertContentAfter($element, $content)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->replace($element, $content, 'Prado.Element.Insert.after');
- }
-
- /**
- * Insert a HTML fragement in before the element.
- * @param TControl control element or element id
- * @param string HTML fragement or the control to be rendered
- */
- public function insertContentBefore($element, $content)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->replace($element, $content, 'Prado.Element.Insert.before');
- }
-
- /**
- * Replace the content of an element with new content. The new content can
- * be a string or a TControl component. If the <tt>content</tt> parameter is
- * a TControl component, its rendered method will be called and its contents
- * will be used for replacement.
- * @param TControl control element or HTML element id.
- * @param string HTML fragement or the control to be rendered
- * @param string replacement method, default is to replace the outter
- * html content.
- * @param string provide a custom boundary.
- * @see insertAbout
- * @see insertBelow
- * @see insertBefore
- * @see insertAfter
- */
- protected function replace($element, $content, $method="Element.replace", $boundary=null)
- {
- if($content instanceof TControl)
- {
- $boundary = $this->getRenderedContentBoundary($content);
- $content = null;
- }
- else if($content instanceof THtmlWriter)
- {
- $boundary = $this->getResponseContentBoundary($content);
- $content = null;
- }
-
- $this->callClientFunction('Prado.Element.replace',
- array($element, $method, $content, $boundary));
- }
-
- /**
- * Replace the content of an element with new content contained in writer.
- * @param TControl control element or HTML element id.
- * @param string HTML fragement or the control to be rendered
- */
- public function replaceContent($element,$content)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->replace($element, $content);
- }
-
- /**
- * Evaluate a block of javascript enclosed in a boundary.
- * @param THtmlWriter writer for the content.
- */
- public function evaluateScript($writer)
- {
- $this->replace(null, $writer, 'Prado.Element.evaluateScript');
- }
-
- /**
- * Appends a block of inline javascript enclosed in a boundary.
- * Similar to to evaluateScript(), but functions declared in the
- * inline block will be available to page elements.
- * @param THtmlWriter writer for the content.
- */
- public function appendScriptBlock($content)
- {
- if($content instanceof TControl)
- {
- $boundary = $this->getRenderedContentBoundary($content);
- }
- else if($content instanceof THtmlWriter)
- {
- $boundary = $this->getResponseContentBoundary($content);
- }
-
- $this->callClientFunction('Prado.Element.appendScriptBlock', array($boundary));
- }
-
- /**
- * Renders the control and return the content boundary from
- * TCallbackResponseWriter. This method should only be used by framework
- * component developers. The render() method is defered to be called in the
- * TActivePageAdapter class.
- * @param TControl control to be rendered on callback response.
- * @return string the boundary for which the rendered content is wrapped.
- */
- private function getRenderedContentBoundary($control)
- {
- $writer = $this->getResponse()->createHtmlWriter();
- $adapter = $control->getPage()->getAdapter();
- $adapter->registerControlToRender($control, $writer);
- return $writer->getWriter()->getBoundary();
- }
-
- /**
- * @param THtmlWriter the writer responsible for rendering html content.
- * @return string content boundary.
- */
- private function getResponseContentBoundary($html)
- {
- if($html instanceof THtmlWriter)
- {
- if($html->getWriter() instanceof TCallbackResponseWriter)
- return $html->getWriter()->getBoundary();
- }
- return null;
- }
-
- /**
- * Add a visual effect the element.
- * @param string visual effect function name.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function visualEffect($type, $element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->callClientFunction($type, array($element, $options));
- }
-
- /**
- * Visual Effect: Gradually make the element appear.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function appear($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.Appear', $element, $options);
- }
-
- /**
- * Visual Effect: Blind down.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function blindDown($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.BlindDown', $element, $options);
- }
-
- /**
- * Visual Effect: Blind up.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function blindUp($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.BlindUp', $element, $options);
-
- }
-
- /**
- * Visual Effect: Drop out.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function dropOut($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.DropOut', $element, $options);
- }
-
- /**
- * Visual Effect: Gradually fade the element.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function fade($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.Fade', $element, $options);
- }
-
- /**
- * Visual Effect: Fold.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function fold($element, $options = null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.Fold', $element, $options);
- }
-
- /**
- * Visual Effect: Gradually make an element grow to a predetermined size.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function grow($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.Grow', $element, $options);
- }
-
- /**
- * Visual Effect: Gradually grow and fade the element.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function puff($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.Puff', $element, $options);
- }
-
- /**
- * Visual Effect: Pulsate.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function pulsate($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.Pulsate', $element, $options);
- }
-
- /**
- * Visual Effect: Shake the element.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function shake($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.Shake', $element, $options);
- }
-
- /**
- * Visual Effect: Shrink the element.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function shrink($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.Shrink', $element, $options);
- }
-
- /**
- * Visual Effect: Slide down.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function slideDown($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.SlideDown', $element, $options);
- }
-
- /**
- * Visual Effect: Side up.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function slideUp($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.SlideUp', $element, $options);
- }
-
- /**
- * Visual Effect: Squish the element.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function squish($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.Squish', $element, $options);
- }
-
- /**
- * Visual Effect: Switch Off effect.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function switchOff($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Effect.SwitchOff', $element, $options);
- }
-
- /**
- * Visual Effect: High light the element for about 2 seconds.
- * @param TControl control element or element id
- * @param array visual effect key-value pair options.
- */
- public function highlight($element, $options=null)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $this->visualEffect('Prado.Effect.Highlight', $element, $options);
- }
-
- /**
- * Set the opacity on a html element or control.
- * @param TControl control element or element id
- * @param float opacity value between 1 and 0
- */
- public function setOpacity($element, $value)
- {
- if ($element instanceof ISurroundable)
- $element=$element->getSurroundingTagID();
- $value = TPropertyValue::ensureFloat($value);
- $this->callClientFunction('Element.setOpacity', array($element,$value));
- }
-}
-
+<?php
+/**
+ * TCallbackClientScript class file
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * TCallbackClientScript class.
+ *
+ * The TCallbackClientScript class provides corresponding methods that can be
+ * executed on the client-side (i.e. the browser client that is viewing
+ * the page) during a callback response.
+ *
+ * The avaiable methods includes setting/clicking input elements, changing Css
+ * styles, hiding/showing elements, and adding visual effects to elements on the
+ * page. The client-side methods can be access through the CallbackClient
+ * property available in TPage.
+ *
+ * For example, to hide "$myTextBox" element during callback response, do
+ * <code>
+ * $this->getPage()->getCallbackClient()->hide($myTextBox);
+ * </code>
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TCallbackClientScript extends TApplicationComponent
+{
+ /**
+ * @var TList list of client functions to execute.
+ */
+ private $_actions;
+
+ /**
+ * Constructor.
+ */
+ public function __construct()
+ {
+ $this->_actions = new TList;
+ }
+
+ /**
+ * @return array list of client function to be executed during callback
+ * response.
+ */
+ public function getClientFunctionsToExecute()
+ {
+ return $this->_actions->toArray();
+ }
+
+ /**
+ * Executes a client-side statement.
+ * @param string javascript function name
+ * @param array list of arguments for the function
+ */
+ public function callClientFunction($function, $params=null)
+ {
+ if(!is_array($params))
+ $params = array($params);
+
+ if(count($params) > 0)
+ {
+ if($params[0] instanceof TControl)
+ $params[0] = $params[0]->getClientID();
+ }
+ $this->_actions->add(array($function => $params));
+ }
+
+ /**
+ * Client script to set the value of a particular input element.
+ * @param TControl control element to set the new value
+ * @param string new value
+ */
+ public function setValue($input, $text)
+ {
+ $this->callClientFunction('Prado.Element.setValue', array($input, $text));
+ }
+
+ /**
+ * Client script to select/clear/check a drop down list, check box list,
+ * or radio button list.
+ * The second parameter determines the selection method. Valid methods are
+ * - <b>Value</b>, select or check by value
+ * - <b>Values</b>, select or check by a list of values
+ * - <b>Index</b>, select or check by index (zero based index)
+ * - <b>Indices</b>, select or check by a list of index (zero based index)
+ * - <b>Clear</b>, clears or selections or checks in the list
+ * - <b>All</b>, select all
+ * - <b>Invert</b>, invert the selection.
+ * @param TControl list control
+ * @param string selection method
+ * @param string|int the value or index to select/check.
+ * @param string selection control type, either 'check' or 'select'
+ */
+ public function select($control, $method='Value', $value=null, $type=null)
+ {
+ $method = TPropertyValue::ensureEnum($method,
+ 'Value', 'Index', 'Clear', 'Indices', 'Values', 'All', 'Invert');
+ $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));
+ }
+
+ private function getSelectionControlType($control)
+ {
+ if(is_string($control)) return 'check';
+ if($control instanceof TCheckBoxList)
+ return 'check';
+ if($control instanceof TCheckBox)
+ return 'check';
+ return 'select';
+ }
+
+ private function getSelectionControlIsListType($control)
+ {
+ return $control instanceof TListControl;
+ }
+
+ /**
+ * Client script to click on an element. <b>This client-side function is unpredictable.</b>
+ *
+ * @param TControl control element or element id
+ */
+ public function click($control)
+ {
+ $this->callClientFunction('Prado.Element.click', $control);
+ }
+
+ /**
+ * Client script to check or uncheck a checkbox or radio button.
+ * @param TControl control element or element id
+ * @param boolean check or uncheck the checkbox or radio button.
+ */
+ public function check($checkbox, $checked=true)
+ {
+ $this->select($checkbox, "Value", $checked);
+ }
+
+ /**
+ * Raise the client side event (given by $eventName) on a particular element.
+ * @param TControl control element or element id
+ * @param string Event name, e.g. "click"
+ */
+ public function raiseClientEvent($control, $eventName)
+ {
+ $this->callClientFunction('Event.fireEvent',
+ array($control, strtolower($eventName)));
+ }
+
+ /**
+ * Sets the attribute of a particular control.
+ * @param TControl control element or element id
+ * @param string attribute name
+ * @param string attribute value
+ */
+ public function setAttribute($control, $name, $value)
+ {
+ // Attributes should be applied on Surrounding tag, except for 'disabled' attribute
+ if ($control instanceof ISurroundable && strtolower($name)!=='disabled')
+ $control=$control->getSurroundingTagID();
+ $this->callClientFunction('Prado.Element.setAttribute',array($control, $name, $value));
+ }
+
+ /**
+ * Sets the options of a select input element.
+ * @param TControl control element or element id
+ * @param TCollection a list of new options
+ */
+ 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())
+ $options[] = array($item->getText(),$item->getValue(), $item->getAttributes()->itemAt('Group'));
+ else
+ $options[] = array($item->getText(),$item->getValue());
+ }
+ $this->callClientFunction('Prado.Element.setOptions', array($control, $options));
+ }
+
+ /**
+ * Shows an element by changing its CSS display style as empty.
+ * @param TControl control element or element id
+ */
+ public function show($element)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->callClientFunction('Element.show', $element);
+ }
+
+ /**
+ * Hides an element by changing its CSS display style to "none".
+ * @param TControl control element or element id
+ */
+ public function hide($element)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->callClientFunction('Element.hide', $element);
+ }
+
+ /**
+ * Toggles the visibility of the element.
+ * @param TControl control element or element id
+ * @param string visual effect, such as, 'appear' or 'slide' or 'blind'.
+ * @param array additional options.
+ */
+ public function toggle($element, $effect=null, $options=array())
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->callClientFunction('Element.toggle', array($element,$effect,$options));
+ }
+
+ /**
+ * Removes an element from the HTML page.
+ * @param TControl control element or element id
+ */
+ public function remove($element)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->callClientFunction('Element.remove', $element);
+ }
+
+ public function addPostDataLoader($name)
+ {
+ $this->callClientFunction('Prado.CallbackRequest.addPostLoaders', $name);
+ }
+
+ /**
+ * Update the element's innerHTML with new content.
+ * @param TControl control element or element id
+ * @param TControl new HTML content, if content is of a TControl, the
+ * controls render method is called.
+ */
+ public function update($element, $content)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->replace($element, $content, 'Element.update');
+ }
+
+ /**
+ * Add a Css class name to the element.
+ * @param TControl control element or element id
+ * @param string CssClass name to add.
+ */
+ public function addCssClass($element, $cssClass)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->callClientFunction('Element.addClassName', array($element, $cssClass));
+ }
+
+ /**
+ * Remove a Css class name from the element.
+ * @param TControl control element or element id
+ * @param string CssClass name to remove.
+ */
+ public function removeCssClass($element, $cssClass)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->callClientFunction('Element.removeClassName', array($element, $cssClass));
+ }
+
+ /**
+ * Sets the CssClass of an element.
+ * @param TControl control element or element id
+ * @param string new CssClass name for the element.
+ */
+ /*public function setCssClass($element, $cssClass)
+ {
+ $this->callClientFunction('Prado.Element.CssClass.set', array($element, $cssClass));
+ }*/
+
+ /**
+ * Scroll the top of the browser viewing area to the location of the
+ * element.
+ * @param TControl control element or element id
+ */
+ public function scrollTo($element)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->callClientFunction('Element.scrollTo', $element);
+ }
+
+ /**
+ * Focus on a particular element.
+ * @param TControl control element or element id.
+ */
+ public function focus($element)
+ {
+ $this->callClientFunction('Prado.Element.focus', $element);
+ }
+
+ /**
+ * Sets the style of element. The style must be a key-value array where the
+ * key is the style property and the value is the style value.
+ * @param TControl control element or element id
+ * @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();
+ $this->callClientFunction('Prado.Element.setStyle', array($element, $styles));
+ }
+
+ /**
+ * Append a HTML fragement to the element.
+ * @param TControl control element or element id
+ * @param string HTML fragement or the control to be rendered
+ */
+ public function appendContent($element, $content)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->replace($element, $content, 'Prado.Element.Insert.append');
+ }
+
+ /**
+ * Prepend a HTML fragement to the element.
+ * @param TControl control element or element id
+ * @param string HTML fragement or the control to be rendered
+ */
+ public function prependContent($element, $content)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->replace($element, $content, 'Prado.Element.Insert.prepend');
+ }
+
+ /**
+ * Insert a HTML fragement after the element.
+ * @param TControl control element or element id
+ * @param string HTML fragement or the control to be rendered
+ */
+ public function insertContentAfter($element, $content)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->replace($element, $content, 'Prado.Element.Insert.after');
+ }
+
+ /**
+ * Insert a HTML fragement in before the element.
+ * @param TControl control element or element id
+ * @param string HTML fragement or the control to be rendered
+ */
+ public function insertContentBefore($element, $content)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->replace($element, $content, 'Prado.Element.Insert.before');
+ }
+
+ /**
+ * Replace the content of an element with new content. The new content can
+ * be a string or a TControl component. If the <tt>content</tt> parameter is
+ * a TControl component, its rendered method will be called and its contents
+ * will be used for replacement.
+ * @param TControl control element or HTML element id.
+ * @param string HTML fragement or the control to be rendered
+ * @param string replacement method, default is to replace the outter
+ * html content.
+ * @param string provide a custom boundary.
+ * @see insertAbout
+ * @see insertBelow
+ * @see insertBefore
+ * @see insertAfter
+ */
+ protected function replace($element, $content, $method="Element.replace", $boundary=null)
+ {
+ if($content instanceof TControl)
+ {
+ $boundary = $this->getRenderedContentBoundary($content);
+ $content = null;
+ }
+ else if($content instanceof THtmlWriter)
+ {
+ $boundary = $this->getResponseContentBoundary($content);
+ $content = null;
+ }
+
+ $this->callClientFunction('Prado.Element.replace',
+ array($element, $method, $content, $boundary));
+ }
+
+ /**
+ * Replace the content of an element with new content contained in writer.
+ * @param TControl control element or HTML element id.
+ * @param string HTML fragement or the control to be rendered
+ */
+ public function replaceContent($element,$content)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->replace($element, $content);
+ }
+
+ /**
+ * Evaluate a block of javascript enclosed in a boundary.
+ * @param THtmlWriter writer for the content.
+ */
+ public function evaluateScript($writer)
+ {
+ $this->replace(null, $writer, 'Prado.Element.evaluateScript');
+ }
+
+ /**
+ * Appends a block of inline javascript enclosed in a boundary.
+ * Similar to to evaluateScript(), but functions declared in the
+ * inline block will be available to page elements.
+ * @param THtmlWriter writer for the content.
+ */
+ public function appendScriptBlock($content)
+ {
+ if($content instanceof TControl)
+ {
+ $boundary = $this->getRenderedContentBoundary($content);
+ }
+ else if($content instanceof THtmlWriter)
+ {
+ $boundary = $this->getResponseContentBoundary($content);
+ }
+
+ $this->callClientFunction('Prado.Element.appendScriptBlock', array($boundary));
+ }
+
+ /**
+ * Renders the control and return the content boundary from
+ * TCallbackResponseWriter. This method should only be used by framework
+ * component developers. The render() method is defered to be called in the
+ * TActivePageAdapter class.
+ * @param TControl control to be rendered on callback response.
+ * @return string the boundary for which the rendered content is wrapped.
+ */
+ private function getRenderedContentBoundary($control)
+ {
+ $writer = $this->getResponse()->createHtmlWriter();
+ $adapter = $control->getPage()->getAdapter();
+ $adapter->registerControlToRender($control, $writer);
+ return $writer->getWriter()->getBoundary();
+ }
+
+ /**
+ * @param THtmlWriter the writer responsible for rendering html content.
+ * @return string content boundary.
+ */
+ private function getResponseContentBoundary($html)
+ {
+ if($html instanceof THtmlWriter)
+ {
+ if($html->getWriter() instanceof TCallbackResponseWriter)
+ return $html->getWriter()->getBoundary();
+ }
+ return null;
+ }
+
+ /**
+ * Add a visual effect the element.
+ * @param string visual effect function name.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function visualEffect($type, $element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->callClientFunction($type, array($element, $options));
+ }
+
+ /**
+ * Visual Effect: Gradually make the element appear.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function appear($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.Appear', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Blind down.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function blindDown($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.BlindDown', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Blind up.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function blindUp($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.BlindUp', $element, $options);
+
+ }
+
+ /**
+ * Visual Effect: Drop out.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function dropOut($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.DropOut', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Gradually fade the element.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function fade($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.Fade', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Fold.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function fold($element, $options = null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.Fold', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Gradually make an element grow to a predetermined size.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function grow($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.Grow', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Gradually grow and fade the element.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function puff($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.Puff', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Pulsate.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function pulsate($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.Pulsate', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Shake the element.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function shake($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.Shake', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Shrink the element.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function shrink($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.Shrink', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Slide down.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function slideDown($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.SlideDown', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Side up.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function slideUp($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.SlideUp', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Squish the element.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function squish($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.Squish', $element, $options);
+ }
+
+ /**
+ * Visual Effect: Switch Off effect.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function switchOff($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Effect.SwitchOff', $element, $options);
+ }
+
+ /**
+ * Visual Effect: High light the element for about 2 seconds.
+ * @param TControl control element or element id
+ * @param array visual effect key-value pair options.
+ */
+ public function highlight($element, $options=null)
+ {
+ if ($element instanceof ISurroundable)
+ $element=$element->getSurroundingTagID();
+ $this->visualEffect('Prado.Effect.Highlight', $element, $options);
+ }
+
+ /**
+ * Set the opacity on a html element or control.
+ * @param TControl control element or element id
+ * @param float opacity value between 1 and 0
+ */
+ public function setOpacity($element, $value)
+ {
+ 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 10231a1c..0d602fa5 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientSide.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientSide.php
@@ -1,322 +1,322 @@
-<?php
-/**
- * TCallbackClientSide class file
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * TCallbackClientSide class.
- *
- * The following client side events are executing in order if the callback
- * request and response are send and received successfuly.
- *
- * - <b>onPreDispatch</b> executed before a request is dispatched.
- * - <b>onUninitialized</b> executed when callback request is uninitialized.
- * - <b>onLoading</b>* executed when callback request is initiated
- * - <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.
- * - <b>onSuccess</b> executed when callback request returns and is successful.
- * - <b>onFailure</b> executed when callback request returns and fails.
- * - <b>onException</b> raised when callback request fails due to request/response errors.
- *
- * * 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
- * OnSuccess event otherwise OnFailure will be raised.
- *
- * - <b>PostState</b> true to collect the form inputs and post them during callback, default is true.
- * - <b>RequestTimeOut</b> The request timeout in milliseconds.
- * - <b>HasPriority</b> true to ensure that the callback request will be sent
- * immediately and will abort existing prioritized requests. It does not affect
- * callbacks that are not prioritized.
- * - <b>EnablePageStateUpdate</b> enable the callback response to enable the
- * viewstate update. This will automatically set HasPriority to true when enabled.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TCallbackClientSide extends TClientSideOptions
-{
- /**
- * Returns javascript statement enclosed within a javascript function.
- * @param string javascript statement
- * @return string javascript statement wrapped in a javascript function
- */
- protected function ensureFunction($javascript)
- {
- return "function(sender, parameter){ {$javascript} }";
- }
-
- /**
- * @param string javascript code to be executed before a request is dispatched.
- */
- public function setOnPreDispatch($javascript)
- {
- $this->setFunction('onPreDispatch', $javascript);
- }
-
- /**
- * @return string javascript code to be executed before a request is dispatched.
- */
- public function getOnPreDispatch()
- {
- return $this->getOption('onPreDispatch');
- }
-
- /**
- * @return string javascript code for client-side onUninitialized event
- */
- public function getOnUninitialized()
- {
- return $this->getOption('onUninitialized');
- }
-
- /**
- * @param string javascript code for client-side onUninitialized event.
- */
- public function setOnUninitialized($javascript)
- {
- $this->setFunction('onUninitialized', $javascript);
- }
-
- /**
- * @return string javascript code for client-side onLoading event
- */
- public function getOnLoading()
- {
- return $this->getOption('onLoading');
- }
-
- /**
- * @param string javascript code for client-side onLoading event.
- */
- public function setOnLoading($javascript)
- {
- $this->setFunction('onLoading', $javascript);
- }
-
- /**
- * @return string javascript code for client-side onLoaded event
- */
- public function getOnLoaded()
- {
- return $this->getOption('onLoaded');
- }
-
- /**
- * @param string javascript code for client-side onLoaded event.
- */
- public function setOnLoaded($javascript)
- {
- $this->setFunction('onLoaded', $javascript);
- }
- /**
- * @return string javascript code for client-side onInteractive event
- */
- public function getOnInteractive()
- {
- return $this->getOption('onInteractive');
- }
-
- /**
- * @param string javascript code for client-side onInteractive event.
- */
- public function setOnInteractive($javascript)
- {
- $this->setFunction('onInteractive', $javascript);
- }
- /**
- * @return string javascript code for client-side onComplete event
- */
- public function getOnComplete()
- {
- return $this->getOption('onComplete');
- }
-
- /**
- * @param string javascript code for client-side onComplete event.
- */
- public function setOnComplete($javascript)
- {
- $this->setFunction('onComplete', $javascript);
- }
- /**
- * @return string javascript code for client-side onSuccess event
- */
- public function getOnSuccess()
- {
- return $this->getOption('onSuccess');
- }
-
- /**
- * @param string javascript code for client-side onSuccess event.
- */
- public function setOnSuccess($javascript)
- {
- $this->setFunction('onSuccess', $javascript);
- }
-
- /**
- * @return string javascript code for client-side onFailure event
- */
- public function getOnFailure()
- {
- return $this->getOption('onFailure');
- }
-
- /**
- * @param string javascript code for client-side onFailure event.
- */
- public function setOnFailure($javascript)
- {
- $this->setFunction('onFailure', $javascript);
- }
-
- /**
- * @return string javascript code for client-side onException event
- */
- public function getOnException()
- {
- return $this->getOption('onException');
- }
-
- /**
- * @param string javascript code for client-side onException event.
- */
- public function setOnException($javascript)
- {
- $this->setFunction('onException', $javascript);
- }
-
- /**
- * @return boolean true to post the inputs of the form on callback, default
- * is post the inputs on callback.
- */
- public function getPostState()
- {
- return $this->getOption('PostInputs');
- }
-
- /**
- * @param boolean true to post the inputs of the form with callback
- * requests. Default is to post the inputs.
- */
- public function setPostState($value)
- {
- $this->setOption('PostInputs', TPropertyValue::ensureBoolean($value));
- }
-
- /**
- * @return integer callback request timeout.
- */
- public function getRequestTimeOut()
- {
- return $this->getOption('RequestTimeOut');
- }
-
- /**
- * @param integer callback request timeout
- */
- public function setRequestTimeOut($value)
- {
- $this->setOption('RequestTimeOut', TPropertyValue::ensureInteger($value));
- }
-
- /**
- * @return boolean true if the callback request has priority and will abort
- * existing prioritized request in order to send immediately. It does not
- * affect callbacks that are not prioritized. Default is true.
- */
- public function getHasPriority()
- {
- $option = $this->getOption('HasPriority');
- return ($option===null) ? true : $option;
- }
-
- /**
- * @param boolean true to ensure that the callback request will be sent
- * immediately and will abort existing prioritized requests. It does not
- * affect callbacks that are not prioritized.
- */
- public function setHasPriority($value)
- {
- $hasPriority = TPropertyValue::ensureBoolean($value);
- $this->setOption('HasPriority', $hasPriority);
- if(!$hasPriority)
- $this->setEnablePageStateUpdate(false);
- }
-
- /**
- * Set to true to enable the callback response to enable the viewstate
- * update. This will automatically set HasPrority to true.
- * @param boolean true enables the callback response to update the
- * viewstate.
- */
- public function setEnablePageStateUpdate($value)
- {
- $enabled = TPropertyValue::ensureBoolean($value);
- $this->setOption('EnablePageStateUpdate', $enabled);
- if($enabled)
- $this->setHasPriority(true);
- }
-
- /**
- * @return boolean client-side viewstate will be updated on callback
- * response if true. Default is true.
- */
- public function getEnablePageStateUpdate()
- {
- $option = $this->getOption('EnablePageStateUpdate');
- return ($option===null) ? true : $option;
- }
-
- /**
- * @return string post back target ID
- */
- public function getPostBackTarget()
- {
- return $this->getOption('EventTarget');
- }
-
- /**
- * @param string post back target ID
- */
- public function setPostBackTarget($value)
- {
- if($value instanceof TControl)
- $value = $value->getUniqueID();
- $this->setOption('EventTarget', $value);
- }
-
- /**
- * @return string post back event parameter.
- */
- public function getPostBackParameter()
- {
- return $this->getOption('EventParameter');
- }
-
- /**
- * @param string post back event parameter.
- */
- public function setPostBackParameter($value)
- {
- $this->setOption('EventParameter', $value);
- }
-}
-
+<?php
+/**
+ * TCallbackClientSide class file
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * TCallbackClientSide class.
+ *
+ * The following client side events are executing in order if the callback
+ * request and response are send and received successfuly.
+ *
+ * - <b>onPreDispatch</b> executed before a request is dispatched.
+ * - <b>onUninitialized</b> executed when callback request is uninitialized.
+ * - <b>onLoading</b>* executed when callback request is initiated
+ * - <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.
+ * - <b>onSuccess</b> executed when callback request returns and is successful.
+ * - <b>onFailure</b> executed when callback request returns and fails.
+ * - <b>onException</b> raised when callback request fails due to request/response errors.
+ *
+ * * 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
+ * OnSuccess event otherwise OnFailure will be raised.
+ *
+ * - <b>PostState</b> true to collect the form inputs and post them during callback, default is true.
+ * - <b>RequestTimeOut</b> The request timeout in milliseconds.
+ * - <b>HasPriority</b> true to ensure that the callback request will be sent
+ * immediately and will abort existing prioritized requests. It does not affect
+ * callbacks that are not prioritized.
+ * - <b>EnablePageStateUpdate</b> enable the callback response to enable the
+ * viewstate update. This will automatically set HasPriority to true when enabled.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TCallbackClientSide extends TClientSideOptions
+{
+ /**
+ * Returns javascript statement enclosed within a javascript function.
+ * @param string javascript statement
+ * @return string javascript statement wrapped in a javascript function
+ */
+ protected function ensureFunction($javascript)
+ {
+ return "function(sender, parameter){ {$javascript} }";
+ }
+
+ /**
+ * @param string javascript code to be executed before a request is dispatched.
+ */
+ public function setOnPreDispatch($javascript)
+ {
+ $this->setFunction('onPreDispatch', $javascript);
+ }
+
+ /**
+ * @return string javascript code to be executed before a request is dispatched.
+ */
+ public function getOnPreDispatch()
+ {
+ return $this->getOption('onPreDispatch');
+ }
+
+ /**
+ * @return string javascript code for client-side onUninitialized event
+ */
+ public function getOnUninitialized()
+ {
+ return $this->getOption('onUninitialized');
+ }
+
+ /**
+ * @param string javascript code for client-side onUninitialized event.
+ */
+ public function setOnUninitialized($javascript)
+ {
+ $this->setFunction('onUninitialized', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side onLoading event
+ */
+ public function getOnLoading()
+ {
+ return $this->getOption('onLoading');
+ }
+
+ /**
+ * @param string javascript code for client-side onLoading event.
+ */
+ public function setOnLoading($javascript)
+ {
+ $this->setFunction('onLoading', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side onLoaded event
+ */
+ public function getOnLoaded()
+ {
+ return $this->getOption('onLoaded');
+ }
+
+ /**
+ * @param string javascript code for client-side onLoaded event.
+ */
+ public function setOnLoaded($javascript)
+ {
+ $this->setFunction('onLoaded', $javascript);
+ }
+ /**
+ * @return string javascript code for client-side onInteractive event
+ */
+ public function getOnInteractive()
+ {
+ return $this->getOption('onInteractive');
+ }
+
+ /**
+ * @param string javascript code for client-side onInteractive event.
+ */
+ public function setOnInteractive($javascript)
+ {
+ $this->setFunction('onInteractive', $javascript);
+ }
+ /**
+ * @return string javascript code for client-side onComplete event
+ */
+ public function getOnComplete()
+ {
+ return $this->getOption('onComplete');
+ }
+
+ /**
+ * @param string javascript code for client-side onComplete event.
+ */
+ public function setOnComplete($javascript)
+ {
+ $this->setFunction('onComplete', $javascript);
+ }
+ /**
+ * @return string javascript code for client-side onSuccess event
+ */
+ public function getOnSuccess()
+ {
+ return $this->getOption('onSuccess');
+ }
+
+ /**
+ * @param string javascript code for client-side onSuccess event.
+ */
+ public function setOnSuccess($javascript)
+ {
+ $this->setFunction('onSuccess', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side onFailure event
+ */
+ public function getOnFailure()
+ {
+ return $this->getOption('onFailure');
+ }
+
+ /**
+ * @param string javascript code for client-side onFailure event.
+ */
+ public function setOnFailure($javascript)
+ {
+ $this->setFunction('onFailure', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side onException event
+ */
+ public function getOnException()
+ {
+ return $this->getOption('onException');
+ }
+
+ /**
+ * @param string javascript code for client-side onException event.
+ */
+ public function setOnException($javascript)
+ {
+ $this->setFunction('onException', $javascript);
+ }
+
+ /**
+ * @return boolean true to post the inputs of the form on callback, default
+ * is post the inputs on callback.
+ */
+ public function getPostState()
+ {
+ return $this->getOption('PostInputs');
+ }
+
+ /**
+ * @param boolean true to post the inputs of the form with callback
+ * requests. Default is to post the inputs.
+ */
+ public function setPostState($value)
+ {
+ $this->setOption('PostInputs', TPropertyValue::ensureBoolean($value));
+ }
+
+ /**
+ * @return integer callback request timeout.
+ */
+ public function getRequestTimeOut()
+ {
+ return $this->getOption('RequestTimeOut');
+ }
+
+ /**
+ * @param integer callback request timeout
+ */
+ public function setRequestTimeOut($value)
+ {
+ $this->setOption('RequestTimeOut', TPropertyValue::ensureInteger($value));
+ }
+
+ /**
+ * @return boolean true if the callback request has priority and will abort
+ * existing prioritized request in order to send immediately. It does not
+ * affect callbacks that are not prioritized. Default is true.
+ */
+ public function getHasPriority()
+ {
+ $option = $this->getOption('HasPriority');
+ return ($option===null) ? true : $option;
+ }
+
+ /**
+ * @param boolean true to ensure that the callback request will be sent
+ * immediately and will abort existing prioritized requests. It does not
+ * affect callbacks that are not prioritized.
+ */
+ public function setHasPriority($value)
+ {
+ $hasPriority = TPropertyValue::ensureBoolean($value);
+ $this->setOption('HasPriority', $hasPriority);
+ if(!$hasPriority)
+ $this->setEnablePageStateUpdate(false);
+ }
+
+ /**
+ * Set to true to enable the callback response to enable the viewstate
+ * update. This will automatically set HasPrority to true.
+ * @param boolean true enables the callback response to update the
+ * viewstate.
+ */
+ public function setEnablePageStateUpdate($value)
+ {
+ $enabled = TPropertyValue::ensureBoolean($value);
+ $this->setOption('EnablePageStateUpdate', $enabled);
+ if($enabled)
+ $this->setHasPriority(true);
+ }
+
+ /**
+ * @return boolean client-side viewstate will be updated on callback
+ * response if true. Default is true.
+ */
+ public function getEnablePageStateUpdate()
+ {
+ $option = $this->getOption('EnablePageStateUpdate');
+ return ($option===null) ? true : $option;
+ }
+
+ /**
+ * @return string post back target ID
+ */
+ public function getPostBackTarget()
+ {
+ return $this->getOption('EventTarget');
+ }
+
+ /**
+ * @param string post back target ID
+ */
+ public function setPostBackTarget($value)
+ {
+ if($value instanceof TControl)
+ $value = $value->getUniqueID();
+ $this->setOption('EventTarget', $value);
+ }
+
+ /**
+ * @return string post back event parameter.
+ */
+ public function getPostBackParameter()
+ {
+ return $this->getOption('EventParameter');
+ }
+
+ /**
+ * @param string post back event parameter.
+ */
+ public function setPostBackParameter($value)
+ {
+ $this->setOption('EventParameter', $value);
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TCallbackEventParameter.php b/framework/Web/UI/ActiveControls/TCallbackEventParameter.php
index d4038fb5..7c532588 100644
--- a/framework/Web/UI/ActiveControls/TCallbackEventParameter.php
+++ b/framework/Web/UI/ActiveControls/TCallbackEventParameter.php
@@ -1,87 +1,87 @@
-<?php
-/**
- * TCallbackEventParameter class file.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * TCallbackEventParameter class.
- *
- * The TCallbackEventParameter provides the parameter passed during the callback
- * request in the {@link getCallbackParameter CallbackParameter} property. The
- * callback response content (e.g. new HTML content) must be rendered
- * using an THtmlWriter obtained from the {@link getNewWriter NewWriter}
- * property, which returns a <b>NEW</b> instance of TCallbackResponseWriter.
- *
- * Each instance TCallbackResponseWriter is associated with a unique
- * boundary delimited. By default each panel only renders its own content.
- * To replace the content of ONE panel with that of rendered from multiple panels
- * use the same writer instance for the panels to be rendered.
- *
- * The response data (i.e., passing results back to the client-side
- * callback handler function) can be set using {@link setResponseData ResponseData} property.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @version $Id: TActivePageAdapter.php 1648 2007-01-24 05:52:22Z wei $
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TCallbackEventParameter extends TEventParameter
-{
- /**
- * @var THttpResponse output content.
- */
- private $_response;
- /**
- * @var mixed callback request parameter.
- */
- private $_parameter;
-
- /**
- * Creates a new TCallbackEventParameter.
- */
- public function __construct($response, $parameter)
- {
- $this->_response = $response;
- $this->_parameter = $parameter;
- }
-
- /**
- * @return TCallbackResponseWriter holds the response content.
- */
- public function getNewWriter()
- {
- return $this->_response->createHtmlWriter(null);
- }
-
- /**
- * @return mixed callback request parameter.
- */
- public function getCallbackParameter()
- {
- return $this->_parameter;
- }
-
- /**
- * @param mixed callback response data.
- */
- public function setResponseData($value)
- {
- $this->_response->getAdapter()->setResponseData($value);
- }
-
- /**
- * @return mixed callback response data.
- */
- public function getResponseData()
- {
- return $this->_response->getAdapter()->getResponseData();
- }
-}
-
+<?php
+/**
+ * TCallbackEventParameter class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * TCallbackEventParameter class.
+ *
+ * The TCallbackEventParameter provides the parameter passed during the callback
+ * request in the {@link getCallbackParameter CallbackParameter} property. The
+ * callback response content (e.g. new HTML content) must be rendered
+ * using an THtmlWriter obtained from the {@link getNewWriter NewWriter}
+ * property, which returns a <b>NEW</b> instance of TCallbackResponseWriter.
+ *
+ * Each instance TCallbackResponseWriter is associated with a unique
+ * boundary delimited. By default each panel only renders its own content.
+ * To replace the content of ONE panel with that of rendered from multiple panels
+ * use the same writer instance for the panels to be rendered.
+ *
+ * The response data (i.e., passing results back to the client-side
+ * callback handler function) can be set using {@link setResponseData ResponseData} property.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @version $Id: TActivePageAdapter.php 1648 2007-01-24 05:52:22Z wei $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TCallbackEventParameter extends TEventParameter
+{
+ /**
+ * @var THttpResponse output content.
+ */
+ private $_response;
+ /**
+ * @var mixed callback request parameter.
+ */
+ private $_parameter;
+
+ /**
+ * Creates a new TCallbackEventParameter.
+ */
+ public function __construct($response, $parameter)
+ {
+ $this->_response = $response;
+ $this->_parameter = $parameter;
+ }
+
+ /**
+ * @return TCallbackResponseWriter holds the response content.
+ */
+ public function getNewWriter()
+ {
+ return $this->_response->createHtmlWriter(null);
+ }
+
+ /**
+ * @return mixed callback request parameter.
+ */
+ public function getCallbackParameter()
+ {
+ return $this->_parameter;
+ }
+
+ /**
+ * @param mixed callback response data.
+ */
+ public function setResponseData($value)
+ {
+ $this->_response->getAdapter()->setResponseData($value);
+ }
+
+ /**
+ * @return mixed callback response data.
+ */
+ public function getResponseData()
+ {
+ return $this->_response->getAdapter()->getResponseData();
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TCallbackOptions.php b/framework/Web/UI/ActiveControls/TCallbackOptions.php
index baba32e1..e75c2fde 100644
--- a/framework/Web/UI/ActiveControls/TCallbackOptions.php
+++ b/framework/Web/UI/ActiveControls/TCallbackOptions.php
@@ -1,53 +1,53 @@
-<?php
-/**
- * TCallbackOptions component class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * TCallbackOptions class.
- *
- * TCallbackOptions allows common set of callback client-side options
- * to be attached to other active controls.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TCallbackOptions extends TControl
-{
- /**
- * @var TCallbackClientSide client side callback options.
- */
- private $_clientSide;
-
- /**
- * Callback client-side options can be set by setting the properties of
- * the ClientSide property. E.g. <com:TCallbackOptions ClientSide.OnSuccess="..." />
- * See {@link TCallbackClientSide} for details on the properties of
- * ClientSide.
- * @return TCallbackClientSide client-side callback options.
- */
- public function getClientSide()
- {
- if($this->_clientSide===null)
- $this->_clientSide = $this->createClientSide();
- return $this->_clientSide;
- }
-
- /**
- * @return TCallbackClientSide callback client-side options.
- */
- protected function createClientSide()
- {
- return Prado::createComponent('System.Web.UI.ActiveControls.TCallbackClientSide');
- }
-}
-
+<?php
+/**
+ * TCallbackOptions component class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * TCallbackOptions class.
+ *
+ * TCallbackOptions allows common set of callback client-side options
+ * to be attached to other active controls.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TCallbackOptions extends TControl
+{
+ /**
+ * @var TCallbackClientSide client side callback options.
+ */
+ private $_clientSide;
+
+ /**
+ * Callback client-side options can be set by setting the properties of
+ * the ClientSide property. E.g. <com:TCallbackOptions ClientSide.OnSuccess="..." />
+ * See {@link TCallbackClientSide} for details on the properties of
+ * ClientSide.
+ * @return TCallbackClientSide client-side callback options.
+ */
+ public function getClientSide()
+ {
+ if($this->_clientSide===null)
+ $this->_clientSide = $this->createClientSide();
+ return $this->_clientSide;
+ }
+
+ /**
+ * @return TCallbackClientSide callback client-side options.
+ */
+ protected function createClientSide()
+ {
+ return Prado::createComponent('System.Web.UI.ActiveControls.TCallbackClientSide');
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php b/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php
index c28b435c..38aaabec 100644
--- a/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php
+++ b/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php
@@ -1,95 +1,95 @@
-<?php
-/**
- * TEventTriggeredCallback class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-Prado::using('System.Web.UI.ActiveControls.TTriggeredCallback');
-
-/**
- * TEventTriggeredCallback Class
- *
- * Triggers a new callback request when a particular {@link setEventName EventName}
- * on a control with ID given by {@link setControlID ControlID} is raised.
- *
- * The default action of the event on the client-side can be prevented when
- * {@link setPreventDefaultAction PreventDefaultAction} is set to true.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TEventTriggeredCallback extends TTriggeredCallback
-{
- /**
- * @return string The client-side event name the trigger listens to.
- */
- public function getEventName()
- {
- return $this->getViewState('EventName', '');
- }
-
- /**
- * Sets the client-side event name that fires the callback request.
- * @param string The client-side event name the trigger listens to.
- */
- public function setEventName($value)
- {
- $this->setViewState('EventName', $value, '');
- }
-
- /**
- * @param boolean true to prevent/stop default event action.
- */
- public function setPreventDefaultAction($value)
- {
- $this->setViewState('StopEvent', TPropertyValue::ensureBoolean($value), false);
- }
-
- /**
- * @return boolean true to prevent/stop default event action.
- */
- public function getPreventDefaultAction()
- {
- return $this->getViewState('StopEvent', false);
- }
-
- /**
- * @return array list of timer options for client-side.
- */
- protected function getTriggerOptions()
- {
- $options = parent::getTriggerOptions();
- $name = preg_replace('/^on/', '', $this->getEventName());
- $options['EventName'] = strtolower($name);
- $options['StopEvent'] = $this->getPreventDefaultAction();
- return $options;
- }
-
- /**
- * Registers the javascript code for initializing the active control.
- * @param THtmlWriter the renderer.
- */
- public function render($writer)
- {
- parent::render($writer);
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getTriggerOptions());
- }
-
- /**
- * @return string corresponding javascript class name for TEventTriggeredCallback.
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TEventTriggeredCallback';
- }
-}
-
+<?php
+/**
+ * TEventTriggeredCallback class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TTriggeredCallback');
+
+/**
+ * TEventTriggeredCallback Class
+ *
+ * Triggers a new callback request when a particular {@link setEventName EventName}
+ * on a control with ID given by {@link setControlID ControlID} is raised.
+ *
+ * The default action of the event on the client-side can be prevented when
+ * {@link setPreventDefaultAction PreventDefaultAction} is set to true.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TEventTriggeredCallback extends TTriggeredCallback
+{
+ /**
+ * @return string The client-side event name the trigger listens to.
+ */
+ public function getEventName()
+ {
+ return $this->getViewState('EventName', '');
+ }
+
+ /**
+ * Sets the client-side event name that fires the callback request.
+ * @param string The client-side event name the trigger listens to.
+ */
+ public function setEventName($value)
+ {
+ $this->setViewState('EventName', $value, '');
+ }
+
+ /**
+ * @param boolean true to prevent/stop default event action.
+ */
+ public function setPreventDefaultAction($value)
+ {
+ $this->setViewState('StopEvent', TPropertyValue::ensureBoolean($value), false);
+ }
+
+ /**
+ * @return boolean true to prevent/stop default event action.
+ */
+ public function getPreventDefaultAction()
+ {
+ return $this->getViewState('StopEvent', false);
+ }
+
+ /**
+ * @return array list of timer options for client-side.
+ */
+ protected function getTriggerOptions()
+ {
+ $options = parent::getTriggerOptions();
+ $name = preg_replace('/^on/', '', $this->getEventName());
+ $options['EventName'] = strtolower($name);
+ $options['StopEvent'] = $this->getPreventDefaultAction();
+ return $options;
+ }
+
+ /**
+ * Registers the javascript code for initializing the active control.
+ * @param THtmlWriter the renderer.
+ */
+ public function render($writer)
+ {
+ parent::render($writer);
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getTriggerOptions());
+ }
+
+ /**
+ * @return string corresponding javascript class name for TEventTriggeredCallback.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TEventTriggeredCallback';
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
index aba477b9..47c8aeac 100644
--- a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
+++ b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
@@ -1,290 +1,290 @@
-<?php
-/**
- * TInPlaceTextBox class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
-
-/**
- * TInPlaceTextBox Class
- * *
- * TInPlaceTextBox is a component rendered as a label and allows its
- * contents to be edited by changing the label to a textbox when
- * the label is clicked or when another control or html element with
- * ID given by {@link setEditTriggerControlID EditTriggerControlID} is clicked.
- *
- * If the {@link OnLoadingText} event is handled, a callback request is
- * made when the label is clicked, while the request is being made the
- * textbox is disabled from editing. The {@link OnLoadingText} event allows
- * you to update the content of the textbox before the client is allowed
- * to edit the content. After the callback request returns successfully,
- * the textbox is enabled and the contents is then allowed to be edited.
- *
- * Once the textbox loses focus, if {@link setAutoPostBack AutoPostBack}
- * is true and the textbox content has changed, a callback request is made and
- * the {@link OnTextChanged} event is raised like that of the TActiveTextBox.
- * During the request, the textbox is disabled.
- *
- * 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
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TInPlaceTextBox extends TActiveTextBox
-{
- /**
- * Sets the auto post back to true by default.
- */
- public function __construct()
- {
- parent::__construct();
- $this->setAutoPostBack(true);
- }
-
- /**
- * @param boolean true to hide the textbox after losing focus.
- */
- public function setAutoHideTextBox($value)
- {
- $this->setViewState('AutoHide', TPropertyValue::ensureBoolean($value), true);
- }
-
- /**
- * @return boolean true will hide the textbox after losing focus.
- */
- public function getAutoHideTextBox()
- {
- return $this->getViewState('AutoHide', true);
- }
-
- /**
- * @param boolean true to display the edit textbox
- */
- public function setDisplayTextBox($value)
- {
- $value = TPropertyValue::ensureBoolean($value);
- $this->setViewState('DisplayTextBox', $value,false);
- if($this->getActiveControl()->canUpdateClientSide())
- $this->callClientFunction('setDisplayTextBox',$value);
- }
-
- /**
- * @return boolean true to display the edit textbox
- */
- public function getDisplayTextBox()
- {
- return $this->getViewState('DisplayTextBox', false);
- }
-
- /**
- * Calls the client-side static method for this control class.
- * @param string static method name
- * @param mixed method parmaeter
- */
- protected function callClientFunction($func,$value)
- {
- $client = $this->getPage()->getCallbackClient();
- $code = $this->getClientClassName().'.'.$func;
- $client->callClientFunction($code,array($this,$value));
- }
-
- /**
- * @param string ID of the control that can trigger to edit the textbox
- */
- public function setEditTriggerControlID($value)
- {
- $this->setViewState('EditTriggerControlID', $value);
- }
-
- /**
- * @return string ID of the control that can trigger to edit the textbox
- */
- public function getEditTriggerControlID()
- {
- return $this->getViewState('EditTriggerControlID');
- }
-
- /**
- * @return string edit trigger control client ID.
- */
- protected function getExternalControlID()
- {
- $extID = $this->getEditTriggerControlID();
- if($extID===null) return '';
- if(($control = $this->findControl($extID))!==null)
- return $control->getClientID();
- return $extID;
- }
-
- /**
- * On callback response, the inner HTMl of the label and the
- * value of the textbox is updated
- * @param string the text value of the label
- */
- public function setText($value)
- {
- TTextBox::setText($value);
- if($this->getActiveControl()->canUpdateClientSide())
- {
- $client = $this->getPage()->getCallbackClient();
- $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);
- }
- }
-
- /**
- * @return string tag name of the label.
- */
- protected function getTagName()
- {
- return 'span';
- }
-
- /**
- * Renders the body content of the label.
- * @param THtmlWriter the writer for rendering
- */
- public function renderContents($writer)
- {
- if(($text=$this->getText())==='')
- parent::renderContents($writer);
- else
- $writer->write($text);
- }
-
- /**
- * @return string label client ID
- */
- protected function getLabelClientID()
- {
- return $this->getClientID().'__label';
- }
-
- /**
- * This method is invoked when a callback is requested. The method raises
- * 'OnCallback' event to fire up the event handlers. If you override this
- * method, be sure to call the parent implementation so that the event
- * handler can be invoked.
- * @param TCallbackEventParameter event parameter to be passed to the event handlers
- */
- public function onCallback($param)
- {
- $action = $param->getCallbackParameter();
- if(is_array($action) && $action[0] === '__InlineEditor_loadExternalText__')
- {
- $parameter = new TCallbackEventParameter($this->getResponse(), $action[1]);
- $this->onLoadingText($parameter);
- }
- $this->raiseEvent('OnCallback', $this, $param);
- }
-
- /**
- * @return array callback options.
- */
- protected function getPostBackOptions()
- {
- $options = parent::getPostBackOptions();
- $options['ID'] = $this->getLabelClientID();
- $options['TextBoxID'] = $this->getClientID();
- $options['ExternalControl'] = $this->getExternalControlID();
- $options['AutoHide'] = $this->getAutoHideTextBox() == false ? '' : true;
- $options['AutoPostBack'] = $this->getAutoPostBack() == false ? '' : true;
- $options['Columns'] = $this->getColumns();
- if($this->getTextMode()==='MultiLine')
- {
- $options['Rows'] = $this->getRows();
- $options['Wrap'] = $this->getWrap()== false ? '' : true;
- }
- else
- {
- $length = $this->getMaxLength();
- $options['MaxLength'] = $length > 0 ? $length : '';
- }
-
- if($this->hasEventHandler('OnLoadingText'))
- $options['LoadTextOnEdit'] = true;
-
- $options['ReadOnly']=$this->getReadOnly();
- return $options;
- }
-
- /**
- * Raised when editing the content is requsted to be loaded from the
- * server side.
- * @param TCallbackEventParameter event parameter to be passed to the event handlers
- */
- public function onLoadingText($param)
- {
- $this->raiseEvent('OnLoadingText',$this,$param);
- }
-
- /**
- * @return string corresponding javascript class name for this TInPlaceTextBox
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TInPlaceTextBox';
- }
-
- /**
- * Ensure that the ID attribute is rendered and registers the javascript code
- * for initializing the active control.
- */
- protected function addAttributesToRender($writer)
- {
- //calls the TWebControl to avoid rendering other attribute normally render for a textbox.
- TWebControl::addAttributesToRender($writer);
- $writer->addAttribute('id',$this->getLabelClientID());
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
- }
-
- /**
- * Registers CSS and JS.
- * This method is invoked right before the control rendering, if the control is visible.
- * @param mixed event parameter
- */
- public function onPreRender($param)
- {
- parent::onPreRender($param);
- $this->registerClientScript();
- }
-
- /**
- * Registers the relevant JavaScript.
- */
- protected function registerClientScript()
- {
- $cs=$this->getPage()->getClientScript();
- $cs->registerPradoScript('inlineeditor');
- }
-}
+<?php
+/**
+ * TInPlaceTextBox class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
+
+/**
+ * TInPlaceTextBox Class
+ * *
+ * TInPlaceTextBox is a component rendered as a label and allows its
+ * contents to be edited by changing the label to a textbox when
+ * the label is clicked or when another control or html element with
+ * ID given by {@link setEditTriggerControlID EditTriggerControlID} is clicked.
+ *
+ * If the {@link OnLoadingText} event is handled, a callback request is
+ * made when the label is clicked, while the request is being made the
+ * textbox is disabled from editing. The {@link OnLoadingText} event allows
+ * you to update the content of the textbox before the client is allowed
+ * to edit the content. After the callback request returns successfully,
+ * the textbox is enabled and the contents is then allowed to be edited.
+ *
+ * Once the textbox loses focus, if {@link setAutoPostBack AutoPostBack}
+ * is true and the textbox content has changed, a callback request is made and
+ * the {@link OnTextChanged} event is raised like that of the TActiveTextBox.
+ * During the request, the textbox is disabled.
+ *
+ * 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
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TInPlaceTextBox extends TActiveTextBox
+{
+ /**
+ * Sets the auto post back to true by default.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAutoPostBack(true);
+ }
+
+ /**
+ * @param boolean true to hide the textbox after losing focus.
+ */
+ public function setAutoHideTextBox($value)
+ {
+ $this->setViewState('AutoHide', TPropertyValue::ensureBoolean($value), true);
+ }
+
+ /**
+ * @return boolean true will hide the textbox after losing focus.
+ */
+ public function getAutoHideTextBox()
+ {
+ return $this->getViewState('AutoHide', true);
+ }
+
+ /**
+ * @param boolean true to display the edit textbox
+ */
+ public function setDisplayTextBox($value)
+ {
+ $value = TPropertyValue::ensureBoolean($value);
+ $this->setViewState('DisplayTextBox', $value,false);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->callClientFunction('setDisplayTextBox',$value);
+ }
+
+ /**
+ * @return boolean true to display the edit textbox
+ */
+ public function getDisplayTextBox()
+ {
+ return $this->getViewState('DisplayTextBox', false);
+ }
+
+ /**
+ * Calls the client-side static method for this control class.
+ * @param string static method name
+ * @param mixed method parmaeter
+ */
+ protected function callClientFunction($func,$value)
+ {
+ $client = $this->getPage()->getCallbackClient();
+ $code = $this->getClientClassName().'.'.$func;
+ $client->callClientFunction($code,array($this,$value));
+ }
+
+ /**
+ * @param string ID of the control that can trigger to edit the textbox
+ */
+ public function setEditTriggerControlID($value)
+ {
+ $this->setViewState('EditTriggerControlID', $value);
+ }
+
+ /**
+ * @return string ID of the control that can trigger to edit the textbox
+ */
+ public function getEditTriggerControlID()
+ {
+ return $this->getViewState('EditTriggerControlID');
+ }
+
+ /**
+ * @return string edit trigger control client ID.
+ */
+ protected function getExternalControlID()
+ {
+ $extID = $this->getEditTriggerControlID();
+ if($extID===null) return '';
+ if(($control = $this->findControl($extID))!==null)
+ return $control->getClientID();
+ return $extID;
+ }
+
+ /**
+ * On callback response, the inner HTMl of the label and the
+ * value of the textbox is updated
+ * @param string the text value of the label
+ */
+ public function setText($value)
+ {
+ TTextBox::setText($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ {
+ $client = $this->getPage()->getCallbackClient();
+ $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);
+ }
+ }
+
+ /**
+ * @return string tag name of the label.
+ */
+ protected function getTagName()
+ {
+ return 'span';
+ }
+
+ /**
+ * Renders the body content of the label.
+ * @param THtmlWriter the writer for rendering
+ */
+ public function renderContents($writer)
+ {
+ if(($text=$this->getText())==='')
+ parent::renderContents($writer);
+ else
+ $writer->write($text);
+ }
+
+ /**
+ * @return string label client ID
+ */
+ protected function getLabelClientID()
+ {
+ return $this->getClientID().'__label';
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $action = $param->getCallbackParameter();
+ if(is_array($action) && $action[0] === '__InlineEditor_loadExternalText__')
+ {
+ $parameter = new TCallbackEventParameter($this->getResponse(), $action[1]);
+ $this->onLoadingText($parameter);
+ }
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * @return array callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ $options = parent::getPostBackOptions();
+ $options['ID'] = $this->getLabelClientID();
+ $options['TextBoxID'] = $this->getClientID();
+ $options['ExternalControl'] = $this->getExternalControlID();
+ $options['AutoHide'] = $this->getAutoHideTextBox() == false ? '' : true;
+ $options['AutoPostBack'] = $this->getAutoPostBack() == false ? '' : true;
+ $options['Columns'] = $this->getColumns();
+ if($this->getTextMode()==='MultiLine')
+ {
+ $options['Rows'] = $this->getRows();
+ $options['Wrap'] = $this->getWrap()== false ? '' : true;
+ }
+ else
+ {
+ $length = $this->getMaxLength();
+ $options['MaxLength'] = $length > 0 ? $length : '';
+ }
+
+ if($this->hasEventHandler('OnLoadingText'))
+ $options['LoadTextOnEdit'] = true;
+
+ $options['ReadOnly']=$this->getReadOnly();
+ return $options;
+ }
+
+ /**
+ * Raised when editing the content is requsted to be loaded from the
+ * server side.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onLoadingText($param)
+ {
+ $this->raiseEvent('OnLoadingText',$this,$param);
+ }
+
+ /**
+ * @return string corresponding javascript class name for this TInPlaceTextBox
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TInPlaceTextBox';
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ //calls the TWebControl to avoid rendering other attribute normally render for a textbox.
+ TWebControl::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getLabelClientID());
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
+
+ /**
+ * Registers CSS and JS.
+ * This method is invoked right before the control rendering, if the control is visible.
+ * @param mixed event parameter
+ */
+ public function onPreRender($param)
+ {
+ parent::onPreRender($param);
+ $this->registerClientScript();
+ }
+
+ /**
+ * Registers the relevant JavaScript.
+ */
+ protected function registerClientScript()
+ {
+ $cs=$this->getPage()->getClientScript();
+ $cs->registerPradoScript('inlineeditor');
+ }
+}
diff --git a/framework/Web/UI/ActiveControls/TTriggeredCallback.php b/framework/Web/UI/ActiveControls/TTriggeredCallback.php
index fd1fabb1..4b89cb8e 100644
--- a/framework/Web/UI/ActiveControls/TTriggeredCallback.php
+++ b/framework/Web/UI/ActiveControls/TTriggeredCallback.php
@@ -1,71 +1,71 @@
-<?php
-/**
- * TTriggeredCallback class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-Prado::using('System.Web.UI.ActiveControls.TCallback');
-/**
- * TTriggeredCallback abstract Class
- *
- * Base class for triggered callback controls. The {@link setControlID ControlID}
- * property sets the control ID to observe the trigger.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-abstract class TTriggeredCallback extends TCallback
-{
- /**
- * @return string The ID of the server control the trigger is bounded to.
- */
- public function getControlID()
- {
- return $this->getViewState('ControlID', '');
- }
-
- /**
- * @param string The ID of the server control the trigger is bounded to.
- */
- public function setControlID($value)
- {
- $this->setViewState('ControlID', $value, '');
- }
-
- /**
- * @return string target control client ID or html element ID if
- * control is not found in hierarchy.
- */
- protected function getTargetControl()
- {
- $id = $this->getControlID();
- if(($control=$this->findControl($id)) instanceof TControl)
- return $control->getClientID();
- if($id==='')
- {
- throw new TConfigurationException(
- 'ttriggeredcallback_invalid_controlid', get_class($this));
- }
- return $id;
- }
-
- /**
- * @return array list of trigger callback options.
- */
- protected function getTriggerOptions()
- {
- $options['ID'] = $this->getClientID();
- $options['EventTarget'] = $this->getUniqueID();
- $options['ControlID'] = $this->getTargetControl();
- return $options;
- }
-}
-
+<?php
+/**
+ * TTriggeredCallback class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TCallback');
+/**
+ * TTriggeredCallback abstract Class
+ *
+ * Base class for triggered callback controls. The {@link setControlID ControlID}
+ * property sets the control ID to observe the trigger.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+abstract class TTriggeredCallback extends TCallback
+{
+ /**
+ * @return string The ID of the server control the trigger is bounded to.
+ */
+ public function getControlID()
+ {
+ return $this->getViewState('ControlID', '');
+ }
+
+ /**
+ * @param string The ID of the server control the trigger is bounded to.
+ */
+ public function setControlID($value)
+ {
+ $this->setViewState('ControlID', $value, '');
+ }
+
+ /**
+ * @return string target control client ID or html element ID if
+ * control is not found in hierarchy.
+ */
+ protected function getTargetControl()
+ {
+ $id = $this->getControlID();
+ if(($control=$this->findControl($id)) instanceof TControl)
+ return $control->getClientID();
+ if($id==='')
+ {
+ throw new TConfigurationException(
+ 'ttriggeredcallback_invalid_controlid', get_class($this));
+ }
+ return $id;
+ }
+
+ /**
+ * @return array list of trigger callback options.
+ */
+ protected function getTriggerOptions()
+ {
+ $options['ID'] = $this->getClientID();
+ $options['EventTarget'] = $this->getUniqueID();
+ $options['ControlID'] = $this->getTargetControl();
+ return $options;
+ }
+}
+
diff --git a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
index 58a78d08..899419ee 100644
--- a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
+++ b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
@@ -1,120 +1,120 @@
-<?php
-/**
- * TValueTriggeredCallback class file.
- *
- * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- */
-
-Prado::using('System.Web.UI.ActiveControls.TTriggeredCallback');
-
-/**
- * TValueTriggeredCallback Class
- *
- * 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 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
- * observed, the polling interval is reset to the original value.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.Web.UI.ActiveControls
- * @since 3.1
- */
-class TValueTriggeredCallback extends TTriggeredCallback
-{
- /**
- * @return string The control property name to observe value changes.
- */
- public function getPropertyName()
- {
- return $this->getViewState('PropertyName', '');
- }
-
- /**
- * Sets the control property name to observe value changes that fires the callback request.
- * @param string The control property name to observe value changes.
- */
- public function setPropertyName($value)
- {
- $this->setViewState('PropertyName', $value, '');
- }
-
- /**
- * Sets the polling interval in seconds to observe property changes.
- * Default is 1 second.
- * @param float polling interval in seconds.
- */
- 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.
- */
- 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);
- }
-
- /**
- * @return array list of timer options for client-side.
- */
- protected function getTriggerOptions()
- {
- $options = parent::getTriggerOptions();
- $options['PropertyName'] = $this->getPropertyName();
- $options['Interval'] = $this->getInterval();
- $options['Decay'] = $this->getDecayRate();
- return $options;
- }
-
- /**
- * Registers the javascript code for initializing the active control.
- * @param THtmlWriter the renderer.
- */
- public function render($writer)
- {
- parent::render($writer);
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getTriggerOptions());
- }
-
- /**
- * @return string corresponding javascript class name for TEventTriggeredCallback.
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TValueTriggeredCallback';
- }
-}
+<?php
+/**
+ * TValueTriggeredCallback class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2012 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TTriggeredCallback');
+
+/**
+ * TValueTriggeredCallback Class
+ *
+ * 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 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
+ * observed, the polling interval is reset to the original value.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TValueTriggeredCallback extends TTriggeredCallback
+{
+ /**
+ * @return string The control property name to observe value changes.
+ */
+ public function getPropertyName()
+ {
+ return $this->getViewState('PropertyName', '');
+ }
+
+ /**
+ * Sets the control property name to observe value changes that fires the callback request.
+ * @param string The control property name to observe value changes.
+ */
+ public function setPropertyName($value)
+ {
+ $this->setViewState('PropertyName', $value, '');
+ }
+
+ /**
+ * Sets the polling interval in seconds to observe property changes.
+ * Default is 1 second.
+ * @param float polling interval in seconds.
+ */
+ 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.
+ */
+ 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);
+ }
+
+ /**
+ * @return array list of timer options for client-side.
+ */
+ protected function getTriggerOptions()
+ {
+ $options = parent::getTriggerOptions();
+ $options['PropertyName'] = $this->getPropertyName();
+ $options['Interval'] = $this->getInterval();
+ $options['Decay'] = $this->getDecayRate();
+ return $options;
+ }
+
+ /**
+ * Registers the javascript code for initializing the active control.
+ * @param THtmlWriter the renderer.
+ */
+ public function render($writer)
+ {
+ parent::render($writer);
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getTriggerOptions());
+ }
+
+ /**
+ * @return string corresponding javascript class name for TEventTriggeredCallback.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TValueTriggeredCallback';
+ }
+}