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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
<?php
/**
* TTableRow and TTableCellCollection class file
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
* @copyright Copyright © 2005-2015 PradoSoft
* @license http://www.pradosoft.com/license/
* @package System.Web.UI.WebControls
*/
/**
* Includes TTableCell class
*/
Prado::using('System.Web.UI.WebControls.TTableCell');
/**
* TTableRow class.
*
* TTableRow displays a table row. The table cells in the row can be accessed
* via {@link getCells Cells}. The horizontal and vertical alignments of the row
* are specified via {@link setHorizontalAlign HorizontalAlign} and
* {@link setVerticalAlign VerticalAlign} properties, respectively.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @package System.Web.UI.WebControls
* @since 3.0
*/
class TTableRow extends TWebControl
{
/**
* @return string tag name for the table
*/
protected function getTagName()
{
return 'tr';
}
/**
* Adds object parsed from template to the control.
* This method adds only {@link TTableCell} objects into the {@link getCells Cells} collection.
* All other objects are ignored.
* @param mixed object parsed from template
*/
public function addParsedObject($object)
{
if($object instanceof TTableCell)
$this->getCells()->add($object);
}
/**
* Creates a style object for the control.
* This method creates a {@link TTableItemStyle} to be used by the table row.
* @return TStyle control style to be used
*/
protected function createStyle()
{
return new TTableItemStyle;
}
/**
* Creates a control collection object that is to be used to hold child controls
* @return TTableCellCollection control collection
* @see getControls
*/
protected function createControlCollection()
{
return new TTableCellCollection($this);
}
/**
* @return TTableCellCollection list of {@link TTableCell} controls
*/
public function getCells()
{
return $this->getControls();
}
/**
* @return string the horizontal alignment of the contents within the table item, defaults to 'NotSet'.
*/
public function getHorizontalAlign()
{
if($this->getHasStyle())
return $this->getStyle()->getHorizontalAlign();
else
return 'NotSet';
}
/**
* Sets the horizontal alignment of the contents within the table item.
* Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center'
* @param string the horizontal alignment
*/
public function setHorizontalAlign($value)
{
$this->getStyle()->setHorizontalAlign($value);
}
/**
* @return string the vertical alignment of the contents within the table item, defaults to 'NotSet'.
*/
public function getVerticalAlign()
{
if($this->getHasStyle())
return $this->getStyle()->getVerticalAlign();
else
return 'NotSet';
}
/**
* Sets the vertical alignment of the contents within the table item.
* Valid values include 'NotSet','Top','Bottom','Middle'
* @param string the horizontal alignment
*/
public function setVerticalAlign($value)
{
$this->getStyle()->setVerticalAlign($value);
}
/**
* @return TTableRowSection location of a row in a table. Defaults to TTableRowSection::Body.
*/
public function getTableSection()
{
return $this->getViewState('TableSection',TTableRowSection::Body);
}
/**
* @param TTableRowSection location of a row in a table.
*/
public function setTableSection($value)
{
$this->setViewState('TableSection',TPropertyValue::ensureEnum($value,'TTableRowSection'),TTableRowSection::Body);
}
/**
* Renders body contents of the table row
* @param THtmlWriter writer for the rendering purpose
*/
public function renderContents($writer)
{
if($this->getHasControls())
{
$writer->writeLine();
foreach($this->getControls() as $cell)
{
$cell->renderControl($writer);
$writer->writeLine();
}
}
}
}
/**
* TTableCellCollection class.
*
* TTableCellCollection is used to maintain a list of cells belong to a table row.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @package System.Web.UI.WebControls
* @since 3.0
*/
class TTableCellCollection extends TControlCollection
{
/**
* Inserts an item at the specified position.
* This overrides the parent implementation by performing additional
* operations for each newly added table cell.
* @param integer the speicified position.
* @param mixed new item
* @throws TInvalidDataTypeException if the item to be inserted is not a TTableCell object.
*/
public function insertAt($index,$item)
{
if($item instanceof TTableCell)
parent::insertAt($index,$item);
else
throw new TInvalidDataTypeException('tablecellcollection_tablecell_required');
}
}
/**
* TTableRowSection class.
* TTableRowSection defines the enumerable type for the possible table sections
* that a {@link TTableRow} can be within.
*
* The following enumerable values are defined:
* - Header: in table header
* - Body: in table body
* - Footer: in table footer
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @package System.Web.UI.WebControls
* @since 3.0.4
*/
class TTableRowSection extends TEnumerable
{
const Header='Header';
const Body='Body';
const Footer='Footer';
}
|