| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* TActivePanel file.
|
|
|
4 |
*
|
|
|
5 |
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2005-2008 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id: TActivePanel.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
10 |
* @package System.Web.UI.ActiveControls
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* Load active control adapter.
|
|
|
15 |
*/
|
|
|
16 |
Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* TActivePanel is the TPanel active control counterpart.
|
|
|
20 |
*
|
|
|
21 |
* TActivePanel allows the client-side panel contents to be updated during a
|
|
|
22 |
* callback response using the {@link flush} method.
|
|
|
23 |
*
|
|
|
24 |
* Example: Assume $param is an instance of TCallbackEventParameter attached to
|
|
|
25 |
* the OnCallback event a TCallback with ID "callback1", and
|
|
|
26 |
* "panel1" is the ID of a TActivePanel.
|
|
|
27 |
* <code>
|
|
|
28 |
* function callback1_requested($sender, $param)
|
|
|
29 |
* {
|
|
|
30 |
* $this->panel1->render($param->getNewWriter());
|
|
|
31 |
* }
|
|
|
32 |
* </code>
|
|
|
33 |
*
|
|
|
34 |
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
|
|
|
35 |
* @version $Id: TActivePanel.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
36 |
* @package System.Web.UI.ActiveControls
|
|
|
37 |
* @since 3.1
|
|
|
38 |
*/
|
|
|
39 |
class TActivePanel extends TPanel implements IActiveControl
|
|
|
40 |
{
|
|
|
41 |
/**
|
|
|
42 |
* Creates a new callback control, sets the adapter to
|
|
|
43 |
* TActiveControlAdapter. If you override this class, be sure to set the
|
|
|
44 |
* adapter appropriately by, for example, by calling this constructor.
|
|
|
45 |
*/
|
|
|
46 |
public function __construct()
|
|
|
47 |
{
|
|
|
48 |
parent::__construct();
|
|
|
49 |
$this->setAdapter(new TActiveControlAdapter($this));
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
/**
|
|
|
53 |
* @return TBaseActiveControl standard active control options.
|
|
|
54 |
*/
|
|
|
55 |
public function getActiveControl()
|
|
|
56 |
{
|
|
|
57 |
return $this->getAdapter()->getBaseActiveControl();
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
* Renders and replaces the panel's content on the client-side.
|
|
|
62 |
* When render() is called before the OnPreRender event, such as when render()
|
|
|
63 |
* is called during a callback event handler, the rendering
|
|
|
64 |
* is defered until OnPreRender event is raised.
|
|
|
65 |
* @param THtmlWriter html writer
|
|
|
66 |
*/
|
|
|
67 |
public function render($writer)
|
|
|
68 |
{
|
|
|
69 |
if($this->getHasPreRendered())
|
|
|
70 |
{
|
|
|
71 |
parent::render($writer);
|
|
|
72 |
if($this->getActiveControl()->canUpdateClientSide())
|
|
|
73 |
$this->getPage()->getCallbackClient()->replaceContent($this,$writer);
|
|
|
74 |
}
|
|
|
75 |
else
|
|
|
76 |
{
|
|
|
77 |
$this->getPage()->getAdapter()->registerControlToRender($this,$writer);
|
|
|
78 |
if ($this->getHasControls())
|
|
|
79 |
{
|
|
|
80 |
// If we update a TActivePanel on callback,
|
|
|
81 |
// We shouldn't update all childs, because the whole content will be replaced by
|
|
|
82 |
// the parent
|
|
|
83 |
foreach ($this->findControlsByType('IActiveControl', false) as $control)
|
|
|
84 |
{
|
|
|
85 |
$control->getActiveControl()->setEnableUpdate(false);
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
|