<?php
/**
 * Fieldset
 *
 * @date 21.03.2007
 * @name Fieldset
 * @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.WebControls
 * @category 
 * 
 * This is UI fieldset
 */
class Fieldset extends HtmlControl
{
	/*
	* Sets legend name
	*/
	public function setLegend($value)
	{
		$this->tag['legend'] = $value;
	}
	/*
	* Returns legend tag with the name
	*/
	public function getLegend()
	{
		if(isset($this->tag['legend']))
			return '<legend>'.$this->tag['legend'].'</legend>';
	}
	/*
	* Sets items
	*/
	public function setItem($name,$item)
	{
		$this->item[$name] = $item;
	}
	/*
	* Returns rendered component
	*/
	public function render()
	{
		$attributes = $this->renderAttributes();
		$items = '';
		if(isset($this->item) && is_array($this->item))
		{
			foreach($this->item as $name=>$item){
				$items.= '<li>'.$name.' '.$item.'</li>';
			}
		}
		$fieldset = '<fieldset '.$attributes.'>'.$this->getLegend().$items.'</fieldset>';
		return $fieldset;
	}
}
?>