]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/framework/Web/UI/ActiveControls/TActiveMultiView.php
baculum: New Baculum API and Baculum Web
[bacula/bacula] / gui / baculum / framework / Web / UI / ActiveControls / TActiveMultiView.php
1 <?php
2 /**
3  * TActiveMultiView class file
4  *
5  * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
6  * @link http://www.landwehr-software.de/
7  * @copyright Copyright &copy; 2009 LANDWEHR Computer und Software GmbH
8  * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9  * @package System.Web.UI.ActiveControls
10  */
11
12 /**
13  * Includes the following used classes
14  */
15 Prado::using('System.Web.UI.WebControls.TMultiView');
16
17 /**
18  * TActiveMultiView class.
19  *
20  * TActiveMultiView is the active counterpart to the original {@link TMultiView} control.
21  * It re-renders on Callback when {@link setActiveView ActiveView} or
22  * {@link setActiveViewIndex ActiveViewIndex} is called.
23  *
24  * Please refer to the original documentation of the regular counterpart for usage.
25  *
26  * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
27  * @package System.Web.UI.ActiveControls
28  * @since 3.1.6
29  */
30 class TActiveMultiView extends TMultiView implements IActiveControl
31 {
32         /**
33         * Creates a new callback control, sets the adapter to
34         * TActiveControlAdapter.
35         */
36         public function __construct()
37         {
38                 parent::__construct();
39                 $this->setAdapter(new TActiveControlAdapter($this));
40         }
41
42         /**
43         * @return TBaseActiveControl standard active control options.
44         */
45         public function getActiveControl()
46         {
47                 return $this->getAdapter()->getBaseActiveControl();
48         }
49
50         /**
51         * Returns the id of the surrounding container (span).
52         * @return string container id
53         */
54         protected function getContainerID()
55         {
56                 return $this->ClientID.'_Container';
57         }
58
59         /**
60         * Renders the TActiveMultiView.
61         * If the MutliView did not pass the prerender phase yet, it will register itself for rendering later.
62         * Else it will call the {@link renderMultiView()} method which will do the rendering of the MultiView.
63         * @param THtmlWriter writer for the rendering purpose
64         */
65         public function render($writer)
66         {
67                 if($this->getHasPreRendered()) {
68                         $this->renderMultiView($writer);
69                         if($this->getActiveControl()->canUpdateClientSide())
70                                 $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(),$writer);
71                 }
72                 else
73                         $this->getPage()->getAdapter()->registerControlToRender($this,$writer);
74         }
75
76         /**
77         * Renders the TActiveMultiView by writing a span tag with the container id obtained from {@link getContainerID()}
78         * which will be called by the replacement method of the client script to update it's content.
79         * @param $writer THtmlWriter writer for the rendering purpose
80         */
81         protected function renderMultiView($writer)
82         {
83                 $writer->addAttribute('id', $this->getContainerID());
84                 $writer->renderBeginTag('span');
85                 parent::render($writer);
86                 $writer->renderEndTag();
87         }
88
89         /**
90         * @param integer the zero-based index of the current view in the view collection. -1 if no active view.
91         * @throws TInvalidDataValueException if the view index is invalid
92         */
93         public function setActiveViewIndex($value)
94         {
95                 parent::setActiveViewIndex($value);
96                 if($this->getActiveControl()->canUpdateClientSide())
97                         $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter());
98         }
99
100         /**
101         * @param TView the view to be activated
102         * @throws TInvalidOperationException if the view is not in the view collection
103         */
104         public function setActiveView($value)
105         {
106                 parent::setActiveView($value);
107                 if($this->getActiveControl()->canUpdateClientSide())
108                         $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter());
109         }
110 }