2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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.
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
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 \*=====================================================================*/
23 * Printer Table Element (PrinterTableElement.php)
28 require_once('ISSO/PrinterRootElementTable.php');
29 require_once('ISSO/PrinterBaseElement.php');
32 * Printer Table Element
34 * This represents a table row that holds elements.
37 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
42 class BSPrinterTableElement
extends BSPrinterElement
48 private $cssClass = ':swap:';
51 * Array of child nodes
54 private $children = array();
56 // ###################################################################
58 * Returns a new instance of this class
60 public static function Init()
62 return new BSPrinterTableElement();
65 // ###################################################################
67 * Factory method that creates a checkbox row
70 * @param string Element name
72 * @param boolean Checked?
74 * @return BSPrinterTableElement A proper table element
76 public static function RowCheckbox($label, $name, $value, $checked = false
)
78 $tr = new BSPrinterTableElement();
80 $tr->addChild(new BSPrinterLabelElement($label));
82 $elm = new BSPrinterBaseElement('checkbox', $name, $value);
83 $elm->setActive($checked);
90 // ###################################################################
92 * Sets the CSS class to use. Use ":swap:" to alternate
94 * @param string CSS class
96 public function setCssClass($class)
98 $this->cssClass
= $class;
101 // ###################################################################
103 * Returns the number of columns in this element
105 * @return integer Column count
107 public function numberOfColumns()
109 return sizeof($this->children
);
112 // ###################################################################
114 * Adds a child node to the element
116 * @param BSPrinterElement A child element
118 * @return BSPrinterTableElement Returns the current object
120 public function addChild(BSPrinterElement
$child)
122 $this->children
[] = $child;
126 // ###################################################################
128 * Returns the HTML for all printed children elements
130 * @return string Printed HTML
132 protected function _paintChildren()
136 foreach ($this->children
AS $child)
138 $builder .= "\n<td>" . $child->paint() . "</td>\n";
144 // ###################################################################
146 * Paints the entire table row
148 * @return string Table row HTML
150 public function paint()
152 return "<tr>" . $this->_paintChildren() . "</tr>";
156 /*=====================================================================*
157 || ###################################################################
160 || ###################################################################
161 \*=====================================================================*/