Location: PHPKode > scripts > DMenuGenerator > dmenugenerator/menu.class.php
<?
#########################################################################
#### @Autor:  Dyego Fernandes de Sousa                               ####
#### @E-mail: hide@address.com                                  ####
#### @Título: Criador de Menus DHTML  {Creator of DHTML Menus}       ####
#### @E-mail: hide@address.com, hide@address.com    ####
#########################################################################

	/*Comentários / Notes
	****************************************************************************
	*	   English                        |         Português                   *
	*-------------------------------------|------------------------------------*
	* This class perform actions to create|Esta classe executa ações para criar*
	* a DHTML menu, using: JavaScript and | um menu DHTML, usando Javascript e *
	* CSS Style Sheets. It´s very util if |  estilos CSS. Ela é muito útil se  *
	*  you want create a site, or a Web   |  você deseja criar um site ou uma  *
	*           Application               | Aplicação Web                      *
	****************************************************************************
	*/
class menu{
var $labels;
var $items;
var $width;
var $height;
var $menuSettings;
var $btnClickAction;
	/*
	Comentários / Notes
	****************************************************************************
	*	   English                        |         Português                   *
	*-------------------------------------|------------------------------------*
	*   Method to create the JavaScript   |  Método para criar uma função em   *
	* function to do the rollover action  |   JavaScript que fará a ação de    *
	*           for the menu              |        rollover para o menu        *
	****************************************************************************
	*/
	function jsMenu($settings){
		$jsMenu = "<script type ='text/javascript'>\n";
		$jsMenu.= "\tfunction changeCl(obj,flag){\n";
		$jsMenu.= "\t\tif(flag){\n";
		$jsMenu.="\t\tobj.style.backgroundColor 	= '".$settings[1]."';\n";
		$jsMenu.="\t\tobj.style.color 				= '".$settings[5]."';\n";
		$jsMenu.="\t\tobj.style.textDecoration 		= '".$settings[3]."';\n";
		$jsMenu.="\t\tobj.style.border				= '".$settings[7]."';\n";
		$jsMenu.="\t\tobj.style.fontWeight			= '".$settings[9]."';\n";
		$jsMenu.="\t\tobj.style.fontFamily			= '".$settings[11]."';\n";
		$jsMenu.="\t\tobj.style.fontSize			= '".$settings[13]."';\n";
		$jsMenu.="\t\t} else {\n";
		$jsMenu.="\t\t\tobj.style.backgroundColor 	= '".$settings[0]."';\n";
		$jsMenu.="\t\t\tobj.style.color 			= '".$settings[4]."';\n";
		$jsMenu.="\t\t\tobj.style.textDecoration 	= '".$settings[2]."';\n";
		$jsMenu.="\t\t\tobj.style.border		   	= '".$settings[6]."';\n";
		$jsMenu.="\t\t\tobj.style.fontWeight		= '".$settings[8]."';\n";
		$jsMenu.="\t\t\tobj.style.fontFamily		= '".$settings[10]."';\n";
		$jsMenu.="\t\t\tobj.style.fontSize			= '".$settings[12]."';\n";
		$jsMenu.="\t\t\t}\n";
		$jsMenu.="\t\t}\n";
		$jsMenu.="</script>\n";
		return $jsMenu;
	}
	/*
	Comentários / Notes
	****************************************************************************
	*	   English                        |         Português                   *
	*-------------------------------------|------------------------------------*
	* Method to create the Menu objects,  |  Método para criar os objetos do   *
	* with your attributes, styles and    | Menu, com seus atributos, estilos  *
	*          other properties           |    e demais propriedades           *
	****************************************************************************
	*/	function createMenu($border,$bgcolor,$fontcolor){
		$menu 	 = "\n<div style='width:".$this->width."px; height:".$this->height."px; background-color:beige'>\n";
		$unWidth = round(($this->width - ($this->items)*4)/$this->items);
		$style	 = "height:".$this->height."px ; width:".$unWidth."px; border:".$border."; background-color:".$bgcolor."; color:".$fontcolor."";
			for($i = 0; $i<$this->items; $i++){
				$menu .= "\t<input type='button' style='".$style."' value='".$this->labels[$i]."' onMouseOver='changeCl(this,1)' onMouseOut='changeCl(this,0)'  onClick='".$this->btnClickAction[$i]."' />\n";
			}
		$menu	.="</div>\n";
		return $menu;
	}
	/*
	Comentários / Notes
	****************************************************************************
	*	   English                        |         Português                   *
	*-------------------------------------|------------------------------------*
	* Method to print a String, very util | Método para imprimir uma string,   *
	*                                     |           Muito útil               *
	****************************************************************************
	*/
	function process($str){
		print($str);
	}
	/*
	Comentários / Notes
	****************************************************************************
	*	   English                        |         Português                   *
	*-------------------------------------|------------------------------------*
	*	  Constructor                     |        Construtor                  *
	****************************************************************************
	*/
	function menu($menuConfig){
		$this->labels			= $menuConfig['labels'];
		$this->items 			= count($menuConfig['labels']);
		$this->width			= $menuConfig['config'][0];
		$this->height			= $menuConfig['config'][1];
		$this->menuSettings		= $menuConfig['mnSett'];
		$this->btnClickAction	= $menuConfig['btnAct'];
		
		$this->process($this->jsMenu($this->menuSettings));
		$this->process($this->createMenu($this->menuSettings[6],$this->menuSettings[0],$this->menuSettings[4]));
	}
}

?>
Return current item: DMenuGenerator