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

132 lines
4.2 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
2023-08-18 20:56:42 +00:00
use MicroHTML\HTMLElement;
2020-02-01 18:11:00 +00:00
/**
* 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 Page extends BasePage
{
public function body_html(): string
2020-02-01 18:11:00 +00:00
{
global $config;
list($nav_links, $sub_links) = $this->get_nav_links();
2020-02-01 18:11:00 +00:00
$theme_name = $config->get_string(SetupConfig::THEME, 'lite');
$site_name = $config->get_string(SetupConfig::TITLE);
$data_href = get_base_href();
$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 alt='' src='{$data_href}/favicon.ico' style='position: relative; top: 3px;'></a>
<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 ($this->blocks as $block) {
switch ($block->section) {
case "left":
$left_block_html .= $this->block_to_html($block, true);
2020-02-01 18:11:00 +00:00
break;
case "main":
$main_block_html .= $this->block_to_html($block, false);
2020-02-01 18:11:00 +00:00
break;
case "user":
$user_block_html .= $block->body;
break;
case "subheading":
$sub_block_html .= $this->block_to_html($block, false);
2020-02-01 18:11:00 +00:00
break;
default:
print "<p>error: {$block->header} using an unknown section ({$block->section})";
break;
}
}
$custom_sublinks = "";
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>";
}
2023-03-21 02:37:24 +00:00
$flash_html = $this->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $this->flash)))."</b>" : "";
2023-01-11 11:46:42 +00:00
if (!$this->left_enabled) {
2020-02-01 18:11:00 +00:00
$left_block_html = "";
$main_block_html = "<article id='body_noleft'>{$main_block_html}</article>";
} else {
$left_block_html = "<nav>{$left_block_html}</nav>";
2023-03-21 02:37:24 +00:00
$main_block_html = "<article>$flash_html{$main_block_html}</article>";
2020-02-01 18:11:00 +00:00
}
$footer_html = $this->footer_html();
return <<<EOD
2020-02-01 18:11:00 +00:00
<header>
$menu
$custom_sublinks
$sub_block_html
</header>
$left_block_html
$main_block_html
<footer>
$footer_html
</footer>
EOD;
} /* end of function display_page() */
2023-11-11 21:49:12 +00:00
public function block_to_html(Block $block, bool $hidable = false): string
2020-02-01 18:11:00 +00:00
{
$h = $block->header;
$b = $block->body;
$i = $block->id;
2023-03-21 02:37:24 +00:00
$html = $b;
2023-06-27 10:45:27 +00:00
if ($h != "Paginator") {
2023-03-21 02:37:24 +00:00
$html = "<section id='{$i}'>";
if (!is_null($h)) {
$html .= "<div class='navtop navside tab shm-toggler' data-toggle-sel='#{$i}'>{$h}</div>";
}
if (!is_null($b)) {
$html .= "<div class='navside tab".($hidable ? " blockbody" : "")."'>$b</div>";
}
$html .= "</section>";
2020-02-01 18:11:00 +00:00
}
return $html;
}
2023-08-18 20:56:42 +00:00
public function navlinks(Link $link, HTMLElement|string $desc, bool $active): ?string
2020-02-01 18:11:00 +00:00
{
$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>";
}
return $html;
}
}