Okay this finally looks good
[isso.git] / PrinterRootElementTable.php
1 <?php
2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * Printer Root Element: Table (PrinterRootElementTable.php)
24 *
25 * @package ISSO
26 */
27
28 require_once('ISSO/PrinterRootElement.php');
29
30 /**
31 * Printer Root Element: Table
32 *
33 * Represents a <table> object. This can have a parent or not: if it does,
34 * then it will be painted as a child, otherwise it will act as a root.
35 *
36 * @author Blue Static
37 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
38 * @version $Revision$
39 * @package ISSO
40 *
41 */
42 class BSPrinterRootElementTable extends BSPrinterRootElement
43 {
44 /**
45 * Maximum number of columns
46 * @var integer
47 */
48 private $colspan = 0;
49
50 // ###################################################################
51 /**
52 * Adds a table row into the child list
53 *
54 * @param BSPrinterTableElement Table element
55 */
56 public function addChild(BSPrinterElement $tr)
57 {
58 $this->children[] = $tr;
59 }
60
61 // ###################################################################
62 /**
63 * Calculates the number of columns to display based on the colspan
64 * of children elements
65 */
66 private function _calculateColumnCount()
67 {
68 foreach ($this->children AS $child)
69 {
70 if ($child->numberOfColumns() > $this->colspan)
71 {
72 $this->colspan = $child->numberOfColumns();
73 }
74 }
75 }
76
77 // ###################################################################
78 /**
79 * Returns the HTML for all printed children elements
80 *
81 * @return string Printed HTML
82 */
83 protected function _paintChildren()
84 {
85 $builder = '';
86
87 $this->_calculateColumnCount();
88
89 foreach ($this->children AS $child)
90 {
91 $builder .= "\n" . $child->paint() . "\n";
92 }
93
94 return $builder;
95 }
96
97 // ###################################################################
98 /**
99 * Paints the <table>
100 *
101 * @return string Table HTML code
102 */
103 public function paint()
104 {
105 return "<table>" . $this->_paintChildren() . "</table>";
106 }
107 }
108
109 /*=====================================================================*
110 || ###################################################################
111 || # $HeadURL$
112 || # $Id$
113 || ###################################################################
114 \*=====================================================================*/
115 ?>