-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainMenuClass.php
44 lines (44 loc) · 1.43 KB
/
MainMenuClass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
class MainMenuClass
{
private static $menu;
private static function addMenuItemAuto($name, $file)
{
if("" == basename($_SERVER['REQUEST_URI'], ".php") || strlen(strchr(basename($_SERVER['REQUEST_URI'], ".php"),"?")) > 40)
{
if($name == Index)
{
MainMenuClass::$menu->addMenuItem(new MenuItemClass($name, $file, true));
}
else
{
MainMenuClass::$menu->addMenuItem(new MenuItemClass($name, $file, false));
}
}
else
{
if($file == basename($_SERVER['REQUEST_URI'], ".php") . ".php")
{
MainMenuClass::$menu->addMenuItem(new MenuItemClass($name, $file, true));
}
else
{
MainMenuClass::$menu->addMenuItem(new MenuItemClass($name, $file, false));
}
}
}
static function show($isAdmin)
{
MainMenuClass::$menu = new MenuClass();
MainMenuClass::addMenuItemAuto('Index', 'index.php');
MainMenuClass::addMenuItemAuto('My Home', 'myHome.php');
MainMenuClass::addMenuItemAuto('Current Planet', 'currentPlanet.php');
MainMenuClass::addMenuItemAuto('Ship Actions', 'shipActions.php');
if($isAdmin)
{
MainMenuClass::addMenuItemAuto('Admin Page', 'adminPage.php');
}
MainMenuClass::$menu->printMenu();
}
}
?>