object. This can have a parent or not: if it does, * then it will be painted as a child, otherwise it will act as a root. * * @author Blue Static * @copyright Copyright (c)2002 - [#]year[#], Blue Static * @version $Revision$ * @package ISSO * */ class BSPrinterRootElementTable extends BSPrinterRootElement { /** * Maximum number of columns * @var integer */ private $colspan = 0; /** * Heading child elements * @var array */ private $headers = array(); /** * Width of the table * @var string */ private $width = '90%'; // ################################################################### /** * Constructor */ public function __construct() { $this->setCssClass('tborder'); } // ################################################################### /** * Adds a table row into the child list * * @param BSPrinterTableElement Table element */ public function addChild(BSPrinterElement $tr) { if (!$tr instanceof BSPrinterTableElement) { trigger_error('BSPrinterRootElementTable::addChild() only accepts BSPrinterTableElement objects as children'); } $this->children[] = $tr; } // ################################################################### /** * Adds a table element to be a heading of the table. This is still * considered a child, but it goes before all other child elemends * * @param BSPrinterTableElement Child element */ public function addHeadingChild(BSPrinterTableElement $tr) { $this->headers[] = $tr; } // ################################################################### /** * Sets the width of the table * * @param string Width value */ public function setWidth($width) { $this->width = $width; } // ################################################################### /** * Calculates the number of columns to display based on the colspan * of children elements */ private function _calculateColumnCount() { foreach ($this->children AS $child) { if ($child->numberOfColumns() > $this->colspan) { $this->colspan = $child->numberOfColumns(); } } } // ################################################################### /** * Returns the HTML for all printed children elements * * @return string Printed HTML */ protected function _paintChildren() { $builder = ''; $this->children = array_merge($this->headers, $this->children); $this->headers = array(); $this->_calculateColumnCount(); foreach ($this->children AS $child) { $child->setColumnNumber($this->colspan); $builder .= "\n" . $child->paint(); } return $builder; } // ################################################################### /** * Paints the * * @return string Table HTML code */ public function paint() { return "
\n
width . "\"" . $this->_prepareStyle() . ">" . $this->_paintChildren() . "\n
"; } } /*=====================================================================* || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>