2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2023-01-10 22:44:09 +00:00
|
|
|
namespace Shimmie2;
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
use MicroHTML\HTMLElement;
|
|
|
|
|
2023-12-31 01:20:36 +00:00
|
|
|
class CustomViewPostTheme extends ViewPostTheme
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
|
|
|
* @param HTMLElement[] $editor_parts
|
|
|
|
*/
|
|
|
|
public function display_page(Image $image, array $editor_parts): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
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));
|
|
|
|
}
|
2014-04-29 05:33:03 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
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);
|
2020-06-14 16:05:55 +00:00
|
|
|
$h_type = html_escape($image->get_mime());
|
2019-05-28 16:59:38 +00:00
|
|
|
$h_date = autodate($image->posted);
|
|
|
|
$h_filesize = to_shorthand_int($image->filesize);
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
global $user;
|
2019-07-09 14:10:21 +00:00
|
|
|
if ($user->can(Permissions::VIEW_IP)) {
|
2019-05-28 16:59:38 +00:00
|
|
|
$h_ownerlink .= " ($h_ip)";
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html = "
|
2013-06-19 19:09:22 +00:00
|
|
|
ID: {$image->id}
|
|
|
|
<br>Uploader: $h_ownerlink
|
|
|
|
<br>Date: $h_date
|
|
|
|
<br>Size: $h_filesize ({$image->width}x{$image->height})
|
2019-06-25 20:17:13 +00:00
|
|
|
<br>Type: $h_type
|
2013-06-19 19:09:22 +00:00
|
|
|
";
|
|
|
|
|
2023-11-11 21:49:12 +00:00
|
|
|
if ($image->length != null) {
|
2019-06-25 20:17:13 +00:00
|
|
|
$h_length = format_milliseconds($image->length);
|
|
|
|
$html .= "<br/>Length: $h_length";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (!is_null($image->source)) {
|
2024-01-19 11:10:54 +00:00
|
|
|
$h_source = html_escape(make_http($image->source));
|
2019-05-28 16:59:38 +00:00
|
|
|
$html .= "<br>Source: <a href='$h_source'>link</a>";
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2019-08-07 19:53:59 +00:00
|
|
|
if (Extension::is_enabled(RatingsInfo::KEY)) {
|
2024-06-12 23:20:50 +00:00
|
|
|
$rating = $image['rating'];
|
|
|
|
if ($rating === null) {
|
|
|
|
$rating = "?";
|
2019-10-10 15:25:11 +00:00
|
|
|
}
|
2024-06-12 23:20:50 +00:00
|
|
|
$h_rating = Ratings::rating_to_human($rating);
|
|
|
|
$html .= "<br>Rating: <a href='".search_link(["rating=$rating"])."'>$h_rating</a>";
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
return $html;
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
protected function build_navigation(Image $image): string
|
|
|
|
{
|
|
|
|
//$h_pin = $this->build_pin($image);
|
|
|
|
$h_search = "
|
2024-02-12 11:26:13 +00:00
|
|
|
<form action='".search_link()."' method='GET'>
|
2024-06-09 14:32:20 +00:00
|
|
|
<input name='search' type='text' class='autocomplete_tags' style='width:75%'>
|
2013-06-19 19:09:22 +00:00
|
|
|
<input type='submit' value='Go' style='width:20%'>
|
2024-02-12 11:11:14 +00:00
|
|
|
<input type='hidden' name='q' value='post/list'>
|
2013-06-19 19:09:22 +00:00
|
|
|
</form>
|
|
|
|
";
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
return "$h_search";
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
}
|