-
Notifications
You must be signed in to change notification settings - Fork 2
/
Nav.php
119 lines (112 loc) · 3.79 KB
/
Nav.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
require_once( "Autoloader.php");
class Nav
{
function __construct()
{
$this->Session = new Session;
}
function SetNavBar($event){
return"
<div id='NavBarBorder'>
<div><a href='index.php'><img class='NavBarImg' src='http://hfteam3.infhaarlem.nl/cms/Images/Nav/HaarlemImage.png'></a></div>
".$this->SetEvent("Home", $event)."
".$this->SetEvent("Food", $event)."
".$this->SetEvent("Dance", $event)."
".$this->SetEvent("Historic", $event)."
".$this->SetEvent("Jazz", $event)."
".$this->SetEvent("MyProgram", $event)."
<div class='right'>
<div class='Languages'>
<a href='".$this->DeterminGET()."Language=English'><img class='LanguagesImages ".$this->DetermineActiveLanguage('English')."' src='http://hfteam3.infhaarlem.nl/cms/Images/Nav/Englishflag.png'></a>
<a href='".$this->DeterminGET()."Language=Dutch'><img class='LanguagesImages ".$this->DetermineActiveLanguage('Dutch')."' src='http://hfteam3.infhaarlem.nl/cms/Images/Nav/Dutchflag.png'></a>
</div>
<a href='Checkout.php'>
<div class='ShoppingCart'>
<div class='shopcartItems' id='shoppingcartCount'>".$this->GetCartItems()."</div>
</div>
</a>
</div>
</div>
<div id='myPopup' class='popup'>
<div class='popupContent'>
<span class='popuptext' >
<p id='#popupHeader'>Ticket(s) added to cart!</p>
<hr id='hrBars'>
<a href='Checkout.php' class='toCheckoutBTN'>To Cart</a>
</span>
</div>
</div>";
}
public function SetEvent($event, $active){
if($active == $event){
if ($event == 'Home') {
return "<div class='ActiveWrapper'>
<div class='Active'><a class='Link' href='index.php'><div class='NavActive'>".$event."</div></a></div>
</div>";
}
if ($event == 'MyProgram') {
return "<div class='ActiveWrapper'>
<div class='Active ActiveXtraWide'><a class='Link' href='".$event.".php'><div class='NavActive'>".$event."</div></a></div>
</div>";
}
return "<div class='ActiveWrapper'>
<div class='Active'><a class='Link' href='".$event.".php'><div class='NavActive'>".$event."</div></a></div>
</div>";
}
else{
if ($event == 'Home') {
return "<div class='NavLinks'><a class='Link' href='index.php'><div class='NavText'>".$event."</div></a></div>";
}
return "<div class='NavLinks'><a class='Link' href='".$event.".php'><div class='NavText'>".$event."</div></a></div>";
}
}
public function GetCartItems() {
if(isset($_SESSION['Tickets'])) {
$shoppingCartAmount = 0;
foreach (EncryptionHelper::Decrypt($_SESSION['Tickets']) as $items) {
// check if session ticket is a reservation
if ($items['TypeEvent'] == 1) {
// it's a reservation, this means session ticket contains 'Child/AdultAmount' instead of just Amount, act accordingly
$shoppingCartAmount = $shoppingCartAmount + intval($items['ChildAmount']) + intval($items['AdultAmount']);
} else {
$shoppingCartAmount = $shoppingCartAmount+ intval($items['Amount']);
}
}
return $shoppingCartAmount;
}
else {
return 0;
}
}
private function DetermineActiveLanguage($language){
if (isset($_SESSION['Language'])) {
if (EncryptionHelper::Decrypt($_SESSION['Language']) == $language) {
return 'ActiveLanguage';
}
}
else{
$_SESSION['Language'] = EncryptionHelper::Encrypt('English');
return 'ActiveLanguage';
}
}
private function DeterminGET(){
if (extract($_GET) >= 2 && isset($_GET['Language'])) {
if ($_GET['Language'] == 'English') {
$newUrl = substr($_SERVER['REQUEST_URI'], 0, -17);
return $newUrl.'&';
}
elseif ($_GET['Language'] == 'Dutch'){
$newUrl = substr($_SERVER['REQUEST_URI'], 0, -15);
return $newUrl.'&';
}
}
elseif (extract($_GET) > 0 && !isset($_GET['Language'])) {
return ''.$_SERVER['REQUEST_URI'].'&';
}
else{
return '?';
}
}
}
?>