2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2010-02-28 20:05:12 +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;
|
2020-10-26 15:26:43 +00:00
|
|
|
$page->set_title("Post {$image->id}: ".$image->get_tag_list());
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->set_heading(html_escape($image->get_tag_list()));
|
|
|
|
$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0));
|
|
|
|
$page->add_block(new Block("Statistics", $this->build_stats($image), "left", 15));
|
|
|
|
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 11));
|
|
|
|
$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function build_stats(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);
|
|
|
|
|
|
|
|
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)";
|
|
|
|
}
|
|
|
|
|
|
|
|
$html = "
|
2010-02-28 20:05:12 +00:00
|
|
|
Id: {$image->id}
|
|
|
|
<br>Posted: $h_date by $h_ownerlink
|
|
|
|
<br>Size: {$image->width}x{$image->height}
|
|
|
|
<br>Filesize: $h_filesize
|
2019-06-24 15:05:16 +00:00
|
|
|
<br>Type: ".$h_type."
|
2010-02-28 20:05:12 +00:00
|
|
|
";
|
2023-11-11 21:49:12 +00:00
|
|
|
if ($image->video_codec != null) {
|
2020-08-17 22:05:51 +00:00
|
|
|
$html .= "<br/>Video Codec: $image->video_codec";
|
|
|
|
}
|
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";
|
|
|
|
}
|
|
|
|
|
2010-02-28 20:05:12 +00:00
|
|
|
|
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>";
|
|
|
|
}
|
|
|
|
|
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-05-28 16:59:38 +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
|
|
|
}
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
2010-02-28 20:05:12 +00:00
|
|
|
}
|