summaryrefslogtreecommitdiff
path: root/lib/prado/framework/Web/UI/ActiveControls/TTriggeredCallback.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-02-24 23:18:07 +0100
committeremkael <emkael@tlen.pl>2016-02-24 23:18:07 +0100
commit6f7fdef0f500cd4bb540affd3bc1482243f337c1 (patch)
tree4853eecd0769a903e6130c1896e1d070848150dd /lib/prado/framework/Web/UI/ActiveControls/TTriggeredCallback.php
parent61f2ea48a4e11cb5fb941b3783e19c9e9ef38a45 (diff)
* Prado 3.3.0
Diffstat (limited to 'lib/prado/framework/Web/UI/ActiveControls/TTriggeredCallback.php')
-rw-r--r--lib/prado/framework/Web/UI/ActiveControls/TTriggeredCallback.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/prado/framework/Web/UI/ActiveControls/TTriggeredCallback.php b/lib/prado/framework/Web/UI/ActiveControls/TTriggeredCallback.php
new file mode 100644
index 0000000..7675bc8
--- /dev/null
+++ b/lib/prado/framework/Web/UI/ActiveControls/TTriggeredCallback.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * TTriggeredCallback class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2005-2015 The PRADO Group
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @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>
+ * @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;
+ }
+}
+