<?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"; } ?>