1 | <?php |
||
11 | class Ctable |
||
12 | { |
||
13 | private $headers; |
||
14 | private $footers; |
||
15 | private $rows; |
||
16 | private $caption; |
||
17 | private $class; |
||
18 | private $id; |
||
19 | |||
20 | /** |
||
21 | * Output an html representation of a table row. |
||
22 | * |
||
23 | * @param array $row the values that are supposed to be in the row |
||
24 | * @return string $html the html code representing the row |
||
25 | */ |
||
26 | 8 | private function generateTableRow($row) |
|
36 | |||
37 | /** |
||
38 | * Output an html representation of a table header. |
||
39 | * |
||
40 | * @param array $headers the values that are supposed to be in the header row |
||
41 | * @return string $html the html code representing the header |
||
42 | */ |
||
43 | 8 | private function generateTableHead($headers) |
|
51 | |||
52 | /** |
||
53 | * Output an html representation of a table footer. |
||
54 | * @param array $footers the values that are supposed to be in the footer row |
||
55 | * @return string $html the html code representing the footer |
||
56 | */ |
||
57 | 1 | private function generateTableFoot($footers) |
|
65 | |||
66 | /** |
||
67 | * Output an html representation of a table body, |
||
68 | * contained within <tbody> tags and containing a number |
||
69 | * of rows. |
||
70 | * @param array $rows the rows that are supposed to be contained by the table body |
||
71 | * @return string $html the html code representing the table body |
||
72 | */ |
||
73 | 8 | private function generateTableBody($rows) |
|
83 | |||
84 | /** |
||
85 | * Output an html representation |
||
86 | * of a table caption. |
||
87 | * @param string $text the string that is supposed to be the table caption |
||
88 | * @return string the html code representing the table caption |
||
89 | */ |
||
90 | 1 | private function generateTableCaption($text) |
|
94 | |||
95 | /** |
||
96 | * Output the opening <table> tag to initate a table. |
||
97 | * It can look in different ways depending on whether there are any |
||
98 | * class or id attributes. |
||
99 | * @return string the html code representing the opening <table> tag |
||
100 | */ |
||
101 | 8 | private function openTable() |
|
118 | |||
119 | /** |
||
120 | * Output the html code that represents a table |
||
121 | * consisting of a body and a header as well as, optionally, a footer and/or |
||
122 | * a caption. |
||
123 | * @return string $html the html representation of a table |
||
124 | */ |
||
125 | 8 | private function generateTable() |
|
140 | |||
141 | /** |
||
142 | * Initiate the object and save the data as inside parameters of the class. |
||
143 | * @param array $data the array containing the data that are needed |
||
144 | * to create the table |
||
145 | */ |
||
146 | 9 | public function __construct($data) |
|
171 | |||
172 | /** |
||
173 | * Save an array with rows as a property of the class. |
||
174 | * @param array $array an array containing rows |
||
175 | */ |
||
176 | 9 | public function setRows($array) |
|
180 | |||
181 | /** |
||
182 | * Save an array with headers as a property of the class. |
||
183 | * @param array $array an array containing table headers |
||
184 | */ |
||
185 | 9 | public function setHeaders($array) |
|
189 | |||
190 | /** |
||
191 | * Save an array with footers as a property of the class. |
||
192 | * @param array $array an array containing table footers |
||
193 | */ |
||
194 | 1 | public function setFooters($array) |
|
198 | |||
199 | /** |
||
200 | * Save a table caption as a property of the class. |
||
201 | * @param string $string a value that is supposed to be used as the table caption |
||
202 | */ |
||
203 | 1 | public function setCaption($string) |
|
207 | |||
208 | /** |
||
209 | * Save some CSS classes that are supposed to be assigned to the table |
||
210 | * as a property of the class. |
||
211 | * @param array $array an array that is a list of CSS classes |
||
212 | */ |
||
213 | 2 | public function setClass($array) |
|
217 | |||
218 | /** |
||
219 | * Save a CSS id that is supposed to be assigned to the table |
||
220 | * as a property of the class. |
||
221 | * @param string $text a CSS id that is supposed to be assigned |
||
222 | */ |
||
223 | 2 | public function setId($text) |
|
227 | |||
228 | /** |
||
229 | * Add one row of data to the existing array of |
||
230 | * rows of data that is a property of the class. |
||
231 | * @param array $data a row of data values |
||
232 | */ |
||
233 | 1 | public function addRow($data) |
|
237 | |||
238 | /** |
||
239 | * Tell me how many rows of data this table has. |
||
240 | * @return integer a number representing how many rows of data this table has |
||
241 | */ |
||
242 | 1 | public function getNumberOfRows() |
|
246 | |||
247 | /** |
||
248 | * Output the generated html table. |
||
249 | * @return string complete HTML code representing a table |
||
250 | */ |
||
251 | 8 | public function View() |
|
255 | } |
||
256 |