* 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 = _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": if(file_exists("ext/numeric_score")){ $cs .= "Popular by Day/Month/Year ";} $cs .= "All"; if(file_exists("ext/favorites")){ $cs .= "My Favorites";} if(file_exists("ext/rss_images")){ $cs .= "Feed";} if(file_exists("ext/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
";} $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
"; } print << {$page->title} $header_html $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