* 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"; } /* Holiday Stuff! If the current day is one of the set holidays, it will use a seperate stylesheet. Aswell as a few extra things depending on the day. This only adds April Fools for now. TODO: Add setup block to make the whole holiday thing "optional". / Choose what holidays you wish to use. */ if(/*date('d/m') == '01/01' || date('d/m') == '14/02' || */date('d/m') == '01/04'/* || date('d/m') == '24/12' || date('d/m') == '25/12' || date('d/m') == '31/12'*/){ $csssheet = " {$site_name} "; // Custom links: These appear on the menu. $custom_links = ""; if($user->is_anonymous()) { $custom_links .= $this->navlinks(make_link('user_admin/login'), "Account", array("user", "user_admin", "setup", "admin", "profile")); } else { $custom_links .= $this->navlinks(make_link('user'), "Account", array("user", "setup", "user_admin", "admin", "profile")); } $custom_links .= $this->navlinks(make_link('post/list'), "Posts", array("post", "view")); $custom_links .= $this->navlinks(make_link('comment/list'), "Comments", array("comment")); $custom_links .= $this->navlinks(make_link('tags'), "Tags", array("tags")); $custom_links .= $this->navlinks(make_link('upload'), "Upload", array("upload")); if(class_exists("Wiki")) { $custom_links .= $this->navlinks(make_link('wiki/rules'), "Rules", array("wiki/rules")); $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", array("wiki")); } $menu .= "$custom_links"; $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 = _get_query_parts(); $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": $cs .= "All"; $cs .= "My Favorites"; $cs .= "Feed"; if($hw) $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
";} $debug = get_debug_info(); $contact = empty($contact_link) ? "" : "
Contact"; $subheading = empty($page->subheading) ? "" : "
{$page->subheading}
"; $wrapper = ""; if(strlen($page->heading) > 100) { $wrapper = ' style="height: 3em; overflow: auto;"'; } if($page->left_enabled==false) { $left_block_html = ""; $main_block_html = "
$main_block_html
"; } else { $left_block_html = ""; $main_block_html = "
$main_block_html
"; } // This is required for the holiday feature. if(empty($csssheet)){ $csssheet = ""; } if(empty($banner)){ $holiday = ""; } print << {$page->title} $csssheet $header_html $banner $menu $custom_sublinks $sub_block_html $left_block_html $main_block_html EOD; } /** * A handy function which does exactly what it says in the method name */ private function block_to_html($block, $hidable=false, $salt="") { $h = $block->header; $b = $block->body; $html = ""; $i = str_replace(' ', '_', $h) . $salt; if($hidable) $html .= " "; if(!is_null($h)) { if($salt == "main") { $html .= ""; } else { $html .= ""; } } if(!is_null($b)) { //if(strpos($b, "")) { if($salt =="main") { $html .= "
$b
"; } else { $html .= " "; } } return $html; } private function navlinks($link, $desc, $pages_matched) { /** * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) */ $html = null; $url = $_GET['q']; $re1='.*?'; $re2='((?:[a-z][a-z]+))'; if ($c=preg_match_all ("/".$re1.$re2."/is", $url, $matches)) { $url=$matches[1][0]; } for($i=0;$i