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/lite/layout.class.php

168 lines
5.7 KiB
PHP
Raw Normal View History

2010-02-28 11:01:18 +00:00
<?php
/**
* Name: Lite Theme
* Author: Zach Hall <zach@sosguy.net>
* 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
{
public function display_page(Page $page, array $nav_links, array $sub_links)
{
global $config;
2010-02-28 11:01:18 +00:00
2019-08-02 19:40:03 +00:00
$theme_name = $config->get_string(SetupConfig::THEME, 'lite');
$site_name = $config->get_string(SetupConfig::TITLE);
$data_href = get_base_href();
$contact_link = contact_link();
$header_html = $page->get_all_html_headers();
$menu = "<div class='menu'>
<script type='text/javascript' src='{$data_href}/themes/{$theme_name}/wz_tooltip.js'></script>
<a href='".make_link()."' onmouseover='Tip(&#39;Home&#39;, BGCOLOR, &#39;#C3D2E0&#39;, FADEIN, 100)' onmouseout='UnTip()'><img src='{$data_href}/favicon.ico' style='position: relative; top: 3px;'></a>
2010-02-28 11:01:18 +00:00
<b>{$site_name}</b> ";
// Custom links: These appear on the menu.
$custom_links = "";
foreach ($nav_links as $nav_link) {
$custom_links .= $this->navlinks($nav_link->link, $nav_link->description, $nav_link->active);
}
$menu .= "{$custom_links}</div>";
$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 "<p>error: {$block->header} using an unknown section ({$block->section})";
break;
}
}
$custom_sublinks = "";
2019-09-29 13:30:55 +00:00
if (!empty($sub_links)) {
$custom_sublinks = "<div class='sbar'>";
foreach ($sub_links as $nav_link) {
$custom_sublinks .= $this->navlinks($nav_link->link, $nav_link->description, $nav_link->active);
}
$custom_sublinks .= "</div>";
}
2010-02-28 11:01:18 +00:00
$debug = get_debug_info();
2010-02-28 11:01:18 +00:00
$contact = empty($contact_link) ? "" : "<br><a href='{$contact_link}'>Contact</a>";
//$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
2010-02-28 11:01:18 +00:00
/*$wrapper = "";
if(strlen($page->heading) > 100) {
$wrapper = ' style="height: 3em; overflow: auto;"';
}*/
if ($page->left_enabled == false) {
$left_block_html = "";
$main_block_html = "<article id='body_noleft'>{$main_block_html}</article>";
} else {
$left_block_html = "<nav>{$left_block_html}</nav>";
$main_block_html = "<article>{$main_block_html}</article>";
}
2010-02-28 11:01:18 +00:00
$flash = $page->get_cookie("flash_message");
$flash_html = "";
if (!empty($flash)) {
$flash_html = "<b id='flash'>".nl2br(html_escape($flash))." <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
}
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]-->
2010-02-28 11:01:18 +00:00
<head>
<title>{$page->title}</title>
$header_html
</head>
<body>
2012-03-11 16:18:37 +00:00
<header>
$menu
$custom_sublinks
$sub_block_html
</header>
$left_block_html
$flash_html
$main_block_html
2012-03-11 16:18:37 +00:00
<footer>
2010-02-28 11:01:18 +00:00
Images &copy; their respective owners,
2018-09-26 21:49:37 +00:00
<a href="https://code.shishnet.org/shimmie2/">Shimmie</a> &copy;
<a href="https://www.shishnet.org/">Shish</a> &amp;
2014-02-25 17:40:07 +00:00
<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
2019-06-12 22:36:36 +00:00
2007-2019,
2010-02-28 11:01:18 +00:00
based on the Danbooru concept.<br />
Lite Theme by <a href="http://seemslegit.com">Zach</a>
2010-02-28 11:01:18 +00:00
$debug
$contact
2012-03-11 16:18:37 +00:00
</footer>
2010-02-28 11:01:18 +00:00
</body>
</html>
EOD;
} /* end of function display_page() */
2014-04-25 18:14:22 +00:00
public function block_to_html(Block $block, bool $hidable=false, string $salt=""): string
{
$h = $block->header;
$b = $block->body;
$i = str_replace(' ', '_', $h) . $salt;
$html = "<section id='{$i}'>";
if (!is_null($h)) {
if ($salt == "main") {
$html .= "<div class='maintop navside tab shm-toggler' data-toggle-sel='#{$i}'>{$h}</div>";
} else {
$html .= "<div class='navtop navside tab shm-toggler' data-toggle-sel='#{$i}'>{$h}</div>";
}
}
if (!is_null($b)) {
if ($salt =="main") {
$html .= "<div class='blockbody'>{$b}</div>";
} else {
$html .= "
2014-04-25 18:14:22 +00:00
<div class='navside tab'>{$b}</div>
";
}
}
$html .= "</section>";
return $html;
}
2014-04-25 18:14:22 +00:00
/**
* #param string[] $pages_matched
*/
public function navlinks(Link $link, string $desc, bool $active): ?string
{
$html = null;
if ($active) {
$html = "<a class='tab-selected' href='{$link->make_link()}'>{$desc}</a>";
} else {
$html = "<a class='tab' href='{$link->make_link()}'>{$desc}</a>";
}
2014-04-25 18:14:22 +00:00
return $html;
}
2014-04-24 23:08:23 +00:00
} /* end of class Layout */