-
Notifications
You must be signed in to change notification settings - Fork 0
/
Page.php
101 lines (89 loc) · 2.57 KB
/
Page.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
<?php
/**
* Created by PhpStorm.
* User: dluong
* Date: 1/29/2018
* Time: 3:30 PM
*/
class Page
{
public $content;
public $title = 'TLA Consulting Pty Ltd';
public $keywords = 'consulting, freelance, consultants';
public $buttons = ['Home' => 'home.php', 'Contact' => 'contact.php', 'Services' => 'services.php', 'Site Map' => 'map.php'];
public function __set($name, $value) {
$this->$name = $value;
}
public function display() {
echo "<html>\n<head>\n";
$this -> displayTitle();
$this -> displayKeywords();
$this -> displayStyles();
echo "</head>\n<body>\n";
$this -> displayHeader();
$this -> displayMenu($this->buttons);
echo $this->content;
$this -> displayFooter();
echo "</body>\n</html>\n";
}
public function isURLCurrentPage($url) {
return (strpos($_SERVER['PHP_SELF'], $url) === FALSE ?: TRUE);
}
public function displayTitle() {
echo "<title>$this->title</title>";
}
public function displayKeywords() {
echo "<meta name='keywords' content='$this->keywords'/>";
}
public function displayStyles() {
?>
<link rel="stylesheet" href="styles.css">
<?php
}
public function displayMenu($buttons) {
echo '<nav>';
foreach ($buttons as $name => $url) {
$this->displayButton($name, $url, !$this->isURLCurrentPage($url));
}
echo "</nav>\n";
}
public function displayButton($name, $url, $active=TRUE) {
if ($active) {
?>
<div class="menuitem">
<a href="<?=$url?>">
<img src="s-logo.gif" alt="" height="20" width="20" />
<span class="menutext"><?=$name?></span>
</a>
</div>
<?php
}
else {
?>
<div class="menuitem">
<img src="side-logo.gif">
<span class="menutext"><?=$name?></span>
</div>
<?php
}
}
public function displayHeader() {
?>
<!-- page header -->
<header>
<img src="logo.gif" alt="TLA logo" height="70" width="70" />
<h1>TLA Consulting</h1>
</header>
<?php
}
public function displayFooter() {
?>
<!-- page footer -->
<footer>
<p>© TLA Consulting Pty Ltd.<br />
Please see our
<a href="legal.php">legal information page</a>.</p>
</footer>
<?php
}
}