<?php
ob_start();/* header buffer */
session_start();
?>
<html>
<head>
<?php
################## legend #############################
### different sections
// things to do
/* information */
#######################################################
/* php 5 */
/* Mutliple tiers */
/* Menu data is stored in a class array and selected through post with a menuId variable*/
/* Link adresses can be include files or web addresses*/
/* The menu information is stored in a class array */
/* The menu id number is returned by post*/
/* Useing the id number the the data is extacted from the class array*/
/* The link file is put in an table cell*/
/* Change css for different styles */
### new instance of menu bar class ###################
// set menu bar name
$menuBar= new menuBar("menu bar name");
### new menu settings ###############################
// set menu bar width
$menuWidth= "130px";
// set sub menus width
$subMenuWidth= "100px";
// delete lines or add lines as required.
// group: collection of menus.
// menu: handle for link address.
// change class function settings to form menu groups, menus and set link addresses.
// link addresses can be an included file ('inc') or copy of a web address ('copy').
// class function,type, group, group or menu,----------- link file ---------------------------------------
$menuBar->menuSet('copy','Main','Home' ,'http://snippets.bluejon.co.uk/index.php');
$menuBar->menuSet('copy','Main','Scrolling tables ' ,'');
$menuBar->menuSet('copy','Scrolling tables ','Version 2','http://scrolltable.bluejon.co.uk/scrollTableV2.php');
$menuBar->menuSet('copy','Scrolling tables ','Version 3','http://scrolltable.bluejon.co.uk/scrollTableV3.php');
$menuBar->menuSet('copy','Scrolling tables ','Version 4','http://scrolltable.bluejon.co.uk/scrollTableV4.php');
$menuBar->menuSet('copy','Main' ,'Script Enabled' ,'');
$menuBar->menuSet('inc','Script Enabled','Version 1','/includes/check4-js-endabled-v1.php');
$menuBar->menuSet('inc','Script Enabled','Version 2','/includes/check4-js-enabled-v2.php');
$menuBar->menuSet('inc','Script Enabled','Version 3-1','/includes/check4-js-and-cookie-enabled-v3-1.php');
$menuBar->menuSet('copy','Main','Menus','http://snippets.bluejon.co.uk/menu/menubar-vert-v1.php');
$menuBar->menuSet('copy','Main','Database','http://snippets.bluejon.co.uk/db-editor/db-viewer-v1.php');
$menuBar->menuSet('copy','Main','Maps' ,'http://snippets.bluejon.co.uk/streetmap/streetmap-v1.php');
$menuBar->menuSet('copy','Main','Miscellaneous' ,'');
$menuBar->menuSet('copy','Miscellaneous','Variables','http://snippets.bluejon.co.uk/misc/varNameIncremented.php');
$menuBar->menuSet('inc','Miscellaneous','Time Zones','/includes/local-timezone-v1.php');
### settings end #####################################
### php menubar class ##################################
class menuBar{
protected $menuBarName;
protected $groupList= array();
protected $menuList= array();
protected $menuGroupNum;
protected $menuGroupId;
protected $menuId;
function __construct($menuBarNameInput){
$this->menuBarName= $menuBarNameInput;
}
function menuSet($linkType,$menuGroupInput,$menuNameInput,$menuLinkInput){/* inputs for menu */
$this->menuId++;
$this->menuList[$this->menuId]= array(/* make menu array */
id=>$this->menuId,
linkType=> $linkType,
name=>$menuNameInput,
link=>$menuLinkInput
);
$this->groupList[$menuGroupInput][$menuNameInput]= $this->menuId;/*add menuId number group array */
}
function menuBarDisplay(){ /* display menu bar */
$this->menuGroupNum= 0;
print "<div class= 'menuBar'id= 'mbar'>";/* css for menubar */
print "<div class= 'menuBarName'>";/* css for menubar name */
print $this->menuBarName;/* display menu bar name */
print "</div>";
foreach($this->groupList as $menuBarKey=> $menuBarValue){
if(!$this->menuSearch($menuBarKey)){/* search menu array to detect if it is a parent menu */
print"<div class= 'menuGroup'>";
print $menuBarKey;
print"</div>";
$this->menuDisplay($menuBarKey);
}
}
print "</div>";
}
function menuDisplay($groupKeyVar){ /* display menus */
foreach($this->groupList[$groupKeyVar] as $menuKey=> $menuValue){
if(array_key_exists($menuKey,$this->groupList)){
$this->menuGroupNum++;
$this->menuGroupId= "groupId".$this->menuGroupNum;
print"<div class= 'menuGroup'style='z-index: 1000'
onMouseOver= showHide('$this->menuGroupId');
onMouseOut= showHide('$this->menuGroupId'); >";
print $menuKey. "<span style='position:absolute;right:0;'> >></span>";/* pointer arrows for hidden menus */
print"<div class= 'hide' id= '$this->menuGroupId'>";
$this->menuDisplay($menuKey);
print"</div>";
print"</div>";
}else{/* menuId number for $P0ST */
print "<div class= 'menu'
onMouseOver= \"this.className= 'mouseHov'\"
onMouseOut= \"this.className= 'menu'\"
onClick= \"menuInput('$menuValue'); \" >";
print $this->menuList[$menuValue]['name'];
print "</div>";
}
}
}
function menuSearch($menu){ /* search for parent in menu array */
foreach($this->menuList as $menuKey=> $menuValue){
if($menuValue['name']== $menu){
return true;
}
}
return false;
}
function menuSelect($menuId){/* */
switch ($this->menuList[$menuId]['linkType']){
case inc:
include($_SERVER['DOCUMENT_ROOT'].$this->menuList[$menuId]['link']);
break;
case copy:
print file_get_contents($this->menuList[$menuId]['link']);
break;
default:
if(count($this->menuList > 0)){
print file_get_contents($this->menuList[1]['link']);
}
break;
}
}
}
?>
<!### CSS ############################################>
<style type="text/css">
<!--
div.menu, .mouseOut, .mouseHov, .show{/* common css */
text-decoration:none;
text-align:left;
text-indent:10px;
font-weight:200;
font-style:normal;
font-family:sans-serif;
font-size:12px;
color:white;
background-color:royalBlue;
}
div.menuBar{/* css for menu bar */
width:<?php print $menuWidth;?>;
border-top:1px solid black;
border-bottom:1px solid black;
}
div.menuBarName{/* css for menu bar name */
line-height:1.5em;
text-align:center;
font-size:16px;
font-weight:400;
font-style:normal;
font-family:helvetica;
color:white;
background-color:royalBlue;
border-left:1px solid black;
border-right:1px solid black;
}
div.menuGroup{/* css for menu groups */
position:relative;
overflow:visible;
border-top:1px solid black;
border-left:1px solid black;
border-right:1px solid black;
cursor:default;
color:white;
background-color:cornFlowerBlue;
text-align:center;
font-size:14px;
font-weight: 300;
font-style:normal;
font-family:arial;
color:white;
}
div.menu{
border-top:1px solid black;
border-left:1px solid black;
border-right:1px solid black;
}
/* css for mouse linked to javascript */
.mouseHov{
background-color:#0000CD;
color:yellow;
cursor:pointer;
cursor:hand;
border-top:1px solid black;
border-left:1px solid black;
border-right:1px solid black;
}
.hide{
display:none;
}
.show{
top:0;
position:absolute;
width:<?php print $subMenuWidth; ?>;
z-order:200;
overflow:visible;
right:-<?php print $subMenuWidth;?>;
border-bottom:1px solid black;
}
/* css for page layout */
table.layout{
color:#404040;
background-color:LightSteelBlue;
margin:0px;
padding:0;
border:1px blue solid;
border-collapse:collapse;
border-spacing:0;
border-spacing:0;
}
td.content{
width:600px;
vertical-align:top;
padding:0;
border:1px blue solid;
}
-->
</style>
<!### javascript ###################################>
<script type = "text/javascript">/* javascript */
function showHide(Id){
var group = document.getElementById(Id);
menu_status = group.className
if(menu_status != 'show'){
group.className = 'show';
}else{
group.className = 'hide';
}
}
function menuInput(id){/* submit menuId number by post */
document.getElementById('menuId').value =id;
menuForm.submit();
}
</script>
<!### display #########################################>
</head>
<body>
<?php
if($_POST['menuId']){/* check for $_POST from form with menuId number and store in a session*/
//$menuId=$_POST['menuId'];
$_SESSION['menuId']=$_POST['menuId'];
$menuId= $_SESSION['menuId'];
};
### display link file in table #####################>
?>
<form name= "menuForm" method= "post" action= "<?php print $PHP_SELF;?>" >
<input type= "hidden" name= "menuId" id= "menuId">
</form>
<table class= 'layout'>
<tr>
<td> </td>
<td><center><h1>Display Link Content</h1></center></td>
</tr>
<tr>
<td style='vertical-align:top;'><?php $menuBar->menuBarDisplay();?></td>
<td class= 'content'><?php $menuBar->menuSelect($menuId);/*check for a menu selected through post*/?></td>
</tr>
</table><br>
<a href="http://snippets.bluejon.co.uk/menu/menubar-vert-v2-phpcode.php">Display php source code </a>
</body>
</html>
<?php
ob_end_flush();
?>