Location: PHPKode > scripts > PHP 4 Applications > php-4-applications/p4a_barmenu.php
<?php
	require_once("p4a_constants.php");
	require_once("p4a_control.php");

class p4a_BarMenu extends p4a_Control
{
	var $mainoption;

	function p4a_BarMenu()
	{
		$this->type='barmenu';
	}

	function setMainOption( $_on, $_l, $_ev='')
	{
		$this->mainoption[$_on]['label'] = $_l;
		$this->mainoption[$_on]['selected'] = 0;
		if (!empty($_ev))
			$this->mainoption[$_on]['event'] = $_ev;
	}

	function setSelected( $_on)
	{
		foreach($this->mainoption as $cn => $v)
			$this->mainoption[$cn]['selected'] = 0;

		$this->mainoption[$_on]['selected'] = 1;
	}
 
	function flush( $_ev=0)
	{
		if (!$_ev)
			$da="";
		else
			$da="parent.";

		$js = "<script language='JavaScript'>";
		$js .= $da.$this->id_html.".className='clsBarMenu';";
		$js .= $da.$this->id_html.".innerHTML='";

		$js .= "<ul>";
		foreach($this->mainoption as $on => $v)
		{
			$js .= "<li";
			if ((isset($v['event']))&&($v['selected']==0))
				$js .= " onclick=\"javascript:p4a_eventFrame.location.href=&#039;p4a_events.php?event=".$v['event']."&#039;\"";
			if ($v['selected']==1)
				$js .= " class=\"clsMainOptionSelected\"";
			else
				$js .= " onmouseover=\"javascript:this.className=&#039;clsMainOptionOver&#039;;\" onmouseout =\"javascript:this.className=&#039&#039;;\"";

			$js .= ">".$v['label']."</li>";
		}
		$js .= "</ul>';";
		$js .= "</script>";

		return $js;
	}
}
?>
Return current item: PHP 4 Applications