* 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 = ""; ksort($page->html_headers); 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 = "

"; // hack global $user; $username = url_escape($user->name); // hack $qp = explode("/", ltrim(@$_GET["q"], "/")); $hw = class_exists("Wiki"); $cs = ""; // 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
";} $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
"; } $flash = get_prefixed_cookie("flash_message"); $flash_html = ""; if($flash) { $flash_html = "".nl2br(html_escape($flash))." [X]"; set_prefixed_cookie("flash_message", "", -1, "/"); } print << {$page->title} $header_html
$menu $custom_sublinks $sub_block_html
$left_block_html $flash_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; $i = str_replace(' ', '_', $h) . $salt; $html = "
"; if(!is_null($h)) { if($salt == "main") { $html .= ""; } else { $html .= ""; } } if(!is_null($b)) { if($salt =="main") { $html .= "
$b
"; } else { $html .= " "; } } $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 = ltrim($_GET['q'], "/"); $re1='.*?'; $re2='((?:[a-z][a-z_]+))'; if (preg_match_all ("/".$re1.$re2."/is", $url, $matches)) { $url=$matches[1][0]; } $count_pages_matched = count($pages_matched); for($i=0; $i < $count_pages_matched; $i++) { if($url == $pages_matched[$i]) { $html = "$desc"; } } if(is_null($html)) {$html = "$desc";} return $html; } } ?>