* Link: http://seemslegit.com
* License: GPLv2
* Description: A mashup of Default, Danbooru, the interface on qwebirc, and
* 	       some other sites, packaged in a light blue color.
*/
class Layout {
	/**
	 * turns the Page into HTML
	 */
	public function display_page(Page $page) {
		global $config, $user;
		$theme_name = $config->get_string('theme', 'lite');
		$site_name = $config->get_string('title');
		$data_href = get_base_href();
		$contact_link = $config->get_string('contact_link');
		$header_html = "";
		foreach($page->html_headers as $line) {
			$header_html .= "\t\t$line\n";
		}
		$menu = "
";
		
		$left_block_html = "";
		$main_block_html = "";
		$sub_block_html  = "";
		$user_block_html = "";
		foreach($page->blocks as $block) {
			switch($block->section) {
				case "left":
					$left_block_html .= $this->block_to_html($block, true, "left");
					break;
				case "main":
					$main_block_html .= $this->block_to_html($block, false, "main");
					break;
				case "user":
					$user_block_html .= $block->body;
					break;
				case "subheading":
					$sub_block_html .= $this->block_to_html($block, false, "main");
					break;
				default:
					print "error: {$block->header} using an unknown section ({$block->section})";
					break;
			}
		}
		$custom_sublinks = "
";
		$cs = null;
		// hack
		global $user;
		$username = url_escape($user->name);
		// hack
		$qp = explode("/", ltrim(@$_GET["q"], "/"));
		$hw = class_exists("Wiki");
		// php sucks
		switch($qp[0]) {
			default:
				$cs = $user_block_html;
				break;
			case "":
				# FIXME: this assumes that the front page is
				# post/list; in 99% of case it will either be
				# post/list or home, and in the latter case
				# the subnav links aren't shown, but it would
				# be nice to be correct
			case "post":
				if(class_exists("NumericScore")){ $cs .= "
Popular by Day/Month/Year ";}
				$cs .= "
All";
				if(class_exists("Favorites")){ $cs .= "
My Favorites";}
				if(class_exists("RSS_Images")){ $cs .= "
Feed";}
				if(class_exists("Random_Image")){ $cs .= "
Random Image";}
				if($hw){ $cs .= "
Help";
				}else{ $cs .= "
Help";}
				break;
			case "comment":
				$cs .= "
All";
				$cs .= "
Feed";
				$cs .= "
Help";
				break;
			case "pool":
				$cs .= "
List";
				$cs .= "
Create";
				$cs .= "
Changes";
				$cs .= "
Help";
				break;
			case "wiki":
				$cs .= "
Index";
				$cs .= "
Rules";
				$cs .= "
Help";
				break;
			case "tags":
			case "alias":
				$cs .= "
Map";
				$cs .= "
Alphabetic";
				$cs .= "
Popularity";
				$cs .= "
Categories";
				$cs .= "
Aliases";
				$cs .= "
Help";
				break;
			case "upload":
				if($hw) $cs .= "
Guidelines";
				break;
			case "random":
				$cs .= "
Shuffle";
				$cs .= "
Download";
				break;
			case "featured":
				$cs .= "
Download";
				break;
		}
		if($cs == "") {$custom_sublinks = "";} else {
		$custom_sublinks .= "$cs