diff options
Diffstat (limited to 'html/@include.php')
| -rw-r--r-- | html/@include.php | 59 | 
1 files changed, 59 insertions, 0 deletions
| diff --git a/html/@include.php b/html/@include.php new file mode 100644 index 0000000..2cf50d3 --- /dev/null +++ b/html/@include.php @@ -0,0 +1,59 @@ +<?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']; + +	$hbeg = $hide && !$selected ? '!--' : ''; +	$hend = $hide && !$selected ? '--' : ''; +	$sel = $selected ? ' class="selected"' : ''; + +	return "<{$hbeg}li{$sel}><a href=\"{$url}\">{$text}</a></li{$hend}>"; +} + +/// 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"; +} + +?> | 
