This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/themes/warm/layout.class.php

118 lines
3.1 KiB
PHP
Raw Normal View History

2009-07-23 01:32:45 +00:00
<?php
/**
* A class to turn a Page data structure into a blob of HTML
*/
class Layout {
/**
* turns the Page into HTML
*/
public function display_page(Page $page) {
global $config;
$theme_name = $config->get_string('theme', 'default');
$site_name = $config->get_string('title');
2009-07-23 01:32:45 +00:00
$data_href = get_base_href();
$main_page = $config->get_string('main_page');
2009-07-23 01:32:45 +00:00
$contact_link = $config->get_string('contact_link');
$header_html = "";
foreach($page->html_headers as $line) {
$header_html .= "\t\t$line\n";
2009-07-23 01:32:45 +00:00
}
$left_block_html = "";
$main_block_html = "";
$head_block_html = "";
2010-01-03 09:56:07 +00:00
$sub_block_html = "";
2009-07-23 01:32:45 +00:00
foreach($page->blocks as $block) {
switch($block->section) {
case "left":
$left_block_html .= $this->block_to_html($block, true, "left");
break;
case "head":
$head_block_html .= "<td width='250'><small>".$this->block_to_html($block, false, "head")."</small></td>";
break;
case "main":
$main_block_html .= $this->block_to_html($block, false, "main");
break;
2010-01-03 09:56:07 +00:00
case "subheading":
$sub_block_html .= $block->body; // $this->block_to_html($block, true);
break;
2009-07-23 01:32:45 +00:00
default:
print "<p>error: {$block->header} using an unknown section ({$block->section})";
break;
}
}
$debug = get_debug_info();
$contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>";
2009-07-23 01:32:45 +00:00
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
$wrapper = "";
if(strlen($page->heading) > 100) {
$wrapper = ' style="height: 3em; overflow: auto;"';
}
print <<<EOD
2012-03-05 10:14:58 +00:00
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
2009-07-23 01:32:45 +00:00
<head>
<title>{$page->title}</title>
$header_html
</head>
<body>
2012-03-11 16:18:37 +00:00
<header>
<table id="header" class="bgtop" width="100%" height="113px">
<tr>
<td><center>
<h1><a href="$data_href/$main_page">{$site_name}</a></h1>
<p>[Navigation links go here]
</center></td>
$head_block_html
</tr>
</table>
$sub_block_html
</header>
<nav>
$left_block_html
</nav>
<article>
$main_block_html
</article>
<footer>
2009-07-23 01:32:45 +00:00
Images &copy; their respective owners,
2010-01-03 09:41:31 +00:00
<a href="http://code.shishnet.org/shimmie2/">Shimmie</a> &copy;
<a href="http://www.shishnet.org/">Shish</a> &amp;
<a href="https://github.com/shish/shimmie2/contributors">The Team</a>
2007-2012,
2009-07-23 01:32:45 +00:00
based on the Danbooru concept.
$debug
$contact
2012-03-11 16:18:37 +00:00
</footer>
2009-07-23 01:32:45 +00:00
</body>
</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;
2012-03-12 02:45:39 +00:00
$html = "<section id='$i'>";
2012-03-12 02:50:41 +00:00
if(!is_null($h)) $html .= "<h3 data-toggle-sel='#$i' class='shm-toggler'>$h</h3>";
2012-03-12 02:45:39 +00:00
if(!is_null($b)) $html .= "<div class='blockbody'>$b</div>";
$html .= "</section>";
2009-07-23 01:32:45 +00:00
return $html;
}
}
?>