-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.php
103 lines (91 loc) · 2.67 KB
/
index.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
<?php
declare(strict_types=1);
// Created: 20150101 - Updated: 20250209
// Copyright (C) 2015-2025 Mark Constable <[email protected]> (AGPL-3.0)
echo new class
{
private readonly array $nav;
private array $out = [
'doc' => 'SPE::00',
'nav' => '',
'head' => 'Simple PHP Examples',
'main' => '<p>This is a super simple set of PHP 8 examples.</p>',
'foot' => 'Copyright © 2015-2025 Mark Constable (AGPL-3.0)',
];
public function __construct()
{
$this->nav = [
['01-Simple', '01-Simple'],
['02-Styled', '02-Styled'],
['03-Plugins', '03-Plugins'],
['04-Themes', '04-Themes'],
['05-Autoload', '05-Autoload/public'],
['06-Session', '06-Session/public'],
['07-PDO', '07-PDO/public'],
['08-Users', '08-Users/public'],
['09-Auth', '09-Auth/public'],
['10-BareBone', '10-BareBone/public'],
];
}
public function __toString(): string
{
return $this->html();
}
private function nav(): string
{
$links = array_map(
fn($n) => ' <li>
<a href="' . $n[1] . '">' . $n[0] . '</a>
</li>',
$this->nav
);
return '
<nav aria-label="Main navigation">
<ul role="list">
' . implode('
', $links) . '
</ul>
</nav>';
}
private function head(): string
{
return '
<header>
<h1>' . $this->out['head'] . '</h1>' . $this->nav() . '
</header>';
}
private function main(): string
{
return '
<main id="main">
' . $this->out['main'] . '
</main>';
}
private function foot(): string
{
return '
<footer>
<p>
<small>' . $this->out['foot'] . '</small>
</p>
</footer>';
}
private function html(): string
{
return '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
<meta http-equiv="Content-Security-Policy" content="default-src \'self\'">
<meta name="color-scheme" content="light dark">
<title>' . $this->out['doc'] . '</title>
<meta name="description" content="Simple PHP Examples">
<meta name="author" content="Mark Constable">
<link rel="icon" href="favicon.ico">
</head>
<body>' . $this->head() . $this->main() . $this->foot() . '
</body>
</html>';
}
};