]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/framework/Web/UI/ActiveControls/TTriggeredCallback.php
baculum: New Baculum API and Baculum Web
[bacula/bacula] / gui / baculum / framework / Web / UI / ActiveControls / TTriggeredCallback.php
1 <?php
2 /**
3  * TTriggeredCallback class file.
4  *
5  * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
6  * @link https://github.com/pradosoft/prado
7  * @copyright Copyright &copy; 2005-2016 The PRADO Group
8  * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9  * @package System.Web.UI.ActiveControls
10  */
11
12 Prado::using('System.Web.UI.ActiveControls.TCallback');
13 /**
14  * TTriggeredCallback abstract Class
15  *
16  * Base class for triggered callback controls. The {@link setControlID ControlID}
17  * property sets the control ID to observe the trigger.
18  *
19  * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
20  * @package System.Web.UI.ActiveControls
21  * @since 3.1
22  */
23 abstract class TTriggeredCallback extends TCallback
24 {
25         /**
26          * @return string The ID of the server control the trigger is bounded to.
27          */
28         public function getControlID()
29         {
30                 return $this->getViewState('ControlID', '');
31         }
32
33         /**
34          * @param string The ID of the server control the trigger is bounded to.
35          */
36         public function setControlID($value)
37         {
38                 $this->setViewState('ControlID', $value, '');
39         }
40
41         /**
42          * @return string target control client ID or html element ID if
43          * control is not found in hierarchy.
44          */
45         protected function getTargetControl()
46         {
47                 $id = $this->getControlID();
48                 if(($control=$this->findControl($id)) instanceof TControl)
49                         return $control->getClientID();
50                 if($id==='')
51                 {
52                         throw new TConfigurationException(
53                                 'ttriggeredcallback_invalid_controlid', get_class($this));
54                 }
55                 return $id;
56         }
57
58         /**
59          * @return array list of trigger callback options.
60          */
61         protected function getTriggerOptions()
62         {
63                 $options['ID'] = $this->getClientID();
64                 $options['EventTarget'] = $this->getUniqueID();
65                 $options['ControlID'] = $this->getTargetControl();
66                 return $options;
67         }
68 }
69