Location: PHPKode > scripts > Dropdown Menu for phpBB2 > dropdown-menu-for-phpbb2/udm_phpbb2.class.php
<?php
/**
osCommerce UDM class
Date Created: 08-03-2007
Last Modified: 08-04-2007
Author: Brandon Carlson (hide@address.com)
License: See http://www.udm4.com/licensing/
Function: To provide UDM4 dropdown menu based on osCommerce Categories
**/
class UDM {
	/* Constructor Method */
	function UDM($db,$path) {
		$this->menu = "";
		$this->db = $db;
		$this->path = $path;
	}
	function generate($parent=0, $language=1) {
		// Generate UDM Menu using recursion
		switch($parent) {
			case "0":
					$sql = "
					SELECT 
						* 
					FROM 
						". CATEGORIES_TABLE . " 
					ORDER BY
						".CATEGORIES_TABLE.".cat_order
				";
				break;
			default:
				$sql = "
					SELECT 
						*
					FROM
						".FORUMS_TABLE."
					WHERE
						".FORUMS_TABLE.".cat_id = '$parent'
					ORDER BY
						".FORUMS_TABLE.".forum_order
				";
				break;
		}
		$rs = $this->db->sql_query($sql);
		if($this->db->sql_numrows($rs)>0) {
			$key_name = "";
			$key_id = "";
			$key_url = "";
			if($parent==0) {
				$this->menu .= "\n<ul id='udm' class='udm'>";
				$this->menu .= "\n\t<li><a href='index.php'>Home</a></li>";
				$key_name = "cat_title";
				$key_id = "cat_id";
				$key_url = "index.php?c=";
			}
			else {
				$this->menu .= "\n<ul>";
				$key_name = "forum_name";
				$key_id = "forum_id";
				$key_url = "viewforum.php?f=";
			}
			while($r =  $this->db->sql_fetchrowset($rs)) {
				foreach($r as $info) {
				$this->menu .= "\n\t<li>";
				$this->menu .= "\n\t\t<a href='".$key_url.$info[$key_id]."'>".$info[$key_name]."</a>";
				if($parent==0) {
					$this->generate($info[$key_id],$language);
				}
				$this->menu .= "\n\t</li>";
				}
			}
			$this->menu .= "\n</ul>";
		}
	}
	function display() {
		//output menu
		$this->generate();
		$content = $this->menu;
		return $content;
	}
	function get_config($type) {
		//load UDM configuration files, this uses standard configuration for additional infomation
		//visit http://www.udm4.com/manual/
		if($type=="header") {
			$content = '
				<!-- ULTIMATE DROP DOWN MENU Version 4.42 by Brothercake -->
				<!-- http://www.udm4.com/ -->
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-custom.js"></script>
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-control.js"></script>
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-style.js"></script>
			';
		}
		if($type=="body") {
			$content = '
				<!-- menu script -->
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-dom.js"></script>
				<!-- keyboard navigation module -->
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-mod-keyboard.js"></script>
			';		
		}
		return $content;
	}
}
?>
Return current item: Dropdown Menu for phpBB2