merge layout stuff into Page class
This commit is contained in:
parent
de0a7138d2
commit
f0f3cc7aa0
19 changed files with 954 additions and 1126 deletions
|
@ -277,7 +277,7 @@ class BasePage
|
|||
*/
|
||||
public function display(): void
|
||||
{
|
||||
global $page, $user;
|
||||
global $user;
|
||||
|
||||
header("HTTP/1.0 {$this->code} Shimmie");
|
||||
header("Content-type: " . $this->type);
|
||||
|
@ -354,8 +354,7 @@ class BasePage
|
|||
usort($sub_links, "sort_nav_links");
|
||||
|
||||
$this->add_auto_html_headers();
|
||||
$layout = new Layout();
|
||||
$layout->display_page($page, $nav_links, $sub_links);
|
||||
$this->render($nav_links, $sub_links);
|
||||
break;
|
||||
case PageMode::DATA:
|
||||
header("Content-Length: " . strlen($this->data));
|
||||
|
@ -380,7 +379,6 @@ class BasePage
|
|||
header('Accept-Ranges: bytes');
|
||||
|
||||
if (isset($_SERVER['HTTP_RANGE'])) {
|
||||
$c_start = $start;
|
||||
$c_end = $end;
|
||||
list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
|
||||
if (strpos($range, ',') !== false) {
|
||||
|
@ -528,6 +526,100 @@ class BasePage
|
|||
}
|
||||
$this->add_html_header("<script defer src='$data_href/$js_cache_file' type='text/javascript'></script>", 44);
|
||||
}
|
||||
|
||||
/**
|
||||
* turns the Page into HTML
|
||||
*/
|
||||
public function render(array $nav_links, array $sub_links)
|
||||
{
|
||||
$head_html = $this->head_html();
|
||||
$body_html = $this->body_html();
|
||||
|
||||
print <<<EOD
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="en">
|
||||
$head_html
|
||||
$body_html
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
|
||||
protected function head_html(): string {
|
||||
$html_header_html = $this->get_all_html_headers();
|
||||
|
||||
return "
|
||||
<head>
|
||||
<title>{$this->title}</title>
|
||||
$html_header_html
|
||||
</head>
|
||||
";
|
||||
}
|
||||
|
||||
protected function body_html(): string {
|
||||
$left_block_html = "";
|
||||
$main_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($this->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "main":
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->get_html(false);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$wrapper = "";
|
||||
if (strlen($this->heading) > 100) {
|
||||
$wrapper = ' style="height: 3em; overflow: auto;"';
|
||||
}
|
||||
|
||||
$footer_html = $this->footer_html();
|
||||
$flash_html = $this->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $this->flash)))."</b>" : "";
|
||||
return "
|
||||
<body>
|
||||
<header>
|
||||
<h1$wrapper>{$this->heading}</h1>
|
||||
$sub_block_html
|
||||
</header>
|
||||
<nav>
|
||||
$left_block_html
|
||||
</nav>
|
||||
<article>
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer>
|
||||
$footer_html
|
||||
</footer>
|
||||
</body>
|
||||
";
|
||||
}
|
||||
|
||||
protected function footer_html(): string {
|
||||
$debug = get_debug_info();
|
||||
$contact_link = contact_link();
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
|
||||
return "
|
||||
Images © their respective owners,
|
||||
<a href=\"https://code.shishnet.org/shimmie2/\">Shimmie</a> ©
|
||||
<a href=\"https://www.shishnet.org/\">Shish</a> &
|
||||
<a href=\"https://github.com/shish/shimmie2/graphs/contributors\">The Team</a>
|
||||
2007-2020,
|
||||
based on the Danbooru concept.
|
||||
$debug
|
||||
$contact
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
class PageNavBuildingEvent extends Event
|
||||
|
@ -619,6 +711,7 @@ class NavLink
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function sort_nav_links(NavLink $a, NavLink $b)
|
||||
|
|
|
@ -346,6 +346,7 @@ class MockDatabase extends Database
|
|||
|
||||
public function __construct(array $responses = [])
|
||||
{
|
||||
parent::__construct("fake:dsn");
|
||||
$this->responses = $responses;
|
||||
}
|
||||
|
||||
|
|
|
@ -547,7 +547,6 @@ function _get_themelet_files(string $_theme): array
|
|||
{
|
||||
$base_themelets = [];
|
||||
$base_themelets[] = 'themes/'.$_theme.'/page.class.php';
|
||||
$base_themelets[] = 'themes/'.$_theme.'/layout.class.php';
|
||||
$base_themelets[] = 'themes/'.$_theme.'/themelet.class.php';
|
||||
|
||||
$ext_themelets = zglob("ext/{".Extension::get_enabled_extensions_as_string()."}/theme.php");
|
||||
|
@ -591,7 +590,8 @@ function _fatal_error(Exception $e): void
|
|||
$q = (!isset($e->query) || is_null($e->query)) ? "" : "<p><b>Query:</b> " . html_escape($e->query);
|
||||
header("HTTP/1.0 500 Internal Error");
|
||||
echo '
|
||||
<html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Internal error - SCore-'.$version.'</title>
|
||||
</head>
|
||||
|
|
|
@ -45,6 +45,7 @@ class DeleteAliasEvent extends Event
|
|||
|
||||
public function __construct(string $oldtag)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->oldtag = $oldtag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -459,37 +459,37 @@ class Artists extends Extension
|
|||
private function get_artistID_by_url(string $url): int
|
||||
{
|
||||
global $database;
|
||||
return $database->get_one("SELECT artist_id FROM artist_urls WHERE url = :url", ['url'=>$url]);
|
||||
return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE url = :url", ['url'=>$url]);
|
||||
}
|
||||
|
||||
private function get_artistID_by_memberName(string $member): int
|
||||
{
|
||||
global $database;
|
||||
return $database->get_one("SELECT artist_id FROM artist_members WHERE name = :name", ['name'=>$member]);
|
||||
return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE name = :name", ['name'=>$member]);
|
||||
}
|
||||
|
||||
private function get_artistName_by_artistID(int $artistID): string
|
||||
{
|
||||
global $database;
|
||||
return $database->get_one("SELECT name FROM artists WHERE id = :id", ['id'=>$artistID]);
|
||||
return (string)$database->get_one("SELECT name FROM artists WHERE id = :id", ['id'=>$artistID]);
|
||||
}
|
||||
|
||||
private function get_artistID_by_aliasID(int $aliasID): int
|
||||
{
|
||||
global $database;
|
||||
return $database->get_one("SELECT artist_id FROM artist_alias WHERE id = :id", ['id'=>$aliasID]);
|
||||
return (int)$database->get_one("SELECT artist_id FROM artist_alias WHERE id = :id", ['id'=>$aliasID]);
|
||||
}
|
||||
|
||||
private function get_artistID_by_memberID(int $memberID): int
|
||||
{
|
||||
global $database;
|
||||
return $database->get_one("SELECT artist_id FROM artist_members WHERE id = :id", ['id'=>$memberID]);
|
||||
return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE id = :id", ['id'=>$memberID]);
|
||||
}
|
||||
|
||||
private function get_artistID_by_urlID(int $urlID): int
|
||||
{
|
||||
global $database;
|
||||
return $database->get_one("SELECT artist_id FROM artist_urls WHERE id = :id", ['id'=>$urlID]);
|
||||
return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE id = :id", ['id'=>$urlID]);
|
||||
}
|
||||
|
||||
private function delete_alias(int $aliasID)
|
||||
|
|
|
@ -692,7 +692,7 @@ class Pools extends Extension
|
|||
$images .= " " . $imageID;
|
||||
}
|
||||
|
||||
$count = $database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", ["pid" => $poolID]);
|
||||
$count = (int)$database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", ["pid" => $poolID]);
|
||||
$this->add_history($poolID, 0, $images, $count);
|
||||
return $poolID;
|
||||
}
|
||||
|
@ -982,7 +982,7 @@ class Pools extends Extension
|
|||
continue; // go on to the next one.
|
||||
}
|
||||
|
||||
$count = $database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", ["pid" => $poolID]);
|
||||
$count = (int)$database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", ["pid" => $poolID]);
|
||||
$this->add_history($poolID, $newAction, $imageArray, $count);
|
||||
}
|
||||
}
|
||||
|
@ -1020,7 +1020,7 @@ class Pools extends Extension
|
|||
$this->update_count($poolID);
|
||||
|
||||
if ($history) {
|
||||
$count = $database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", ["pid" => $poolID]);
|
||||
$count = (int)$database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", ["pid" => $poolID]);
|
||||
$this->add_history($poolID, 1, (string)$imageID, $count);
|
||||
}
|
||||
return true;
|
||||
|
@ -1046,7 +1046,7 @@ class Pools extends Extension
|
|||
$this->update_count($poolID);
|
||||
|
||||
if ($history) {
|
||||
$count = $database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", ["pid" => $poolID]);
|
||||
$count = (int)$database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", ["pid" => $poolID]);
|
||||
$this->add_history($poolID, 0, (string)$imageID, $count);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,189 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Name: Danbooru Theme
|
||||
* Author: Bzchan <bzchan@animemahou.com>
|
||||
* Link: https://code.shishnet.org/shimmie2/
|
||||
* License: GPLv2
|
||||
* Description: This is a simple theme changing the css to make shimme
|
||||
* look more like danbooru as well as adding a custom links
|
||||
* bar and title to the top of every page.
|
||||
*/
|
||||
//Small changes added by zshall <http://seemslegit.com>
|
||||
//Changed CSS and layout to make shimmie look even more like danbooru
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
Danbooru Theme - Notes (Bzchan)
|
||||
|
||||
Files: default.php, style.css
|
||||
|
||||
How to use a theme
|
||||
- Copy the danbooru folder with all its contained files into the "themes"
|
||||
directory in your shimmie installation.
|
||||
- Log into your shimmie and change the Theme in the Board Config to your
|
||||
desired theme.
|
||||
|
||||
Changes in this theme include
|
||||
- Adding and editing various elements in the style.css file.
|
||||
- $site_name and $front_name retreival from config added.
|
||||
- $custom_link and $title_link preparation just before html is outputed.
|
||||
- Altered outputed html to include the custom links and removed heading
|
||||
from being displayed (subheading is still displayed)
|
||||
- Note that only the sidebar has been left aligned. Could not properly
|
||||
left align the main block because blocks without headers currently do
|
||||
not have ids on there div elements. (this was a problem because
|
||||
paginator block must be centered and everything else left aligned)
|
||||
|
||||
Tips
|
||||
- You can change custom links to point to whatever pages you want as well as adding
|
||||
more custom links.
|
||||
- The main title link points to the Front Page set in your Board Config options.
|
||||
- The text of the main title is the Title set in your Board Config options.
|
||||
- Themes make no changes to your database or main code files so you can switch
|
||||
back and forward to other themes all you like.
|
||||
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
class Layout
|
||||
{
|
||||
public function display_page(Page $page, array $nav_links, array $sub_links)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$theme_name = $config->get_string(SetupConfig::THEME);
|
||||
//$base_href = $config->get_string('base_href');
|
||||
$data_href = get_base_href();
|
||||
$contact_link = contact_link();
|
||||
$header_html = $page->get_all_html_headers();
|
||||
|
||||
$left_block_html = "";
|
||||
$user_block_html = "";
|
||||
$main_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($page->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "user":
|
||||
$user_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "main":
|
||||
if ($block->header == "Images") {
|
||||
$block->header = " ";
|
||||
}
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
|
||||
if (empty($this->subheading)) {
|
||||
$subheading = "";
|
||||
} else {
|
||||
$subheading = "<div id='subtitle'>{$this->subheading}</div>";
|
||||
}
|
||||
|
||||
$site_name = $config->get_string(SetupConfig::TITLE); // bzchan: change from normal default to get title for top of page
|
||||
$main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page
|
||||
|
||||
$custom_links = "";
|
||||
foreach ($nav_links as $nav_link) {
|
||||
$custom_links .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>";
|
||||
}
|
||||
|
||||
$custom_sublinks = "";
|
||||
if (!empty($sub_links)) {
|
||||
$custom_sublinks = "<div class='sbar'>";
|
||||
foreach ($sub_links as $nav_link) {
|
||||
$custom_sublinks .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>";
|
||||
}
|
||||
$custom_sublinks .= "</div>";
|
||||
}
|
||||
|
||||
|
||||
// bzchan: failed attempt to add heading after title_link (failure was it looked bad)
|
||||
//if($this->heading==$site_name)$this->heading = '';
|
||||
//$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
|
||||
|
||||
// bzchan: prepare main title link
|
||||
$title_link = "<h1 id='site-title'><a href='".make_link($main_page)."'>$site_name</a></h1>";
|
||||
|
||||
if ($page->left_enabled) {
|
||||
$left = "<nav>$left_block_html</nav>";
|
||||
$withleft = "withleft";
|
||||
} else {
|
||||
$left = "";
|
||||
$withleft = "noleft";
|
||||
}
|
||||
|
||||
$flash_html = $page->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $page->flash)))."</b>" : "";
|
||||
|
||||
print <<<EOD
|
||||
<!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]-->
|
||||
<head>
|
||||
<title>{$page->title}</title>
|
||||
$header_html
|
||||
<script src='$data_href/themes/$theme_name/script.js' type='text/javascript'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
$title_link
|
||||
<ul id="navbar" class="flat-list">
|
||||
$custom_links
|
||||
</ul>
|
||||
<ul id="subnavbar" class="flat-list">
|
||||
$custom_sublinks
|
||||
</ul>
|
||||
</header>
|
||||
$subheading
|
||||
$sub_block_html
|
||||
$left
|
||||
<article class="$withleft">
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer><em>
|
||||
Images © their respective owners,
|
||||
<a href="https://code.shishnet.org/shimmie2/">Shimmie</a> ©
|
||||
<a href="https://www.shishnet.org/">Shish</a> &
|
||||
<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
|
||||
2007-2019,
|
||||
based on the Danbooru concept.
|
||||
$debug
|
||||
$contact
|
||||
</em></footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
|
||||
/**
|
||||
* #param string[] $pages_matched
|
||||
*/
|
||||
|
||||
public function navlinks(Link $link, string $desc, bool $active): ?string
|
||||
{
|
||||
$html = null;
|
||||
if ($active) {
|
||||
$html = "<a class='current-page' href='{$link->make_link()}'>{$desc}</a>";
|
||||
} else {
|
||||
$html = "<a class='tab' href='{$link->make_link()}'>{$desc}</a>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,46 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Name: Danbooru Theme
|
||||
* Author: Bzchan <bzchan@animemahou.com>
|
||||
* Link: https://code.shishnet.org/shimmie2/
|
||||
* License: GPLv2
|
||||
* Description: This is a simple theme changing the css to make shimme
|
||||
* look more like danbooru as well as adding a custom links
|
||||
* bar and title to the top of every page.
|
||||
*/
|
||||
//Small changes added by zshall <http://seemslegit.com>
|
||||
//Changed CSS and layout to make shimmie look even more like danbooru
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
Danbooru Theme - Notes (Bzchan)
|
||||
|
||||
Files: default.php, style.css
|
||||
|
||||
How to use a theme
|
||||
- Copy the danbooru folder with all its contained files into the "themes"
|
||||
directory in your shimmie installation.
|
||||
- Log into your shimmie and change the Theme in the Board Config to your
|
||||
desired theme.
|
||||
|
||||
Changes in this theme include
|
||||
- Adding and editing various elements in the style.css file.
|
||||
- $site_name and $front_name retreival from config added.
|
||||
- $custom_link and $title_link preparation just before html is outputed.
|
||||
- Altered outputed html to include the custom links and removed heading
|
||||
from being displayed (subheading is still displayed)
|
||||
- Note that only the sidebar has been left aligned. Could not properly
|
||||
left align the main block because blocks without headers currently do
|
||||
not have ids on there div elements. (this was a problem because
|
||||
paginator block must be centered and everything else left aligned)
|
||||
|
||||
Tips
|
||||
- You can change custom links to point to whatever pages you want as well as adding
|
||||
more custom links.
|
||||
- The main title link points to the Front Page set in your Board Config options.
|
||||
- The text of the main title is the Title set in your Board Config options.
|
||||
- Themes make no changes to your database or main code files so you can switch
|
||||
back and forward to other themes all you like.
|
||||
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
class Page extends BasePage
|
||||
{
|
||||
/** @var bool */
|
||||
|
@ -9,4 +50,117 @@ class Page extends BasePage
|
|||
{
|
||||
$this->left_enabled = false;
|
||||
}
|
||||
|
||||
public function render(array $nav_links, array $sub_links)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$left_block_html = "";
|
||||
$user_block_html = "";
|
||||
$main_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($this->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "user":
|
||||
$user_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "main":
|
||||
if ($block->header == "Images") {
|
||||
$block->header = " ";
|
||||
}
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->subheading)) {
|
||||
$subheading = "";
|
||||
} else {
|
||||
$subheading = "<div id='subtitle'>{$this->subheading}</div>";
|
||||
}
|
||||
|
||||
$site_name = $config->get_string(SetupConfig::TITLE); // bzchan: change from normal default to get title for top of page
|
||||
$main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page
|
||||
|
||||
$custom_links = "";
|
||||
foreach ($nav_links as $nav_link) {
|
||||
$custom_links .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>";
|
||||
}
|
||||
|
||||
$custom_sublinks = "";
|
||||
if (!empty($sub_links)) {
|
||||
$custom_sublinks = "<div class='sbar'>";
|
||||
foreach ($sub_links as $nav_link) {
|
||||
$custom_sublinks .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>";
|
||||
}
|
||||
$custom_sublinks .= "</div>";
|
||||
}
|
||||
|
||||
// bzchan: failed attempt to add heading after title_link (failure was it looked bad)
|
||||
//if($this->heading==$site_name)$this->heading = '';
|
||||
//$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
|
||||
|
||||
// bzchan: prepare main title link
|
||||
$title_link = "<h1 id='site-title'><a href='".make_link($main_page)."'>$site_name</a></h1>";
|
||||
|
||||
if ($this->left_enabled) {
|
||||
$left = "<nav>$left_block_html</nav>";
|
||||
$withleft = "withleft";
|
||||
} else {
|
||||
$left = "";
|
||||
$withleft = "noleft";
|
||||
}
|
||||
|
||||
$flash_html = $this->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $this->flash)))."</b>" : "";
|
||||
$head_html = $this->head_html();
|
||||
$footer_html = $this->footer_html();
|
||||
|
||||
print <<<EOD
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="en">
|
||||
$head_html
|
||||
<body>
|
||||
<header>
|
||||
$title_link
|
||||
<ul id="navbar" class="flat-list">
|
||||
$custom_links
|
||||
</ul>
|
||||
<ul id="subnavbar" class="flat-list">
|
||||
$custom_sublinks
|
||||
</ul>
|
||||
</header>
|
||||
$subheading
|
||||
$sub_block_html
|
||||
$left
|
||||
<article class="$withleft">
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer><em>$footer_html</em></footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
|
||||
public function navlinks(Link $link, string $desc, bool $active): ?string
|
||||
{
|
||||
$html = null;
|
||||
if ($active) {
|
||||
$html = "<a class='current-page' href='{$link->make_link()}'>{$desc}</a>";
|
||||
} else {
|
||||
$html = "<a class='tab' href='{$link->make_link()}'>{$desc}</a>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,185 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Name: Danbooru 2 Theme
|
||||
* Author: Bzchan <bzchan@animemahou.com>, updated by Daniel Oaks <daniel@danieloaks.net>
|
||||
* Link: https://code.shishnet.org/shimmie2/
|
||||
* License: GPLv2
|
||||
* Description: This is a simple theme changing the css to make shimme
|
||||
* look more like danbooru as well as adding a custom links
|
||||
* bar and title to the top of every page.
|
||||
*/
|
||||
//Small changes added by zshall <http://seemslegit.com>
|
||||
//Changed CSS and layout to make shimmie look even more like danbooru
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
Danbooru 2 Theme - Notes (Bzchan)
|
||||
|
||||
Files: default.php, style.css
|
||||
|
||||
How to use a theme
|
||||
- Copy the danbooru2 folder with all its contained files into the "themes"
|
||||
directory in your shimmie installation.
|
||||
- Log into your shimmie and change the Theme in the Board Config to your
|
||||
desired theme.
|
||||
|
||||
Changes in this theme include
|
||||
- Adding and editing various elements in the style.css file.
|
||||
- $site_name and $front_name retreival from config added.
|
||||
- $custom_link and $title_link preparation just before html is outputed.
|
||||
- Altered outputed html to include the custom links and removed heading
|
||||
from being displayed (subheading is still displayed)
|
||||
- Note that only the sidebar has been left aligned. Could not properly
|
||||
left align the main block because blocks without headers currently do
|
||||
not have ids on there div elements. (this was a problem because
|
||||
paginator block must be centered and everything else left aligned)
|
||||
|
||||
Tips
|
||||
- You can change custom links to point to whatever pages you want as well as adding
|
||||
more custom links.
|
||||
- The main title link points to the Front Page set in your Board Config options.
|
||||
- The text of the main title is the Title set in your Board Config options.
|
||||
- Themes make no changes to your database or main code files so you can switch
|
||||
back and forward to other themes all you like.
|
||||
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
class Layout
|
||||
{
|
||||
public function display_page($page, array $nav_links, array $sub_links)
|
||||
{
|
||||
global $config;
|
||||
|
||||
//$theme_name = $config->get_string(SetupConfig::THEME);
|
||||
//$base_href = $config->get_string('base_href');
|
||||
//$data_href = get_base_href();
|
||||
$contact_link = contact_link();
|
||||
$header_html = $page->get_all_html_headers();
|
||||
|
||||
$left_block_html = "";
|
||||
$user_block_html = "";
|
||||
$main_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($page->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "user":
|
||||
$user_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "main":
|
||||
if ($block->header == "Images") {
|
||||
$block->header = " ";
|
||||
}
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
|
||||
if (empty($this->subheading)) {
|
||||
$subheading = "";
|
||||
} else {
|
||||
$subheading = "<div id='subtitle'>{$this->subheading}</div>";
|
||||
}
|
||||
|
||||
$site_name = $config->get_string(SetupConfig::TITLE); // bzchan: change from normal default to get title for top of page
|
||||
$main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page
|
||||
|
||||
$custom_links = "";
|
||||
foreach ($nav_links as $nav_link) {
|
||||
$custom_links .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>";
|
||||
}
|
||||
|
||||
$custom_sublinks = "";
|
||||
if (!empty($sub_links)) {
|
||||
$custom_sublinks = "<div class='sbar'>";
|
||||
foreach ($sub_links as $nav_link) {
|
||||
$custom_sublinks .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>";
|
||||
}
|
||||
$custom_sublinks .= "</div>";
|
||||
}
|
||||
|
||||
|
||||
// bzchan: failed attempt to add heading after title_link (failure was it looked bad)
|
||||
//if($this->heading==$site_name)$this->heading = '';
|
||||
//$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
|
||||
|
||||
// bzchan: prepare main title link
|
||||
$title_link = "<h1 id='site-title'><a href='".make_link($main_page)."'>$site_name</a></h1>";
|
||||
|
||||
if ($page->left_enabled) {
|
||||
$left = "<nav>$left_block_html</nav>";
|
||||
$withleft = "withleft";
|
||||
} else {
|
||||
$left = "";
|
||||
$withleft = "noleft";
|
||||
}
|
||||
|
||||
$flash_html = $page->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $page->flash)))."</b>" : "";
|
||||
|
||||
print <<<EOD
|
||||
<!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]-->
|
||||
<head>
|
||||
<title>{$page->title}</title>
|
||||
$header_html
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
$title_link
|
||||
<ul id="navbar" class="flat-list">
|
||||
$custom_links
|
||||
</ul>
|
||||
<ul id="subnavbar" class="flat-list">
|
||||
$custom_sublinks
|
||||
</ul>
|
||||
</header>
|
||||
$subheading
|
||||
$sub_block_html
|
||||
$left
|
||||
<article class="$withleft">
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer><div>
|
||||
Running Shimmie –
|
||||
Images © their respective owners,
|
||||
<a href="https://code.shishnet.org/shimmie2/">Shimmie</a> ©
|
||||
<a href="https://www.shishnet.org/">Shish</a> &
|
||||
<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
|
||||
2007-2019,
|
||||
based on the Danbooru concept<br />
|
||||
$debug
|
||||
$contact
|
||||
</div></footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
|
||||
public function navlinks(Link $link, string $desc, bool $active): ?string
|
||||
{
|
||||
$html = null;
|
||||
if ($active) {
|
||||
$html = "<a class='current-page' href='{$link->make_link()}'>{$desc}</a>";
|
||||
} else {
|
||||
$html = "<a class='tab' href='{$link->make_link()}'>{$desc}</a>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,46 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Name: Danbooru 2 Theme
|
||||
* Author: Bzchan <bzchan@animemahou.com>, updated by Daniel Oaks <daniel@danieloaks.net>
|
||||
* Link: https://code.shishnet.org/shimmie2/
|
||||
* License: GPLv2
|
||||
* Description: This is a simple theme changing the css to make shimme
|
||||
* look more like danbooru as well as adding a custom links
|
||||
* bar and title to the top of every page.
|
||||
*/
|
||||
//Small changes added by zshall <http://seemslegit.com>
|
||||
//Changed CSS and layout to make shimmie look even more like danbooru
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
Danbooru 2 Theme - Notes (Bzchan)
|
||||
|
||||
Files: default.php, style.css
|
||||
|
||||
How to use a theme
|
||||
- Copy the danbooru2 folder with all its contained files into the "themes"
|
||||
directory in your shimmie installation.
|
||||
- Log into your shimmie and change the Theme in the Board Config to your
|
||||
desired theme.
|
||||
|
||||
Changes in this theme include
|
||||
- Adding and editing various elements in the style.css file.
|
||||
- $site_name and $front_name retreival from config added.
|
||||
- $custom_link and $title_link preparation just before html is outputed.
|
||||
- Altered outputed html to include the custom links and removed heading
|
||||
from being displayed (subheading is still displayed)
|
||||
- Note that only the sidebar has been left aligned. Could not properly
|
||||
left align the main block because blocks without headers currently do
|
||||
not have ids on there div elements. (this was a problem because
|
||||
paginator block must be centered and everything else left aligned)
|
||||
|
||||
Tips
|
||||
- You can change custom links to point to whatever pages you want as well as adding
|
||||
more custom links.
|
||||
- The main title link points to the Front Page set in your Board Config options.
|
||||
- The text of the main title is the Title set in your Board Config options.
|
||||
- Themes make no changes to your database or main code files so you can switch
|
||||
back and forward to other themes all you like.
|
||||
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
class Page extends BasePage
|
||||
{
|
||||
|
@ -7,4 +49,117 @@ class Page extends BasePage
|
|||
{
|
||||
$this->left_enabled = false;
|
||||
}
|
||||
|
||||
public function render(array $nav_links, array $sub_links)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$left_block_html = "";
|
||||
$user_block_html = "";
|
||||
$main_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($this->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "user":
|
||||
$user_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "main":
|
||||
if ($block->header == "Images") {
|
||||
$block->header = " ";
|
||||
}
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->subheading)) {
|
||||
$subheading = "";
|
||||
} else {
|
||||
$subheading = "<div id='subtitle'>{$this->subheading}</div>";
|
||||
}
|
||||
|
||||
$site_name = $config->get_string(SetupConfig::TITLE); // bzchan: change from normal default to get title for top of page
|
||||
$main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page
|
||||
|
||||
$custom_links = "";
|
||||
foreach ($nav_links as $nav_link) {
|
||||
$custom_links .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>";
|
||||
}
|
||||
|
||||
$custom_sublinks = "";
|
||||
if (!empty($sub_links)) {
|
||||
$custom_sublinks = "<div class='sbar'>";
|
||||
foreach ($sub_links as $nav_link) {
|
||||
$custom_sublinks .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>";
|
||||
}
|
||||
$custom_sublinks .= "</div>";
|
||||
}
|
||||
|
||||
// bzchan: failed attempt to add heading after title_link (failure was it looked bad)
|
||||
//if($this->heading==$site_name)$this->heading = '';
|
||||
//$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
|
||||
|
||||
// bzchan: prepare main title link
|
||||
$title_link = "<h1 id='site-title'><a href='".make_link($main_page)."'>$site_name</a></h1>";
|
||||
|
||||
if ($this->left_enabled) {
|
||||
$left = "<nav>$left_block_html</nav>";
|
||||
$withleft = "withleft";
|
||||
} else {
|
||||
$left = "";
|
||||
$withleft = "noleft";
|
||||
}
|
||||
|
||||
$flash_html = $this->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $this->flash)))."</b>" : "";
|
||||
$head_html = $this->head_html();
|
||||
$footer_html = $this->footer_html();
|
||||
|
||||
print <<<EOD
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="en">
|
||||
$head_html
|
||||
<body>
|
||||
<header>
|
||||
$title_link
|
||||
<ul id="navbar" class="flat-list">
|
||||
$custom_links
|
||||
</ul>
|
||||
<ul id="subnavbar" class="flat-list">
|
||||
$custom_sublinks
|
||||
</ul>
|
||||
</header>
|
||||
$subheading
|
||||
$sub_block_html
|
||||
$left
|
||||
<article class="$withleft">
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer><div>$footer_html</div></footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
|
||||
public function navlinks(Link $link, string $desc, bool $active): ?string
|
||||
{
|
||||
$html = null;
|
||||
if ($active) {
|
||||
$html = "<a class='current-page' href='{$link->make_link()}'>{$desc}</a>";
|
||||
} else {
|
||||
$html = "<a class='tab' href='{$link->make_link()}'>{$desc}</a>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* 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, array $nav_links)
|
||||
{
|
||||
//global $config;
|
||||
//$theme_name = $config->get_string(SetupConfig::THEME, 'default');
|
||||
//$data_href = get_base_href();
|
||||
$contact_link = contact_link();
|
||||
$header_html = $page->get_all_html_headers();
|
||||
|
||||
$left_block_html = "";
|
||||
$main_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($page->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "main":
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->get_html(false);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
|
||||
$wrapper = "";
|
||||
if (strlen($page->heading) > 100) {
|
||||
$wrapper = ' style="height: 3em; overflow: auto;"';
|
||||
}
|
||||
|
||||
$flash_html = $page->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $page->flash)))."</b>" : "";
|
||||
|
||||
print <<<EOD
|
||||
<!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]-->
|
||||
<head>
|
||||
<title>{$page->title}</title>
|
||||
$header_html
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<h1$wrapper>{$page->heading}</h1>
|
||||
$sub_block_html
|
||||
</header>
|
||||
<nav>
|
||||
$left_block_html
|
||||
</nav>
|
||||
<article>
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer>
|
||||
Images © their respective owners,
|
||||
<a href="https://code.shishnet.org/shimmie2/">Shimmie</a> ©
|
||||
<a href="https://www.shishnet.org/">Shish</a> &
|
||||
<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
|
||||
2007-2019,
|
||||
based on the Danbooru concept.
|
||||
$debug
|
||||
$contact
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
class Layout
|
||||
{
|
||||
public function display_page(Page $page)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$theme_name = $config->get_string(SetupConfig::THEME, 'default');
|
||||
$data_href = get_base_href();
|
||||
$contact_link = contact_link();
|
||||
$header_html = $page->get_all_html_headers();
|
||||
|
||||
$left_block_html = "";
|
||||
$main_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($page->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "main":
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
|
||||
if (empty($page->subheading)) {
|
||||
$subheading = "";
|
||||
} else {
|
||||
$subheading = "<div id='subtitle'>{$page->subheading}</div>";
|
||||
}
|
||||
|
||||
if ($page->left_enabled) {
|
||||
$left = "<nav>$left_block_html</nav>";
|
||||
$withleft = "withleft";
|
||||
} else {
|
||||
$left = "";
|
||||
$withleft = "";
|
||||
}
|
||||
|
||||
$flash_html = $page->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $page->flash)))."</b>" : "";
|
||||
|
||||
print <<<EOD
|
||||
<!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]-->
|
||||
<head>
|
||||
<title>{$page->title}</title>
|
||||
$header_html
|
||||
<script src='$data_href/themes/$theme_name/script.js' type='text/javascript'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<h1>{$page->heading}</h1>
|
||||
$subheading
|
||||
$sub_block_html
|
||||
</header>
|
||||
$left
|
||||
<article class="$withleft">
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer>
|
||||
<hr>
|
||||
Images © their respective owners,
|
||||
<a href="https://code.shishnet.org/shimmie2/">Shimmie</a> ©
|
||||
<a href="https://www.shishnet.org/">Shish</a> &
|
||||
<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
|
||||
2007-2019,
|
||||
based on the Danbooru concept.
|
||||
<br>Futaba theme based on 4chan's layout and CSS :3
|
||||
$debug
|
||||
$contact
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
}
|
|
@ -7,4 +7,69 @@ class Page extends BasePage
|
|||
{
|
||||
$this->left_enabled = false;
|
||||
}
|
||||
|
||||
public function render($nav_links, $subnav_links)
|
||||
{
|
||||
$left_block_html = "";
|
||||
$main_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($this->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "main":
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->subheading)) {
|
||||
$subheading = "";
|
||||
} else {
|
||||
$subheading = "<div id='subtitle'>{$this->subheading}</div>";
|
||||
}
|
||||
|
||||
if ($this->left_enabled) {
|
||||
$left = "<nav>$left_block_html</nav>";
|
||||
$withleft = "withleft";
|
||||
} else {
|
||||
$left = "";
|
||||
$withleft = "";
|
||||
}
|
||||
|
||||
$flash_html = $this->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $this->flash)))."</b>" : "";
|
||||
$head_html = $this->head_html();
|
||||
$footer_html = $this->footer_html();
|
||||
|
||||
print <<<EOD
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="en">
|
||||
$head_html
|
||||
<body>
|
||||
<header>
|
||||
<h1>{$this->heading}</h1>
|
||||
$subheading
|
||||
$sub_block_html
|
||||
</header>
|
||||
$left
|
||||
<article class="$withleft">
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer>
|
||||
<hr>
|
||||
$footer_html
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* 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;
|
||||
|
||||
$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('Home', BGCOLOR, '#C3D2E0', FADEIN, 100)' onmouseout='UnTip()'><img 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 ($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 = "";
|
||||
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>";
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='{$contact_link}'>Contact</a>";
|
||||
//$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
||||
|
||||
/*$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>";
|
||||
}
|
||||
|
||||
$flash_html = $page->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $page->flash)))."</b>" : "";
|
||||
|
||||
print <<<EOD
|
||||
<!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]-->
|
||||
<head>
|
||||
<title>{$page->title}</title>
|
||||
$header_html
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
$menu
|
||||
$custom_sublinks
|
||||
$sub_block_html
|
||||
</header>
|
||||
$left_block_html
|
||||
$flash_html
|
||||
$main_block_html
|
||||
<footer>
|
||||
Images © their respective owners,
|
||||
<a href="https://code.shishnet.org/shimmie2/">Shimmie</a> ©
|
||||
<a href="https://www.shishnet.org/">Shish</a> &
|
||||
<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
|
||||
2007-2019,
|
||||
based on the Danbooru concept.<br />
|
||||
Lite Theme by <a href="http://seemslegit.com">Zach</a>
|
||||
$debug
|
||||
$contact
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
} /* end of function display_page() */
|
||||
|
||||
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 .= "
|
||||
<div class='navside tab'>{$b}</div>
|
||||
";
|
||||
}
|
||||
}
|
||||
$html .= "</section>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* #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>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
} /* end of class Layout */
|
|
@ -1,4 +1,12 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
|
@ -9,4 +17,129 @@ class Page extends BasePage
|
|||
{
|
||||
$this->left_enabled = false;
|
||||
}
|
||||
|
||||
public function render(array $nav_links, array $sub_links)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$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('Home', BGCOLOR, '#C3D2E0', 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, "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 = "";
|
||||
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>";
|
||||
}
|
||||
|
||||
if ($this->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>";
|
||||
}
|
||||
|
||||
$flash_html = $this->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $this->flash)))."</b>" : "";
|
||||
$head_html = $this->head_html();
|
||||
$footer_html = $this->footer_html();
|
||||
|
||||
print <<<EOD
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="en">
|
||||
$head_html
|
||||
<body>
|
||||
<header>
|
||||
$menu
|
||||
$custom_sublinks
|
||||
$sub_block_html
|
||||
</header>
|
||||
$left_block_html
|
||||
$flash_html
|
||||
$main_block_html
|
||||
<footer>
|
||||
$footer_html
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
} /* end of function display_page() */
|
||||
|
||||
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 .= "
|
||||
<div class='navside tab'>{$b}</div>
|
||||
";
|
||||
}
|
||||
}
|
||||
$html .= "</section>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
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>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,288 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* 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(SetupConfig::THEME, 'material');
|
||||
$site_name = $config->get_string(SetupConfig::TITLE);
|
||||
$data_href = get_base_href();
|
||||
// $main_page = $config->get_string(SetupConfig::MAIN_PAGE);
|
||||
$contact_link = contact_link();
|
||||
$site_link = make_link();
|
||||
$header_html = $page->get_all_html_headers();
|
||||
|
||||
$left_block_html = "";
|
||||
$main_block_html = "";
|
||||
$head_block_html = "";
|
||||
$sub_block_html = "";
|
||||
$drawer_block_html = ""; //use exampled in user.theme.php & view.theme.php
|
||||
$toolbar_block_html = ""; // not used at this point
|
||||
$subtoolbar_block_html = ""; // use exampled in user.theme.php
|
||||
// $navigation = "";
|
||||
|
||||
$h_search = "
|
||||
<div class='mdl-textfield mdl-js-textfield mdl-textfield--expandable
|
||||
mdl-textfield--floating-label mdl-textfield--align-right'>
|
||||
<form action='".make_link()."' method='GET'>
|
||||
<label class='mdl-button mdl-js-button mdl-button--icon'
|
||||
for='waterfall-exp'>
|
||||
<i class='material-icons'>search</i>
|
||||
</label>
|
||||
<div class='mdl-textfield__expandable-holder'>
|
||||
<input id='waterfall-exp' class='autocomplete_tags mdl-textfield__input' name='search' type='text' placeholder='Search' value='' />
|
||||
<input type='hidden' name='q' value='/post/list'>
|
||||
<input type='submit' value='Find' style='display: none;' />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
";
|
||||
|
||||
foreach ($page->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "toolbar":
|
||||
$toolbar_block_html .= $this->get_html($block, "toolbar");
|
||||
break;
|
||||
case "subtoolbar":
|
||||
$subtoolbar_block_html .= $this->get_html($block, "subtoolbar");
|
||||
break;
|
||||
case "left":
|
||||
if ($block->header == "Navigation") {
|
||||
$subtoolbar_block_html = $this->rework_navigation($block);
|
||||
break;
|
||||
}
|
||||
// $left_block_html .= $block->get_html(true);
|
||||
$left_block_html .= $this->get_html($block, "full", true, "left-blocks nav-card mdl-cell--4-col-tablet");
|
||||
break;
|
||||
case "head":
|
||||
$head_block_html .= $this->get_html($block, "third", true, "nav-card head-blocks");
|
||||
break;
|
||||
case "drawer":
|
||||
$drawer_block_html .= $this->get_html($block, "full", true, "nav-card drawer-blocks");
|
||||
break;
|
||||
case "main":
|
||||
// $main_block_html .= $block->get_html(false);
|
||||
$main_block_html .= $this->get_html($block, "main", true, "");
|
||||
break;
|
||||
case "subheading":
|
||||
// $sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
$sub_block_html .= $this->get_html($block, "third", true, "nav-card");
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
/*$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
||||
|
||||
$wrapper = "";
|
||||
if(strlen($page->heading) > 100) {
|
||||
$wrapper = ' style="height: 3em; overflow: auto;"';
|
||||
}
|
||||
*/
|
||||
|
||||
$flash_html = $page->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $page->flash)))."</b>" : "";
|
||||
|
||||
print <<<EOD
|
||||
<!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]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{$page->title}</title>
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en">
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link rel="stylesheet" href="{$data_href}/themes/{$theme_name}/material.min.css" rel="stylesheet">
|
||||
$header_html
|
||||
<script type="text/javascript" src="{$data_href}/themes/{$theme_name}/material.min.js"></script>
|
||||
<script type="text/javascript" src="{$data_href}/themes/{$theme_name}/script0.js?v1"></script>
|
||||
<!-- having conflicts this ensures the screens will not remain hidden \while the layout is adjusted -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
|
||||
<header class="mdl-layout__header mdl-layout__header--waterfall">
|
||||
<!-- Top row, always visible -->
|
||||
<div class="mdl-layout__header-row ">
|
||||
<!-- Title -->
|
||||
<span class="mdl-layout-title">
|
||||
<a class="mdl-logo" href="{$site_link}">{$site_name}</a>
|
||||
</span>
|
||||
<div class="mdl-layout-spacer"></div>
|
||||
$h_search
|
||||
{$toolbar_block_html}
|
||||
<button id="menu-left-col-menu"
|
||||
class="mdl-button mdl-js-button mdl-button--icon">
|
||||
<i class="material-icons">more_vert</i>
|
||||
</button>
|
||||
</div>
|
||||
<!-- Bottom row, not visible on scroll -->
|
||||
<div class="mdl-layout__header-row">
|
||||
<div class="mdl-layout-spacer"></div>
|
||||
<!-- Navigation -->
|
||||
{$subtoolbar_block_html}
|
||||
</div>
|
||||
</header>
|
||||
<div class="mdl-layout__drawer">
|
||||
<span class="mdl-layout-title">Drawer</span>
|
||||
<div class="mdl-grid">
|
||||
$drawer_block_html
|
||||
</div>
|
||||
<nav class="mdl-navigation">
|
||||
<a class="mdl-navigation__link" href="https://code.shishnet.org/shimmie2/">Shimmie ©</a>
|
||||
</nav>
|
||||
</div>
|
||||
<main class="mdl-layout__content">
|
||||
<div class="mdl-grid">
|
||||
<div class="mdl-cell mdl-cell--12-col mdl-grid ">
|
||||
$head_block_html
|
||||
$sub_block_html
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-grid" class="mdl-grid">
|
||||
<div id="left-block" class="mdl-cell mdl-cell--4-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-color--grey-200">
|
||||
<script>
|
||||
document.getElementById("left-block").style.display="none";
|
||||
</script>
|
||||
<div id="left-blk-content" class="mdl-cell mdl-cell--12-col mdl-grid">
|
||||
<!-- Start Left Block -->
|
||||
$left_block_html
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-block" class="mdl-cell mdl-shadow--2dp mdl-cell--8-col mdl-cell--8-col-tablet mdl-color--grey-200 mdl-grid">
|
||||
<script>
|
||||
document.getElementById("main-block").style.display="none";
|
||||
</script>
|
||||
<!-- Start art Block -->
|
||||
<article class="mdl-cell mdl-cell--12-col mdl-cell--top">
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="mdl-mini-footer">
|
||||
$debug
|
||||
$contact
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
|
||||
for="menu-left-col-menu">
|
||||
<li id="layout-top" class="mdl-menu__item">Layout Top</li>
|
||||
<li id="layout-right" class="mdl-menu__item">Layout Right</li>
|
||||
<li id="layout-bottom" class="mdl-menu__item">Layout Bottom</li>
|
||||
<li id="layout-left" class="mdl-menu__item">Layout Left</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
|
||||
public function rework_navigation(Block $block)
|
||||
{
|
||||
// $h = $block->header;
|
||||
$b = $block->body;
|
||||
$i = $block->id;
|
||||
|
||||
$dom = new DomDocument();
|
||||
$dom->loadHTML($b);
|
||||
// $output = [];
|
||||
$html = "<section id='$i'>\n<nav class='mdl-navigation'>\n";
|
||||
foreach ($dom->getElementsByTagName('a') as $item) {
|
||||
$item->setAttribute('class', 'mdl-navigation__link');
|
||||
$html .= $dom->saveHTML($item);
|
||||
// $output[] = array (
|
||||
// ,'str' => $dom->saveHTML($item)
|
||||
// // ,'href' => $item->getAttribute('href')
|
||||
// // ,'anchorText' => $item->nodeValue
|
||||
// );
|
||||
}
|
||||
$html .= "</nav>\n</section>\n";
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML for this block. from core
|
||||
*/
|
||||
public function get_html(Block $block, string $section="main", bool $hidable=false, string $extra_class=""): string
|
||||
{
|
||||
$h = $block->header;
|
||||
$b = $block->body;
|
||||
$i = $block->id;//blotter extention id has `!`
|
||||
|
||||
if ($section == "toolbar") {
|
||||
$html = "<section id='$i'>\n<nav class='mdl-navigation'>\n";
|
||||
if (!empty($b)) {
|
||||
$html .= "$b";
|
||||
}
|
||||
$html .= "</nav>\n</section>\n";
|
||||
return $html;
|
||||
}
|
||||
if ($section == "subtoolbar") {
|
||||
$html = "<section id='$i'>\n<nav class='mdl-navigation'>\n";
|
||||
if (!empty($b)) {
|
||||
$html .= "$b";
|
||||
}
|
||||
$html .= "</nav>\n</section>\n";
|
||||
return $html;
|
||||
}
|
||||
if ($section == "full") {
|
||||
$html = "<div class='mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col $extra_class'><section id='$i'>";
|
||||
$h_toggler = $hidable ? " shm-toggler" : "";
|
||||
if (!empty($h)) {
|
||||
$html .="<div class='mdl-card__title'><h3 data-toggle-sel='#$i' class='mdl-card__title-text $h_toggler'>$h</h3></div>";
|
||||
}
|
||||
if (!empty($b)) {
|
||||
$html .="<div class='mdl-card__supporting-text blockbody'>$b</div>";
|
||||
}
|
||||
$html .= "</section></div>\n";
|
||||
return $html;
|
||||
}
|
||||
if ($section == "third") {
|
||||
$html = "<div class='mdl-card mdl-shadow--4dp mdl-cell mdl-cell--4-col $extra_class'><section id='$i'>";
|
||||
$h_toggler = $hidable ? " shm-toggler" : "";
|
||||
if (!empty($h)) {
|
||||
$html .="<div class='mdl-card__title'><h3 data-toggle-sel='#$i' class='mdl-card__title-text $h_toggler'>$h</h3></div>";
|
||||
}
|
||||
if (!empty($b)) {
|
||||
$html .="<div class='mdl-card__supporting-text blockbody'>$b</div>";
|
||||
}
|
||||
$html .= "</section></div>\n";
|
||||
return $html;
|
||||
}
|
||||
$html = "<section id='$i'>";
|
||||
$h_toggler = $hidable ? " shm-toggler" : "";
|
||||
if (!empty($h)) {
|
||||
$html .= "<h3 data-toggle-sel='#$i' class='$h_toggler'>$h</h3>";
|
||||
}
|
||||
if (!empty($b)) {
|
||||
$html .= "<div class='blockbody'>$b</div>";
|
||||
}
|
||||
$html .= "</section>\n";
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//@todo fix ext/blotter id tag
|
||||
//@todo fix table row error for ext/ip_ban
|
||||
//@todo fix table row error for ext/image_hash_ban
|
||||
//@todo fix table row error for ext/untag
|
||||
//@todo fix ext private-messages gives Uncaught TypeError: Cannot read property 'href' of null when no messages are there..
|
|
@ -1,4 +1,272 @@
|
|||
<?php declare(strict_types=1);
|
||||
class Page extends BasePage
|
||||
{
|
||||
public function render($nav_links, $subnav_links)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$theme_name = $config->get_string(SetupConfig::THEME, 'material');
|
||||
$site_name = $config->get_string(SetupConfig::TITLE);
|
||||
$data_href = get_base_href();
|
||||
// $main_page = $config->get_string(SetupConfig::MAIN_PAGE);
|
||||
$contact_link = contact_link();
|
||||
$site_link = make_link();
|
||||
$header_html = $this->get_all_html_headers();
|
||||
|
||||
$left_block_html = "";
|
||||
$main_block_html = "";
|
||||
$head_block_html = "";
|
||||
$sub_block_html = "";
|
||||
$drawer_block_html = ""; //use exampled in user.theme.php & view.theme.php
|
||||
$toolbar_block_html = ""; // not used at this point
|
||||
$subtoolbar_block_html = ""; // use exampled in user.theme.php
|
||||
// $navigation = "";
|
||||
|
||||
$h_search = "
|
||||
<div class='mdl-textfield mdl-js-textfield mdl-textfield--expandable
|
||||
mdl-textfield--floating-label mdl-textfield--align-right'>
|
||||
<form action='".make_link()."' method='GET'>
|
||||
<label class='mdl-button mdl-js-button mdl-button--icon'
|
||||
for='waterfall-exp'>
|
||||
<i class='material-icons'>search</i>
|
||||
</label>
|
||||
<div class='mdl-textfield__expandable-holder'>
|
||||
<input id='waterfall-exp' class='autocomplete_tags mdl-textfield__input' name='search' type='text' placeholder='Search' value='' />
|
||||
<input type='hidden' name='q' value='/post/list'>
|
||||
<input type='submit' value='Find' style='display: none;' />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
";
|
||||
|
||||
foreach ($this->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "toolbar":
|
||||
$toolbar_block_html .= $this->get_html($block, "toolbar");
|
||||
break;
|
||||
case "subtoolbar":
|
||||
$subtoolbar_block_html .= $this->get_html($block, "subtoolbar");
|
||||
break;
|
||||
case "left":
|
||||
if ($block->header == "Navigation") {
|
||||
$subtoolbar_block_html = $this->rework_navigation($block);
|
||||
break;
|
||||
}
|
||||
// $left_block_html .= $block->get_html(true);
|
||||
$left_block_html .= $this->get_html($block, "full", true, "left-blocks nav-card mdl-cell--4-col-tablet");
|
||||
break;
|
||||
case "head":
|
||||
$head_block_html .= $this->get_html($block, "third", true, "nav-card head-blocks");
|
||||
break;
|
||||
case "drawer":
|
||||
$drawer_block_html .= $this->get_html($block, "full", true, "nav-card drawer-blocks");
|
||||
break;
|
||||
case "main":
|
||||
// $main_block_html .= $block->get_html(false);
|
||||
$main_block_html .= $this->get_html($block, "main", true, "");
|
||||
break;
|
||||
case "subheading":
|
||||
// $sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
$sub_block_html .= $this->get_html($block, "third", true, "nav-card");
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
/*$subheading = empty($this->subheading) ? "" : "<div id='subtitle'>{$this->subheading}</div>";
|
||||
|
||||
$wrapper = "";
|
||||
if(strlen($this->heading) > 100) {
|
||||
$wrapper = ' style="height: 3em; overflow: auto;"';
|
||||
}
|
||||
*/
|
||||
|
||||
$flash_html = $this->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $this->flash)))."</b>" : "";
|
||||
|
||||
print <<<EOD
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{$this->title}</title>
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en">
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link rel="stylesheet" href="{$data_href}/themes/{$theme_name}/material.min.css" rel="stylesheet">
|
||||
$header_html
|
||||
<script type="text/javascript" src="{$data_href}/themes/{$theme_name}/material.min.js"></script>
|
||||
<script type="text/javascript" src="{$data_href}/themes/{$theme_name}/script0.js?v1"></script>
|
||||
<!-- having conflicts this ensures the screens will not remain hidden \while the layout is adjusted -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
|
||||
<header class="mdl-layout__header mdl-layout__header--waterfall">
|
||||
<!-- Top row, always visible -->
|
||||
<div class="mdl-layout__header-row ">
|
||||
<!-- Title -->
|
||||
<span class="mdl-layout-title">
|
||||
<a class="mdl-logo" href="{$site_link}">{$site_name}</a>
|
||||
</span>
|
||||
<div class="mdl-layout-spacer"></div>
|
||||
$h_search
|
||||
{$toolbar_block_html}
|
||||
<button id="menu-left-col-menu"
|
||||
class="mdl-button mdl-js-button mdl-button--icon">
|
||||
<i class="material-icons">more_vert</i>
|
||||
</button>
|
||||
</div>
|
||||
<!-- Bottom row, not visible on scroll -->
|
||||
<div class="mdl-layout__header-row">
|
||||
<div class="mdl-layout-spacer"></div>
|
||||
<!-- Navigation -->
|
||||
{$subtoolbar_block_html}
|
||||
</div>
|
||||
</header>
|
||||
<div class="mdl-layout__drawer">
|
||||
<span class="mdl-layout-title">Drawer</span>
|
||||
<div class="mdl-grid">
|
||||
$drawer_block_html
|
||||
</div>
|
||||
<nav class="mdl-navigation">
|
||||
<a class="mdl-navigation__link" href="https://code.shishnet.org/shimmie2/">Shimmie ©</a>
|
||||
</nav>
|
||||
</div>
|
||||
<main class="mdl-layout__content">
|
||||
<div class="mdl-grid">
|
||||
<div class="mdl-cell mdl-cell--12-col mdl-grid ">
|
||||
$head_block_html
|
||||
$sub_block_html
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-grid" class="mdl-grid">
|
||||
<div id="left-block" class="mdl-cell mdl-cell--4-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-color--grey-200">
|
||||
<script>
|
||||
document.getElementById("left-block").style.display="none";
|
||||
</script>
|
||||
<div id="left-blk-content" class="mdl-cell mdl-cell--12-col mdl-grid">
|
||||
<!-- Start Left Block -->
|
||||
$left_block_html
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-block" class="mdl-cell mdl-shadow--2dp mdl-cell--8-col mdl-cell--8-col-tablet mdl-color--grey-200 mdl-grid">
|
||||
<script>
|
||||
document.getElementById("main-block").style.display="none";
|
||||
</script>
|
||||
<!-- Start art Block -->
|
||||
<article class="mdl-cell mdl-cell--12-col mdl-cell--top">
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="mdl-mini-footer">
|
||||
$debug
|
||||
$contact
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
|
||||
for="menu-left-col-menu">
|
||||
<li id="layout-top" class="mdl-menu__item">Layout Top</li>
|
||||
<li id="layout-right" class="mdl-menu__item">Layout Right</li>
|
||||
<li id="layout-bottom" class="mdl-menu__item">Layout Bottom</li>
|
||||
<li id="layout-left" class="mdl-menu__item">Layout Left</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
|
||||
public function rework_navigation(Block $block)
|
||||
{
|
||||
// $h = $block->header;
|
||||
$b = $block->body;
|
||||
$i = $block->id;
|
||||
|
||||
$dom = new DomDocument();
|
||||
$dom->loadHTML($b);
|
||||
// $output = [];
|
||||
$html = "<section id='$i'>\n<nav class='mdl-navigation'>\n";
|
||||
foreach ($dom->getElementsByTagName('a') as $item) {
|
||||
$item->setAttribute('class', 'mdl-navigation__link');
|
||||
$html .= $dom->saveHTML($item);
|
||||
// $output[] = array (
|
||||
// ,'str' => $dom->saveHTML($item)
|
||||
// // ,'href' => $item->getAttribute('href')
|
||||
// // ,'anchorText' => $item->nodeValue
|
||||
// );
|
||||
}
|
||||
$html .= "</nav>\n</section>\n";
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML for this block. from core
|
||||
*/
|
||||
public function get_html(Block $block, string $section="main", bool $hidable=false, string $extra_class=""): string
|
||||
{
|
||||
$h = $block->header;
|
||||
$b = $block->body;
|
||||
$i = $block->id;//blotter extention id has `!`
|
||||
|
||||
if ($section == "toolbar") {
|
||||
$html = "<section id='$i'>\n<nav class='mdl-navigation'>\n";
|
||||
if (!empty($b)) {
|
||||
$html .= "$b";
|
||||
}
|
||||
$html .= "</nav>\n</section>\n";
|
||||
return $html;
|
||||
}
|
||||
if ($section == "subtoolbar") {
|
||||
$html = "<section id='$i'>\n<nav class='mdl-navigation'>\n";
|
||||
if (!empty($b)) {
|
||||
$html .= "$b";
|
||||
}
|
||||
$html .= "</nav>\n</section>\n";
|
||||
return $html;
|
||||
}
|
||||
if ($section == "full") {
|
||||
$html = "<div class='mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col $extra_class'><section id='$i'>";
|
||||
$h_toggler = $hidable ? " shm-toggler" : "";
|
||||
if (!empty($h)) {
|
||||
$html .="<div class='mdl-card__title'><h3 data-toggle-sel='#$i' class='mdl-card__title-text $h_toggler'>$h</h3></div>";
|
||||
}
|
||||
if (!empty($b)) {
|
||||
$html .="<div class='mdl-card__supporting-text blockbody'>$b</div>";
|
||||
}
|
||||
$html .= "</section></div>\n";
|
||||
return $html;
|
||||
}
|
||||
if ($section == "third") {
|
||||
$html = "<div class='mdl-card mdl-shadow--4dp mdl-cell mdl-cell--4-col $extra_class'><section id='$i'>";
|
||||
$h_toggler = $hidable ? " shm-toggler" : "";
|
||||
if (!empty($h)) {
|
||||
$html .="<div class='mdl-card__title'><h3 data-toggle-sel='#$i' class='mdl-card__title-text $h_toggler'>$h</h3></div>";
|
||||
}
|
||||
if (!empty($b)) {
|
||||
$html .="<div class='mdl-card__supporting-text blockbody'>$b</div>";
|
||||
}
|
||||
$html .= "</section></div>\n";
|
||||
return $html;
|
||||
}
|
||||
$html = "<section id='$i'>";
|
||||
$h_toggler = $hidable ? " shm-toggler" : "";
|
||||
if (!empty($h)) {
|
||||
$html .= "<h3 data-toggle-sel='#$i' class='$h_toggler'>$h</h3>";
|
||||
}
|
||||
if (!empty($b)) {
|
||||
$html .= "<div class='blockbody'>$b</div>";
|
||||
}
|
||||
$html .= "</section>\n";
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* 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(SetupConfig::THEME, 'default');
|
||||
$site_name = $config->get_string(SetupConfig::TITLE);
|
||||
$data_href = get_base_href();
|
||||
$main_page = $config->get_string(SetupConfig::MAIN_PAGE);
|
||||
$contact_link = contact_link();
|
||||
$header_html = $page->get_all_html_headers();
|
||||
|
||||
$left_block_html = "";
|
||||
$main_block_html = "";
|
||||
$head_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($page->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "head":
|
||||
$head_block_html .= "<td width='250'><small>".$block->get_html(false)."</small></td>";
|
||||
break;
|
||||
case "main":
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
/*$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
||||
|
||||
$wrapper = "";
|
||||
if(strlen($page->heading) > 100) {
|
||||
$wrapper = ' style="height: 3em; overflow: auto;"';
|
||||
}
|
||||
*/
|
||||
|
||||
$flash_html = $page->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $page->flash)))."</b>" : "";
|
||||
|
||||
print <<<EOD
|
||||
<!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]-->
|
||||
<head>
|
||||
<title>{$page->title}</title>
|
||||
$header_html
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<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>
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer>
|
||||
Images © their respective owners,
|
||||
<a href="https://code.shishnet.org/shimmie2/">Shimmie</a> ©
|
||||
<a href="https://www.shishnet.org/">Shish</a> &
|
||||
<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
|
||||
2007-2019,
|
||||
based on the Danbooru concept.
|
||||
$debug
|
||||
$contact
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,72 @@
|
|||
<?php declare(strict_types=1);
|
||||
class Page extends BasePage
|
||||
{
|
||||
public function render($nav_links, $subnav_links)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$site_name = $config->get_string(SetupConfig::TITLE);
|
||||
$data_href = get_base_href();
|
||||
$main_page = $config->get_string(SetupConfig::MAIN_PAGE);
|
||||
|
||||
$left_block_html = "";
|
||||
$main_block_html = "";
|
||||
$head_block_html = "";
|
||||
$sub_block_html = "";
|
||||
|
||||
foreach ($this->blocks as $block) {
|
||||
switch ($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $block->get_html(true);
|
||||
break;
|
||||
case "head":
|
||||
$head_block_html .= "<td style='width: 250px;'><small>".$block->get_html(false)."</small></td>";
|
||||
break;
|
||||
case "main":
|
||||
$main_block_html .= $block->get_html(false);
|
||||
break;
|
||||
case "subheading":
|
||||
$sub_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$flash_html = $this->flash ? "<b id='flash'>".nl2br(html_escape(implode("\n", $this->flash)))."</b>" : "";
|
||||
$head_html = $this->head_html();
|
||||
$footer_html = $this->footer_html();
|
||||
|
||||
print <<<EOD
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="en">
|
||||
$head_html
|
||||
<body>
|
||||
<header>
|
||||
<table id="header" class="bgtop" style="width: 100%; height: 113px;">
|
||||
<tr>
|
||||
<td style="text-align: center;">
|
||||
<h1><a href="$data_href/$main_page">{$site_name}</a></h1>
|
||||
<p>[Navigation links go here]
|
||||
</td>
|
||||
$head_block_html
|
||||
</tr>
|
||||
</table>
|
||||
$sub_block_html
|
||||
</header>
|
||||
<nav>
|
||||
$left_block_html
|
||||
</nav>
|
||||
<article>
|
||||
$flash_html
|
||||
$main_block_html
|
||||
</article>
|
||||
<footer>
|
||||
$footer_html
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue