2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2007-07-21 12:11:41 +00:00
|
|
|
|
2023-01-10 22:44:09 +00:00
|
|
|
namespace Shimmie2;
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
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("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", 10));
|
|
|
|
$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
|
|
|
|
}
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
private function build_stats(Image $image): string
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
$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);
|
2007-07-21 12:11:41 +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)";
|
|
|
|
}
|
2008-12-27 06:31:45 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html = "
|
2008-12-27 06:31:45 +00:00
|
|
|
Id: {$image->id}
|
|
|
|
<br>Posted: $h_date by $h_ownerlink
|
|
|
|
<br>Size: {$image->width}x{$image->height}
|
2008-12-27 06:36:51 +00:00
|
|
|
<br>Filesize: $h_filesize
|
2019-06-25 20:17:13 +00:00
|
|
|
<br>Type: $h_type";
|
|
|
|
|
2019-09-29 13:30:55 +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";
|
|
|
|
}
|
2008-12-27 06:31:45 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
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>";
|
|
|
|
}
|
2007-08-01 16:58:50 +00:00
|
|
|
|
2019-08-07 19:53:59 +00:00
|
|
|
if (Extension::is_enabled(RatingsInfo::KEY)) {
|
2023-06-27 16:45:35 +00:00
|
|
|
if ($image->rating === null || $image->rating == "?") {
|
2019-06-27 04:11:59 +00:00
|
|
|
$image->rating = "?";
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
$h_rating = Ratings::rating_to_human($image->rating);
|
|
|
|
$html .= "<br>Rating: $h_rating";
|
|
|
|
}
|
2012-01-24 03:14:27 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
return $html;
|
|
|
|
}
|
2007-07-21 12:11:41 +00:00
|
|
|
}
|