navigation  interaction  search

 other resources

root/tags/phpbms-0.62/menu.php

Revision 102 (checked in by brieb, 2 years ago)

Started organizing css and recoded the html output for the menu.

Line 
1 <?php
2 /*
3  +-------------------------------------------------------------------------+
4  | Copyright (c) 2005, Kreotek LLC                                         |
5  | All rights reserved.                                                    |
6  +-------------------------------------------------------------------------+
7  |                                                                         |
8  | Redistribution and use in source and binary forms, with or without      |
9  | modification, are permitted provided that the following conditions are  |
10  | met:                                                                    |
11  |                                                                         |
12  | - Redistributions of source code must retain the above copyright        |
13  |   notice, this list of conditions and the following disclaimer.         |
14  |                                                                         |
15  | - Redistributions in binary form must reproduce the above copyright     |
16  |   notice, this list of conditions and the following disclaimer in the   |
17  |   documentation and/or other materials provided with the distribution.  |
18  |                                                                         |
19  | - Neither the name of Kreotek LLC nor the names of its contributore may |
20  |   be used to endorse or promote products derived from this software     |
21  |   without specific prior written permission.                            |
22  |                                                                         |
23  | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     |
24  | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       |
25  | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
26  | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
27  | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
28  | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
29  | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
30  | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
31  | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
32  | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
33  | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
34  |                                                                         |
35  +-------------------------------------------------------------------------+
36 */
37
38 function getMenu(){
39     global $dblink;
40     
41     $querystatement="SELECT id,name,link,accesslevel FROM menu WHERE parentid=0 ORDER BY displayorder";
42     $queryresult=mysql_query($querystatement,$dblink);
43     if(!$queryresult) reportError(1,"Error Retrieving Menu");
44     
45     return $queryresult;
46 }
47
48 function getSubItems($parentid){
49     global $dblink;
50
51     $querystatement="SELECT id,name,link,accesslevel FROM menu WHERE parentid=".$parentid." ORDER BY displayorder";
52     $queryresult=mysql_query($querystatement,$dblink);
53     if(!$queryresult) reportError(1,"Error Retrieving Menu");
54
55     if (mysql_num_rows($queryresult)<1) return false; else return $queryresult;
56 }
57
58     $menus=getMenu();
59     $nummenus=mysql_num_rows($menus);
60
61 ?><script language="JavaScript" src="<?php echo $_SESSION["app_path"]?>common/javascript/menu.js" type="text/javascript" ></script>
62 <script language="JavaScript" src="<?php echo $_SESSION["app_path"]?>common/javascript/common.js" type="text/javascript" ></script>
63 <script language="JavaScript" >
64     var spinner=new Image;spinner.src=+"<?php echo $_SESSION["app_path"] ?>common/image/spinner.gif";
65     var upArrow=new Image;upArrow.src="<?php echo $_SESSION["app_path"] ?>common/image/up_arrow.gif";
66     var downArrow=new Image;downArrow.src="<?php echo $_SESSION["app_path"] ?>common/image/down_arrow.gif";
67 </script>
68 <div id="menu" >
69     <h1><a href="<?php echo $_SESSION["app_path"]?><?php echo $_SESSION["default_load_page"]?>" title="<?php echo htmlQuotes($_SESSION["application_name"]);?>"><span><?php echo $_SESSION["application_name"];?></span></a></h1>
70
71     <div id="menuRighthandButtons">
72         <a href="/click for information/"  name="toptop" id="loggedinuser" onClick="showUserInfo('<?php echo $_SESSION["app_path"]?>'); return false;"><?php echo trim($_SESSION["userinfo"]["firstname"]." ".$_SESSION["userinfo"]["lastname"])?></a>       
73         <button name="menuLogout" type="button" onClick="document.location=('<?php echo $_SESSION["app_path"]?>logout.php')" title="log out" class="smallButtons">log out</button>
74         <button name="menuHelp" type="button" onClick="showHelp('<?php echo $_SESSION["app_path"]?>')" title="Help" class="smallButtons">?</button>
75     </div>
76        
77     <ul id="menuBar">
78     <?php     
79         $submenustring="";
80         while($menurecord=mysql_fetch_array($menus)){
81             if($_SESSION["userinfo"]["accesslevel"]>=$menurecord["accesslevel"]){
82                 if($menurecord["link"]) {
83                     if(strpos($menurecord["link"],"http")!==0)
84                         $menurecord["link"]=$_SESSION["app_path"].$menurecord["link"];
85                     ?><li><a href="<?php echo $menurecord["link"]?>"><?php echo $menurecord["name"]?></a></li><?php
86                 }
87                 else { ?><li><a href=""  id="menu<?php echo $menurecord["id"]?>"  onClick="expandMenu(this);return false;"  onMouseOver="checkExpand(this)"><?php echo $menurecord["name"]; ?>&nbsp;<img src="<?php echo $_SESSION["app_path"]?>common/image/down_arrow.gif" id="menuImage<?php echo $menurecord["id"]?>" width=10 height=10 border="0" ></a></li><ul class="submenuitems" style="display:none;" id="submenu<?php echo $menurecord["id"]?>"><?php
88                     $submenustring.=$menurecord["id"].",";
89                     $subitemsquery=getSubItems($menurecord["id"]);
90                     if($subitemsquery){
91                         while($subrecord=mysql_fetch_array($subitemsquery)){
92                             if($_SESSION["userinfo"]["accesslevel"]>=$subrecord["accesslevel"]){
93                                 if(strpos($subrecord["link"],"http")!==0)
94                                     $subrecord["link"]=$_SESSION["app_path"].$subrecord["link"];
95                             ?><li><a href="<?php echo $subrecord["link"]?>">&nbsp;<?php echo $subrecord["name"] ?></a></li><?php }//end if
96                         }//end while
97                     }//end if
98                     echo "</ul>";
99                 }//end if
100             }//end if
101         }//end while
102         $submenustring=substr($submenustring,0,strlen($submenustring)-1);
103     ?></ul></div><script language="JavaScript">var subMenuArray="<?php echo $submenustring ?>".split(",");</script>
104 <?PHP if (isset($statusmessage)) {?>
105 <div id="statusmessage"><?PHP echo $statusmessage ?></div>
106 <?PHP } // end if ?>
107     
108
Note: See TracBrowser for help on using the browser.
Copyright © 2006-2007 Kreotek, LLC. All Rights reserved.