<?php
/**
 * Html table
 *
 * @date 21.03.2007
 * @name Table
 * @author Margo Poolak <margo 'dot' poolak 'at' mail 'dot' ee>
 * @copyright Copyright &copy;2006 Margo Poolak. All Rights Reserved.
 * @version 2.0
 * @package System.Web.UI.HtmlControls
 * @category 
 * 
 * This is UI control component to generate HTML tabel
 */
class Table extends HtmlControl
{
	public $Rows;
	/*
	* Constructor
	* Creating object body collection
	* sets tag name to table
	*/
	function __construct()
	{
		$this->Rows = new BodyCollection();
		$this->setTagName('table');
	}
	/*
	* Sets border width
	* @parameter string width
	*/
	function setBorder($width=1)
	{
		if(is_string($width))
			$this->attribute['border'] = $width;
	}
	/*
	* Renders the content
	* @returns the table string
	*/
	function render()
	{
		$items = $this->Rows->getItems();
		$table = '';
		foreach($items as $row)
		{
			$cells = '';		
			foreach($row->Cells->Items as $item)
			{
				$cells .= $item->renderBody();// render cell
			}
			$row->Text = $cells;// set row text
			$this->Text .= $row->renderBody();// set rendered rows to table
		}
		$table = $this->renderBody();// render tables
		return $table;
	}
}
?>