| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* TTableRow and TTableCellCollection class file
|
|
|
4 |
*
|
|
|
5 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2005-2008 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id: TTableRow.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
10 |
* @package System.Web.UI.WebControls
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* Includes TTableCell class
|
|
|
15 |
*/
|
|
|
16 |
Prado::using('System.Web.UI.WebControls.TTableCell');
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* TTableRow class.
|
|
|
20 |
*
|
|
|
21 |
* TTableRow displays a table row. The table cells in the row can be accessed
|
|
|
22 |
* via {@link getCells Cells}. The horizontal and vertical alignments of the row
|
|
|
23 |
* are specified via {@link setHorizontalAlign HorizontalAlign} and
|
|
|
24 |
* {@link setVerticalAlign VerticalAlign} properties, respectively.
|
|
|
25 |
*
|
|
|
26 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
27 |
* @version $Id: TTableRow.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
28 |
* @package System.Web.UI.WebControls
|
|
|
29 |
* @since 3.0
|
|
|
30 |
*/
|
|
|
31 |
class TTableRow extends TWebControl
|
|
|
32 |
{
|
|
|
33 |
/**
|
|
|
34 |
* @return string tag name for the table
|
|
|
35 |
*/
|
|
|
36 |
protected function getTagName()
|
|
|
37 |
{
|
|
|
38 |
return 'tr';
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* Adds object parsed from template to the control.
|
|
|
43 |
* This method adds only {@link TTableCell} objects into the {@link getCells Cells} collection.
|
|
|
44 |
* All other objects are ignored.
|
|
|
45 |
* @param mixed object parsed from template
|
|
|
46 |
*/
|
|
|
47 |
public function addParsedObject($object)
|
|
|
48 |
{
|
|
|
49 |
if($object instanceof TTableCell)
|
|
|
50 |
$this->getCells()->add($object);
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Creates a style object for the control.
|
|
|
55 |
* This method creates a {@link TTableItemStyle} to be used by the table row.
|
|
|
56 |
* @return TStyle control style to be used
|
|
|
57 |
*/
|
|
|
58 |
protected function createStyle()
|
|
|
59 |
{
|
|
|
60 |
return new TTableItemStyle;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Creates a control collection object that is to be used to hold child controls
|
|
|
65 |
* @return TTableCellCollection control collection
|
|
|
66 |
* @see getControls
|
|
|
67 |
*/
|
|
|
68 |
protected function createControlCollection()
|
|
|
69 |
{
|
|
|
70 |
return new TTableCellCollection($this);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
/**
|
|
|
74 |
* @return TTableCellCollection list of {@link TTableCell} controls
|
|
|
75 |
*/
|
|
|
76 |
public function getCells()
|
|
|
77 |
{
|
|
|
78 |
return $this->getControls();
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
/**
|
|
|
82 |
* @return string the horizontal alignment of the contents within the table item, defaults to 'NotSet'.
|
|
|
83 |
*/
|
|
|
84 |
public function getHorizontalAlign()
|
|
|
85 |
{
|
|
|
86 |
if($this->getHasStyle())
|
|
|
87 |
return $this->getStyle()->getHorizontalAlign();
|
|
|
88 |
else
|
|
|
89 |
return 'NotSet';
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* Sets the horizontal alignment of the contents within the table item.
|
|
|
94 |
* Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center'
|
|
|
95 |
* @param string the horizontal alignment
|
|
|
96 |
*/
|
|
|
97 |
public function setHorizontalAlign($value)
|
|
|
98 |
{
|
|
|
99 |
$this->getStyle()->setHorizontalAlign($value);
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
/**
|
|
|
103 |
* @return string the vertical alignment of the contents within the table item, defaults to 'NotSet'.
|
|
|
104 |
*/
|
|
|
105 |
public function getVerticalAlign()
|
|
|
106 |
{
|
|
|
107 |
if($this->getHasStyle())
|
|
|
108 |
return $this->getStyle()->getVerticalAlign();
|
|
|
109 |
else
|
|
|
110 |
return 'NotSet';
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
/**
|
|
|
114 |
* Sets the vertical alignment of the contents within the table item.
|
|
|
115 |
* Valid values include 'NotSet','Top','Bottom','Middle'
|
|
|
116 |
* @param string the horizontal alignment
|
|
|
117 |
*/
|
|
|
118 |
public function setVerticalAlign($value)
|
|
|
119 |
{
|
|
|
120 |
$this->getStyle()->setVerticalAlign($value);
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
/**
|
|
|
124 |
* @return TTableRowSection location of a row in a table. Defaults to TTableRowSection::Body.
|
|
|
125 |
*/
|
|
|
126 |
public function getTableSection()
|
|
|
127 |
{
|
|
|
128 |
return $this->getViewState('TableSection',TTableRowSection::Body);
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
/**
|
|
|
132 |
* @param TTableRowSection location of a row in a table.
|
|
|
133 |
*/
|
|
|
134 |
public function setTableSection($value)
|
|
|
135 |
{
|
|
|
136 |
$this->setViewState('TableSection',TPropertyValue::ensureEnum($value,'TTableRowSection'),TTableRowSection::Body);
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
/**
|
|
|
140 |
* Renders body contents of the table row
|
|
|
141 |
* @param THtmlWriter writer for the rendering purpose
|
|
|
142 |
*/
|
|
|
143 |
public function renderContents($writer)
|
|
|
144 |
{
|
|
|
145 |
if($this->getHasControls())
|
|
|
146 |
{
|
|
|
147 |
$writer->writeLine();
|
|
|
148 |
foreach($this->getControls() as $cell)
|
|
|
149 |
{
|
|
|
150 |
$cell->renderControl($writer);
|
|
|
151 |
$writer->writeLine();
|
|
|
152 |
}
|
|
|
153 |
}
|
|
|
154 |
}
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
/**
|
|
|
158 |
* TTableCellCollection class.
|
|
|
159 |
*
|
|
|
160 |
* TTableCellCollection is used to maintain a list of cells belong to a table row.
|
|
|
161 |
*
|
|
|
162 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
163 |
* @version $Id: TTableRow.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
164 |
* @package System.Web.UI.WebControls
|
|
|
165 |
* @since 3.0
|
|
|
166 |
*/
|
|
|
167 |
class TTableCellCollection extends TControlCollection
|
|
|
168 |
{
|
|
|
169 |
/**
|
|
|
170 |
* Inserts an item at the specified position.
|
|
|
171 |
* This overrides the parent implementation by performing additional
|
|
|
172 |
* operations for each newly added table cell.
|
|
|
173 |
* @param integer the speicified position.
|
|
|
174 |
* @param mixed new item
|
|
|
175 |
* @throws TInvalidDataTypeException if the item to be inserted is not a TTableCell object.
|
|
|
176 |
*/
|
|
|
177 |
public function insertAt($index,$item)
|
|
|
178 |
{
|
|
|
179 |
if($item instanceof TTableCell)
|
|
|
180 |
parent::insertAt($index,$item);
|
|
|
181 |
else
|
|
|
182 |
throw new TInvalidDataTypeException('tablecellcollection_tablecell_required');
|
|
|
183 |
}
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
/**
|
|
|
188 |
* TTableRowSection class.
|
|
|
189 |
* TTableRowSection defines the enumerable type for the possible table sections
|
|
|
190 |
* that a {@link TTableRow} can be within.
|
|
|
191 |
*
|
|
|
192 |
* The following enumerable values are defined:
|
|
|
193 |
* - Header: in table header
|
|
|
194 |
* - Body: in table body
|
|
|
195 |
* - Footer: in table footer
|
|
|
196 |
*
|
|
|
197 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
198 |
* @version $Id: TTableRow.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
199 |
* @package System.Web.UI.WebControls
|
|
|
200 |
* @since 3.0.4
|
|
|
201 |
*/
|
|
|
202 |
class TTableRowSection extends TEnumerable
|
|
|
203 |
{
|
|
|
204 |
const Header='Header';
|
|
|
205 |
const Body='Body';
|
|
|
206 |
const Footer='Footer';
|
|
|
207 |
}
|
|
|
208 |
|