blob: 2f43391abd32e5ac7cc70160304232429f426491 (
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
|
<?php
/**
* TMultiView and TView class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
* @copyright Copyright © 2005-2014 PradoSoft
* @license http://www.pradosoft.com/license/
* @package Prado\Web\UI\WebControls
*/
namespace Prado\Web\UI\WebControls;
use Prado\Exceptions\TInvalidOperationException;
use Prado\TPropertyValue;
/**
* TView class
*
* TView is a container for a group of controls. TView must be contained
* within a {@link TMultiView} control in which only one view can be active
* at one time.
*
* To activate a view, set {@link setActive Active} to true.
* When a view is activated, it raises {@link onActivate OnActivate} event;
* and when a view is deactivated, it raises {@link onDeactivate OnDeactivate}.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @package Prado\Web\UI\WebControls
* @since 3.0
*/
class TView extends \Prado\Web\UI\TControl
{
private $_active=false;
/**
* Raises <b>OnActivate</b> event.
* @param TEventParameter event parameter
*/
public function onActivate($param)
{
$this->raiseEvent('OnActivate',$this,$param);
}
/**
* Raises <b>OnDeactivate</b> event.
* @param TEventParameter event parameter
*/
public function onDeactivate($param)
{
$this->raiseEvent('OnDeactivate',$this,$param);
}
/**
* @return boolean whether this view is active. Defaults to false.
*/
public function getActive()
{
return $this->_active;
}
/**
* @param boolean whether this view is active.
*/
public function setActive($value)
{
$value=TPropertyValue::ensureBoolean($value);
$this->_active=$value;
parent::setVisible($value);
}
/**
* @param boolean whether the parents should also be checked if visible
* @return boolean whether this view is visible.
* The view is visible if it is active and its parent is visible.
*/
public function getVisible($checkParents=true)
{
if(($parent=$this->getParent())===null)
return $this->getActive();
else if($this->getActive())
return $parent->getVisible($checkParents);
else
return false;
}
/**
* @param boolean
* @throws TInvalidOperationException whenever this method is invoked.
*/
public function setVisible($value)
{
throw new TInvalidOperationException('view_visible_readonly');
}
}
|