<?php
	require_once( $GLOBALS["site_root"]."/includes/widgets/Widget.inc.php" );

	class FrontendRadio extends Widget {
		protected $aValues = array();
		protected $sValue = "all";
		protected $bVertical = false;

		public function setValue( $v ) { $this->sValue = $v; }

		public function __construct( $id , $parent = null ) {
			parent::__construct( $id , $parent );
			$this->initValues();
		}

		public function refreshValueFromArray( $arr = null ) {
			if (!isset( $arr )) $arr = $this->aP;
			if (!isset( $arr[$this->getId()] )) return;
			$this->sValue = $arr[$this->getId()];
		}
		
		public function addOptions( $arr ) { foreach ($arr as $k => $v) $this->aValues[$k]=$v; }
		public function addOption( $k , $v ) { $this->aValues[$k]=$v; }
		public function setVertical( $v ) { $this->bVertical = $v; }

		protected function initValues() {
		}

		public function render() {
			if ($this->sRendered) return $this->sRendered;
			$this->setParam( "aValues" , $this->aValues );
			$this->setParam( "value" , $this->sValue );
			$this->setParam( "bVertical" , $this->bVertical );
			return parent::render();
		}
		
	}
?>
