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
|
<?php
/// Indent all the lines in a string with a given number of tabs
function indent($s, $n, $indent_first_line = false) {
$s = preg_replace("/^/m", str_repeat("\t", $n), $s);
if (!$indent_first_line) {
$s = substr($s, $n);
}
return $s;
}
/// Get the standard <head> elements for the site
function site_head($title) {
return "<title>{$title}</title>\n"
. "<link rel=\"stylesheet\" href=\"/style/main.css\" />\n"
. "<!--\n"
. " Hi there. Nice to see you here. Feel free to have a look around. Also check out the /about\n"
. " page while you're at it. It's got a little bit more info about the site and the resources\n"
. " used.\n"
. "-->\n";
}
/// Get a single top-level navigation item for the site
function site_navitem($url, $text, $hide = false) {
$selected = $url == $_SERVER['REQUEST_URI'];
$classes = [];
if ($selected) {
$classes[] = "selected";
}
if ($hide && !$selected) {
$classes[] = "hidden";
}
$classes = count($classes) > 0 ? (" class=\"" . implode(" ", $classes) . "\"") : "";
return "<li{$classes}><a href=\"{$url}\">{$text}</a></li>";
}
/// Get the standard page header elements for the site
function site_header($title) {
return "<h1 class=\"test\">{$title}</h1>\n"
. "<nav>\n"
. "\t<ul>\n"
. "\t\t" . site_navitem('/', 'Home') . "\n"
. "\t\t" . site_navitem('/projects', 'Projects') . "\n"
. "\t\t" . site_navitem('/blog', 'Blog') . "\n"
. "\t\t" . site_navitem('/privacy', 'Privacy') . "\n"
. "\t\t" . site_navitem('/contact', 'Contact') . "\n"
. "\t\t" . site_navitem('/about', 'About', true) . "\n"
. "\t</ul>\n"
. "</nav>\n";
}
/// Get the standard page footer elements for the site
function site_footer() {
return "<hr />\n"
. "<p>Spragg Software Services Ltd is registered in England, No. 11248242.\n"
. " Registered office: 82 Upper Hanover Street, Sheffield, S3 7RQ.\n"
. " VAT reg No. 295343283.</p>\n";
}
?>
|