]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/framework/Web/UI/ActiveControls/TActiveRatingList.php
9c985d50ec553dc94535273aa2e140a32b992085
[bacula/bacula] / gui / baculum / framework / Web / UI / ActiveControls / TActiveRatingList.php
1 <?php
2 /**
3  * TActiveRatingList class file.
4  *
5  * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
6  * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
7  * @link https://github.com/pradosoft/prado
8  * @copyright Copyright &copy; 2005-2016 The PRADO Group
9  * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
10  * @version $Id$
11  * @package System.Web.UI.ActiveControls
12  */
13
14 /**
15  * TActiveRatingList Class
16  *
17  * Displays clickable images that represent a TRadioButtonList
18  *
19  * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
20  * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
21  * @version $Id$
22  * @package System.Web.UI.ActiveControls
23  * @since 3.1
24  */
25 class TActiveRatingList extends TRatingList implements IActiveControl, ICallbackEventHandler
26 {
27         /**
28          * Creates a new callback control, sets the adapter to
29          * TActiveListControlAdapter. If you override this class, be sure to set the
30          * adapter appropriately by, for example, by calling this constructor.
31          */
32         public function __construct()
33         {
34                 $this->setAdapter(new TActiveListControlAdapter($this));
35                 $this->setAutoPostBack(true);
36                 parent::__construct();
37         }
38
39         /**
40          * @return TBaseActiveCallbackControl standard callback control options.
41          */
42         public function getActiveControl()
43         {
44                 return $this->getAdapter()->getBaseActiveControl();
45         }
46
47         /**
48          * @return TCallbackClientSide client side request options.
49          */
50         public function getClientSide()
51         {
52                 return $this->getAdapter()->getBaseActiveControl()->getClientSide();
53         }
54
55         /**
56          * Raises the callback event. This method is required by {@link
57          * ICallbackEventHandler} interface.
58          * This method is mainly used by framework and control developers.
59          * @param TCallbackEventParameter the event parameter
60          */
61         public function raiseCallbackEvent($param)
62         {
63                 $this->onCallback($param);
64         }
65
66         /**
67          * This method is invoked when a callback is requested. The method raises
68          * 'OnCallback' event to fire up the event handlers. If you override this
69          * method, be sure to call the parent implementation so that the event
70          * handler can be invoked.
71          * @param TCallbackEventParameter event parameter to be passed to the event handlers
72          */
73         public function onCallback($param)
74         {
75                 $this->raiseEvent('OnCallback', $this, $param);
76         }
77
78         /**
79          * @param boolean whether the items in the column can be edited
80          */
81         public function setReadOnly($value)
82         {
83                 if(parent::getReadOnly() === $value)
84                         return;
85
86                 parent::setReadOnly($value);
87                 $value = $this->getReadOnly();
88                 $this->callClientFunction('setReadOnly',$value);
89         }
90
91         /**
92          * @param float rating value, also sets the selected Index
93          */
94         public function setRating($value)
95         {
96                 if(parent::getRating() === $value)
97                         return;
98
99                 parent::setRating($value);
100                 $value = $this->getRating();
101                 $this->callClientFunction('setRating',$value);
102         }
103
104         /**
105          * Calls the client-side static method for this control class.
106          * @param string static method name
107          * @param mixed method parmaeter
108          */
109         protected function callClientFunction($func,$value)
110         {
111                 if($this->getActiveControl()->canUpdateClientSide())
112                 {
113                         $client = $this->getPage()->getCallbackClient();
114                         $code = 'Prado.Registry[\''.$this->ClientID.'\'].'.$func.'('.$value.')';
115                         $client->evaluateScript($code,array($value));
116                 }
117         }
118
119         /**
120          * @param string caption text
121          */
122         public function setCaption($value)
123         {
124                 if(parent::getCaption() === $value)
125                         return;
126
127                 parent::setCaption($value);
128                 // if it's an active control, this should not be needed.
129                 $this->callClientFunction('setCaption',$value);
130         }
131
132         /**
133          * Ensure that the ID attribute is rendered and registers the javascript code
134          * for initializing the active control.
135          */
136         protected function addAttributesToRender($writer)
137         {
138                 parent::addAttributesToRender($writer);
139                 $this->getActiveControl()->registerCallbackClientScript(
140                         $this->getClientClassName(), $this->getPostBackOptions());
141         }
142
143         /**
144          * Gets the name of the javascript class responsible for performing postback for this control.
145          * This method overrides the parent implementation.
146          * @return string the javascript class name
147          */
148         protected function getClientClassName()
149         {
150                 return 'Prado.WebUI.TActiveRatingList';
151         }
152 }
153