3 * TActiveRatingList class file.
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 © 2005-2016 The PRADO Group
9 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
11 * @package System.Web.UI.ActiveControls
15 * TActiveRatingList Class
17 * Displays clickable images that represent a TRadioButtonList
19 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
20 * @author Bradley Booms <bradley[dot]booms[at]gmail[dot]com>
22 * @package System.Web.UI.ActiveControls
25 class TActiveRatingList extends TRatingList implements IActiveControl, ICallbackEventHandler
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.
32 public function __construct()
34 $this->setAdapter(new TActiveListControlAdapter($this));
35 $this->setAutoPostBack(true);
36 parent::__construct();
40 * @return TBaseActiveCallbackControl standard callback control options.
42 public function getActiveControl()
44 return $this->getAdapter()->getBaseActiveControl();
48 * @return TCallbackClientSide client side request options.
50 public function getClientSide()
52 return $this->getAdapter()->getBaseActiveControl()->getClientSide();
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
61 public function raiseCallbackEvent($param)
63 $this->onCallback($param);
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
73 public function onCallback($param)
75 $this->raiseEvent('OnCallback', $this, $param);
79 * @param boolean whether the items in the column can be edited
81 public function setReadOnly($value)
83 if(parent::getReadOnly() === $value)
86 parent::setReadOnly($value);
87 $value = $this->getReadOnly();
88 $this->callClientFunction('setReadOnly',$value);
92 * @param float rating value, also sets the selected Index
94 public function setRating($value)
96 if(parent::getRating() === $value)
99 parent::setRating($value);
100 $value = $this->getRating();
101 $this->callClientFunction('setRating',$value);
105 * Calls the client-side static method for this control class.
106 * @param string static method name
107 * @param mixed method parmaeter
109 protected function callClientFunction($func,$value)
111 if($this->getActiveControl()->canUpdateClientSide())
113 $client = $this->getPage()->getCallbackClient();
114 $code = 'Prado.Registry[\''.$this->ClientID.'\'].'.$func.'('.$value.')';
115 $client->evaluateScript($code,array($value));
120 * @param string caption text
122 public function setCaption($value)
124 if(parent::getCaption() === $value)
127 parent::setCaption($value);
128 // if it's an active control, this should not be needed.
129 $this->callClientFunction('setCaption',$value);
133 * Ensure that the ID attribute is rendered and registers the javascript code
134 * for initializing the active control.
136 protected function addAttributesToRender($writer)
138 parent::addAttributesToRender($writer);
139 $this->getActiveControl()->registerCallbackClientScript(
140 $this->getClientClassName(), $this->getPostBackOptions());
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
148 protected function getClientClassName()
150 return 'Prado.WebUI.TActiveRatingList';