summaryrefslogtreecommitdiff
path: root/html/_include.php
diff options
context:
space:
mode:
Diffstat (limited to 'html/_include.php')
-rw-r--r--html/_include.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/html/_include.php b/html/_include.php
new file mode 100644
index 0000000..7ce79b0
--- /dev/null
+++ b/html/_include.php
@@ -0,0 +1,66 @@
+<?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\" type=\"text/css\" />\n"
+ . "<link rel=\"stylesheet\" href=\"/style/amber.css\" title=\"Amber\" type=\"text/css\" />\n"
+ . "<link rel=\"alternate stylesheet\" href=\"/style/green.css\" title=\"Green\" type=\"text/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";
+}
+
+?>