Adding a bunch of new Printer stuff that I'm not sure works quite yet
[isso.git] / PrinterTableElement.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 Table Element (PrinterTableElement.php)
24 *
25 * @package ISSO
26 */
27
28 require_once('ISSO/PrinterRootElementTable.php');
29 require_once('ISSO/PrinterBaseElement.php');
30
31 /**
32 * Printer Table Element
33 *
34 * This represents a table row that holds elements.
35 *
36 * @author Blue Static
37 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
38 * @version $Revision$
39 * @package ISSO
40 *
41 */
42 class BSPrinterTableElement extends BSPrinterElement
43 {
44 /**
45 * The parent table
46 * @var BSPrinterRootElementTable
47 */
48 private $parent;
49
50 /**
51 * CSS class to use
52 * @var string
53 */
54 private $cssClass = ':swap:';
55
56 /**
57 * Array of child nodes
58 * @var array
59 */
60 private $children = array();
61
62 /**
63 * Constructor
64 */
65 function __construct(BSPrinterRootElementTable $table)
66 {
67 $this->parent = $table;
68 }
69
70 // ###################################################################
71 /**
72 * Sets the CSS class to use. Use ":swap:" to alternate
73 *
74 * @param string CSS class
75 */
76 public function setCssClass($class)
77 {
78 $this->cssClass = $class;
79 }
80
81 // ###################################################################
82 /**
83 * Sets the parent element
84 */
85 public function setParent(BSPrinterElement $parent)
86 {
87 trigger_error('Cannot set the parent element on a BSPrinterRootElement');
88 }
89
90 // ###################################################################
91 /**
92 * Gets the parent element (none exist as this is the root element)
93 */
94 public function getParent()
95 {
96 return null;
97 }
98
99 // ###################################################################
100 /**
101 * Returns the number of columns in this element
102 *
103 * @return integer Column count
104 */
105 public function numberOfColumns()
106 {
107 return sizeof($this->children);
108 }
109
110 // ###################################################################
111 /**
112 * Returns the HTML for all printed children elements
113 *
114 * @return string Printed HTML
115 */
116 protected function _paintChildren()
117 {
118 $builder = '';
119
120 foreach ($this->children AS $child)
121 {
122 $builder .= "\n<td>" . $child->paint() . "</td>\n";
123 }
124
125 return $builder;
126 }
127
128 // ###################################################################
129 /**
130 * Paints the entire table row
131 *
132 * @return string Table row HTML
133 */
134 public function paint()
135 {
136 return "<tr>" . $this->_paintChildren() . "</tr>";
137 }
138 }
139
140 /*=====================================================================*
141 || ###################################################################
142 || # $HeadURL$
143 || # $Id$
144 || ###################################################################
145 \*=====================================================================*/
146 ?>