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