parent
3bf111603f
commit
00e625d679
@ -0,0 +1,11 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
class CustomAdminPageTheme extends AdminPageTheme |
||||
{ |
||||
public function display_page() |
||||
{ |
||||
global $page; |
||||
$page->disable_left(); |
||||
parent::display_page(); |
||||
} |
||||
} |
Binary file not shown.
@ -0,0 +1,127 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
class CustomCommentListTheme extends CommentListTheme |
||||
{ |
||||
public function display_comment_list(array $images, int $page_number, int $total_pages, bool $can_post) |
||||
{ |
||||
global $config, $page, $user; |
||||
|
||||
$page->disable_left(); |
||||
|
||||
// parts for the whole page |
||||
$prev = $page_number - 1; |
||||
$next = $page_number + 1; |
||||
|
||||
$h_prev = ($page_number <= 1) ? "Prev" : |
||||
"<a href='".make_link("comment/list/$prev")."'>Prev</a>"; |
||||
$h_index = "<a href='".make_link()."'>Index</a>"; |
||||
$h_next = ($page_number >= $total_pages) ? "Next" : |
||||
"<a href='".make_link("comment/list/$next")."'>Next</a>"; |
||||
|
||||
$nav = "$h_prev | $h_index | $h_next"; |
||||
|
||||
$page->set_title("Comments"); |
||||
$page->set_heading("Comments"); |
||||
$page->add_block(new Block("Navigation", $nav, "left")); |
||||
$this->display_paginator($page, "comment/list", null, $page_number, $total_pages); |
||||
|
||||
// parts for each image |
||||
$position = 10; |
||||
|
||||
$comment_captcha = $config->get_bool('comment_captcha'); |
||||
$comment_limit = $config->get_int("comment_list_count", 10); |
||||
|
||||
foreach ($images as $pair) { |
||||
$image = $pair[0]; |
||||
$comments = $pair[1]; |
||||
|
||||
$thumb_html = $this->build_thumb_html($image); |
||||
|
||||
$s = " "; |
||||
$un = $image->get_owner()->name; |
||||
$t = ""; |
||||
foreach ($image->get_tag_array() as $tag) { |
||||
$u_tag = url_escape($tag); |
||||
$t .= "<a href='".make_link("post/list/$u_tag/1")."'>".html_escape($tag)."</a> "; |
||||
} |
||||
$p = autodate($image->posted); |
||||
|
||||
$r = Extension::is_enabled(RatingsInfo::KEY) ? "<b>Rating</b> ".Ratings::rating_to_human($image->rating) : ""; |
||||
$comment_html = "<b>Date</b> $p $s <b>User</b> $un $s $r<br><b>Tags</b> $t<p> "; |
||||
|
||||
$comment_count = count($comments); |
||||
if ($comment_limit > 0 && $comment_count > $comment_limit) { |
||||
//$hidden = $comment_count - $comment_limit; |
||||
$comment_html .= "<p>showing $comment_limit of $comment_count comments</p>"; |
||||
$comments = array_slice($comments, -$comment_limit); |
||||
} |
||||
foreach ($comments as $comment) { |
||||
$comment_html .= $this->comment_to_html($comment); |
||||
} |
||||
if ($can_post) { |
||||
if (!$user->is_anonymous()) { |
||||
$comment_html .= $this->build_postbox($image->id); |
||||
} else { |
||||
if (!$comment_captcha) { |
||||
$comment_html .= $this->build_postbox($image->id); |
||||
} else { |
||||
$comment_html .= "<a href='".make_link("post/view/".$image->id)."'>Add Comment</a>"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
$html = " |
||||
<table><tr> |
||||
<td style='width: 220px;'>$thumb_html</td> |
||||
<td style='text-align: left;'>$comment_html</td> |
||||
</tr></table> |
||||
"; |
||||
|
||||
|
||||
$page->add_block(new Block(" ", $html, "main", $position++)); |
||||
} |
||||
} |
||||
|
||||
public function display_recent_comments(array $comments) |
||||
{ |
||||
// no recent comments in this theme |
||||
} |
||||
|
||||
|
||||
protected function comment_to_html(Comment $comment, bool $trim=false): string |
||||
{ |
||||
global $user; |
||||
|
||||
$tfe = new TextFormattingEvent($comment->comment); |
||||
send_event($tfe); |
||||
|
||||
//$i_uid = $comment->owner_id; |
||||
$h_name = html_escape($comment->owner_name); |
||||
//$h_poster_ip = html_escape($comment->poster_ip); |
||||
$h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted); |
||||
$i_comment_id = $comment->comment_id; |
||||
$i_image_id = $comment->image_id; |
||||
$h_posted = autodate($comment->posted); |
||||
|
||||
$h_userlink = "<a class='username' href='".make_link("user/$h_name")."'>$h_name</a>"; |
||||
$h_del = ""; |
||||
if ($user->can(Permissions::DELETE_COMMENT)) { |
||||
$comment_preview = substr(html_unescape($tfe->stripped), 0, 50); |
||||
$j_delete_confirm_message = json_encode("Delete comment by {$comment->owner_name}:\n$comment_preview"); |
||||
$h_delete_script = html_escape("return confirm($j_delete_confirm_message);"); |
||||
$h_delete_link = make_link("comment/delete/$i_comment_id/$i_image_id"); |
||||
$h_del = " - <a onclick='$h_delete_script' href='$h_delete_link'>Del</a>"; |
||||
} |
||||
//$h_imagelink = $trim ? "<a href='".make_link("post/view/$i_image_id")."'>>>></a>\n" : ""; |
||||
if ($trim) { |
||||
return "<p class='comment'>$h_userlink $h_del<br/>$h_posted<br/>$h_comment</p>"; |
||||
} else { |
||||
return " |
||||
<table class='comment'><tr> |
||||
<td class='meta'>$h_userlink<br/>$h_posted$h_del</td> |
||||
<td>$h_comment</td> |
||||
</tr></table> |
||||
"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,16 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
class CustomExtManagerTheme extends ExtManagerTheme |
||||
{ |
||||
public function display_table(Page $page, array $extensions, bool $editable) |
||||
{ |
||||
$page->disable_left(); |
||||
parent::display_table($page, $extensions, $editable); |
||||
} |
||||
|
||||
public function display_doc(Page $page, ExtensionInfo $info) |
||||
{ |
||||
$page->disable_left(); |
||||
parent::display_doc($page, $info); |
||||
} |
||||
} |
After Width: | Height: | Size: 75 KiB |
@ -0,0 +1,53 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
class CustomIndexTheme extends IndexTheme |
||||
{ |
||||
/** |
||||
* #param Image[] $images |
||||
*/ |
||||
public function display_page(Page $page, array $images) |
||||
{ |
||||
$this->display_shortwiki($page); |
||||
|
||||
$this->display_page_header($page, $images); |
||||
|
||||
$nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms); |
||||
$page->add_block(new Block("Search", $nav, "left", 0)); |
||||
|
||||
if (count($images) > 0) { |
||||
$this->display_page_images($page, $images); |
||||
} else { |
||||
$this->display_error(404, "No Images Found", "No images were found to match the search criteria"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* #param string[] $search_terms |
||||
*/ |
||||
protected function build_navigation(int $page_number, int $total_pages, array $search_terms): string |
||||
{ |
||||
$h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms)); |
||||
$h_search_link = make_link(); |
||||
return " |
||||
<p><form action='$h_search_link' method='GET'> |
||||
<input name='search' type='text' value='$h_search_string' class='autocomplete_tags' placeholder='' style='width:75%'/> |
||||
<input type='submit' value='Go' style='width:20%'> |
||||
<input type='hidden' name='q' value='/post/list'> |
||||
</form> |
||||
<div id='search_completions'></div>"; |
||||
} |
||||
|
||||
/** |
||||
* #param Image[] $images |
||||
*/ |
||||
protected function build_table(array $images, ?string $query): string |
||||
{ |
||||
$h_query = html_escape($query); |
||||
$table = "<div class='shm-image-list' data-query='$h_query'>"; |
||||
foreach ($images as $image) { |
||||
$table .= "\t<span class=\"thumb\">" . $this->build_thumb_html($image) . "</span>\n"; |
||||
} |
||||
$table .= "</div>"; |
||||
return $table; |
||||
} |
||||
} |
@ -0,0 +1,166 @@ |
||||
<?php declare(strict_types=1); |
||||
/** |
||||
* Name: Okebooru Theme |
||||
* Author: Bzchan <bzchan@animemahou.com>, updated by Daniel Oaks <daniel@danieloaks.net>, modified for Okebooru by butterbutt <butterbutt@thisisjoes.site> |
||||
* Link: https://code.shishnet.org/shimmie2/ |
||||
* License: GPLv2 |
||||
* Description: This is the Danbooru 2 theme with some fun modifications |
||||
* specifically for Okebooru <https://booru.oke.moe>. |
||||
*/ |
||||
//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 |
||||
{ |
||||
public $left_enabled = true; |
||||
public function disable_left() |
||||
{ |
||||
$this->left_enabled = false; |
||||
} |
||||
|
||||
public function render() |
||||
{ |
||||
global $config; |
||||
|
||||
list($nav_links, $sub_links) = $this->get_nav_links(); |
||||
|
||||
$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()."'><span id='left' class='small'><span class='fast-flicker small'>O</span>KE</span><span id='right' class='small'>BOO<span class='flicker small'>RU</span></span></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; |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
User-agent: * |
||||
Allow: / |
||||
Disallow: /artist |
||||
Disallow: /artist_commentaries |
||||
Disallow: /comment |
||||
Disallow: /explore |
||||
Disallow: /forum |
||||
Disallow: /inline |
||||
Disallow: /forum_topics |
||||
Disallow: /note |
||||
Disallow: /pool |
||||
Disallow: /post |
||||
Disallow: /session |
||||
Disallow: /static |
||||
Disallow: /tag |
||||
Disallow: /tag_alias |
||||
Disallow: /tag_implication |
||||
Disallow: /uploads |
||||
Disallow: /user_upgrades |
||||
Disallow: /user |
||||
Disallow: /wiki |
||||
Disallow: /report |
||||
Disallow: /job_task |
||||
Disallow: /help |
||||
Disallow: /admin |
||||
Disallow: /dmail |
||||
Disallow: /batch |
@ -0,0 +1,10 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
class CustomTagListTheme extends TagListTheme |
||||
{ |
||||
public function display_page(Page $page) |
||||
{ |
||||
$page->disable_left(); |
||||
parent::display_page($page); |
||||
} |
||||
} |
@ -0,0 +1,66 @@ |
||||
<?php declare(strict_types=1); |
||||
class Themelet extends BaseThemelet |
||||
{ |
||||
public function display_paginator(Page $page, string $base, ?string $query, int $page_number, int $total_pages, bool $show_random = false) |
||||
{ |
||||
if ($total_pages == 0) { |
||||
$total_pages = 1; |
||||
} |
||||
$body = $this->build_paginator($page_number, $total_pages, $base, $query); |
||||
$page->add_block(new Block(null, $body, "main", 90)); |
||||
} |
||||
|
||||
private function gen_page_link(string $base_url, ?string $query, int $page, string $name): string |
||||
{ |
||||
$link = make_link("$base_url/$page", $query); |
||||
return "<a href='$link'>$name</a>"; |
||||
} |
||||
|
||||
private function gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): string |
||||
{ |
||||
$paginator = ""; |
||||
if ($page == $current_page) { |
||||
$paginator .= "<b>$page</b>"; |
||||
} else { |
||||
$paginator .= $this->gen_page_link($base_url, $query, $page, $name); |
||||
} |
||||
return $paginator; |
||||
} |
||||
|
||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, ?string $query): string |
||||
{ |
||||
$next = $current_page + 1; |
||||
$prev = $current_page - 1; |
||||
|
||||
$at_start = ($current_page <= 3 || $total_pages <= 3); |
||||
$at_end = ($current_page >= $total_pages -2); |
||||
|
||||
$first_html = $at_start ? "" : $this->gen_page_link($base_url, $query, 1, "1"); |
||||
$prev_html = $at_start ? "" : $this->gen_page_link($base_url, $query, $prev, "<<"); |
||||
$next_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $next, ">>"); |
||||
$last_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $total_pages, "$total_pages"); |
||||
|
||||
$start = $current_page-2 > 1 ? $current_page-2 : 1; |
||||
$end = $current_page+2 <= $total_pages ? $current_page+2 : $total_pages; |
||||
|
||||
$pages = []; |
||||
foreach (range($start, $end) as $i) { |
||||
$pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, (string)$i); |
||||
} |
||||
$pages_html = implode(" ", $pages); |
||||
|
||||
if (strlen($first_html) > 0) { |
||||
$pdots = "..."; |
||||
} else { |
||||
$pdots = ""; |
||||
} |
||||
|
||||
if (strlen($last_html) > 0) { |
||||
$ndots = "..."; |
||||
} else { |
||||
$ndots = ""; |
||||
} |
||||
|
||||
return "<div id='paginator'>$prev_html $first_html $pdots $pages_html $ndots $last_html $next_html</div>"; |
||||
} |
||||
} |
@ -0,0 +1,16 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
class CustomUploadTheme extends UploadTheme |
||||
{ |
||||
public function display_block(Page $page) |
||||
{ |
||||
// this theme links to /upload |
||||
// $page->add_block(new Block("Upload", $this->build_upload_block(), "left", 20)); |
||||
} |
||||
|
||||
public function display_page(Page $page) |
||||
{ |
||||
$page->disable_left(); |
||||
parent::display_page($page); |
||||
} |
||||
} |
@ -0,0 +1,115 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
class CustomUserPageTheme extends UserPageTheme |
||||
{ |
||||
public function display_login_page(Page $page) |
||||
{ |
||||
global $config; |
||||
$page->set_title("Login"); |
||||
$page->set_heading("Login"); |
||||
$page->disable_left(); |
||||
$html = " |
||||
<form action='".make_link("user_admin/login")."' method='POST'> |
||||
<table summary='Login Form'> |
||||
<tr> |
||||
<td width='70'><label for='user'>Name</label></td> |
||||
<td width='70'><input id='user' type='text' name='user'></td> |
||||
</tr> |
||||
<tr> |
||||
<td><label for='pass'>Password</label></td> |
||||
<td><input id='pass' type='password' name='pass'></td> |
||||
</tr> |
||||
<tr><td colspan='2'><input type='submit' value='Log In'></td></tr> |
||||
</table> |
||||
</form> |
||||
"; |
||||
if ($config->get_bool("login_signup_enabled")) { |
||||
$html .= "<small><a href='".make_link("user_admin/create")."'>Create Account</a></small>"; |
||||
} |
||||
$page->add_block(new Block("Login", $html, "main", 90)); |
||||
} |
||||
|
||||
public function display_user_links(Page $page, User $user, $parts) |
||||
{ |
||||
// no block in this theme |
||||
} |
||||
public function display_login_block(Page $page) |
||||
{ |
||||
// no block in this theme |
||||
} |
||||
|
||||
public function display_user_block(Page $page, User $user, $parts) |
||||
{ |
||||
$html = ""; |
||||
$blocked = ["Pools", "Pool Changes", "Alias Editor", "My Profile"]; |
||||
foreach ($parts as $part) { |
||||
if (in_array($part["name"], $blocked)) { |
||||
continue; |
||||
} |
||||
$html .= "<li><a href='{$part["link"]}'>{$part["name"]}</a>"; |
||||
} |
||||
$b = new Block("User Links", $html, "user", 90); |
||||
$b->is_content = false; |
||||
$page->add_block($b); |
||||
} |
||||
|
||||
public function display_signup_page(Page $page) |
||||
{ |
||||
global $config; |
||||
$tac = $config->get_string("login_tac", ""); |
||||
|
||||
$tfe = new TextFormattingEvent($tac); |
||||
send_event($tfe); |
||||
$tac = $tfe->formatted; |
||||
|
||||
$reca = "<tr><td colspan='2'>".captcha_get_html()."</td></tr>"; |
||||
|
||||
if (empty($tac)) { |
||||
$html = ""; |
||||
} else { |
||||
$html = "<p>$tac</p>"; |
||||
} |
||||
|
||||
$html .= " |
||||
<form action='".make_link("user_admin/create")."' method='POST'> |
||||
<table style='width: 300px;'> |
||||
<tr><td>Name</td><td><input type='text' name='name'></td></tr> |
||||
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr> |
||||
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr> |
||||
<tr><td>Email (Optional)</td><td><input type='text' name='email'></td></tr> |
||||
$reca; |
||||
<tr><td colspan='2'><input type='Submit' value='Create Account'></td></tr> |
||||
</table> |
||||
</form> |
||||
"; |
||||
|
||||
$page->set_title("Create Account"); |
||||
$page->set_heading("Create Account"); |
||||
$page->disable_left(); |
||||
$page->add_block(new Block("Signup", $html)); |
||||
} |
||||
|
||||
public function display_ip_list(Page $page, array $uploads, array $comments, array $events) |
||||
{ |
||||
$html = "<table id='ip-history' style='width: 400px;'>"; |
||||
$html .= "<tr><td>Uploaded from: "; |
||||
foreach ($uploads as $ip => $count) { |
||||
$html .= "<br>$ip ($count)"; |
||||
} |
||||
$html .= "</td><td>Commented from:"; |
||||
foreach ($comments as $ip => $count) { |
||||
$html .= "<br>$ip ($count)"; |
||||
} |
||||
$html .= "</td></tr>"; |
||||
$html .= "<tr><td colspan='2'>(Most recent at top)</td></tr></table>"; |
||||
|
||||
$page->add_block(new Block("IPs", $html)); |
||||
} |
||||
|
||||
public function display_user_page(User $duser, $stats) |
||||
{ |
||||
global $page; |
||||
$page->disable_left(); |
||||
parent::display_user_page($duser, $stats); |
||||
} |
||||
} |
@ -0,0 +1,77 @@ |
||||
<?php declare(strict_types=1); |
||||
|
||||
class CustomViewImageTheme extends ViewImageTheme |
||||
{ |
||||
public function display_page(Image $image, $editor_parts) |
||||
{ |
||||
global $page; |
||||
$page->set_heading(html_escape($image->get_tag_list())); |
||||
$page->add_block(new Block("Search", $this->build_navigation($image), "left", 0)); |
||||
$page->add_block(new Block("Information", $this->build_information($image), "left", 15)); |
||||
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 15)); |
||||
} |
||||
|
||||
private function build_information(Image $image): string |
||||
{ |
||||
$h_owner = html_escape($image->get_owner()->name); |
||||
$h_ownerlink = "<a href='".make_link("user/$h_owner")."'>$h_owner</a>"; |
||||
$h_ip = html_escape($image->owner_ip); |
||||
$h_type = html_escape($image->get_mime()); |
||||
$h_date = autodate($image->posted); |
||||
$h_filesize = to_shorthand_int($image->filesize); |
||||
|
||||
global $user; |
||||
if ($user->can(Permissions::VIEW_IP)) { |
||||
$h_ownerlink .= " ($h_ip)"; |
||||
} |
||||
|
||||
$html = " |
||||
ID: {$image->id} |
||||
<br>Uploader: $h_ownerlink |
||||
<br>Date: $h_date |
||||
<br>Size: $h_filesize ({$image->width}x{$image->height}) |
||||
<br>Type: $h_type |
||||
"; |
||||
|
||||
if ($image->length!=null) { |
||||
$h_length = format_milliseconds($image->length); |
||||
$html .= "<br/>Length: $h_length"; |
||||
} |
||||
|
||||
|
||||
if (!is_null($image->source)) { |
||||
$h_source = html_escape($image->source); |
||||
if (substr($image->source, 0, 7) != "http://" && substr($image->source, 0, 8) != "https://") { |
||||
$h_source = "http://" . $h_source; |
||||
} |
||||
$html .= "<br>Source: <a href='$h_source'>link</a>"; |
||||
} |
||||
|
||||
if (Extension::is_enabled(RatingsInfo::KEY)) { |
||||
if ($image->rating == null || $image->rating == "?") { |
||||
$image->rating = "?"; |
||||
} |
||||
if (Extension::is_enabled(RatingsInfo::KEY)) { |
||||
$h_rating = Ratings::rating_to_human($image->rating); |
||||
$html .= "<br>Rating: $h_rating"; |
||||
} |
||||
} |
||||
|
||||
return $html; |
||||
} |
||||
|
||||
protected function build_navigation(Image $image): string |
||||
{ |
||||
//$h_pin = $this->build_pin($image); |
||||
$h_search = " |
||||
<form action='".make_link()."' method='GET'> |
||||
<input name='search' type='text' style='width:75%'> |
||||
<input type='submit' value='Go' style='width:20%'> |
||||
<input type='hidden' name='q' value='/post/list'> |
||||
<input type='submit' value='Find' style='display: none;'> |
||||
</form> |
||||
"; |
||||
|
||||
return "$h_search"; |
||||
} |
||||
} |
Loading…
Reference in new issue