This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/themes/rule34v2/view.theme.php

42 lines
1.1 KiB
PHP
Raw Normal View History

2023-12-15 17:20:34 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
use MicroHTML\HTMLElement;
2023-12-31 01:10:03 +00:00
use function MicroHTML\{TR, TH, TD, emptyHTML, rawHTML, joinHTML, DIV, TABLE, INPUT, A};
2023-12-15 17:20:34 +00:00
2023-12-31 01:20:36 +00:00
class CustomViewPostTheme extends ViewPostTheme
2023-12-15 17:20:34 +00:00
{
2023-12-26 22:53:09 +00:00
// override to make info box always in edit mode
2023-12-31 01:10:03 +00:00
protected function build_info(Image $image, $editor_parts): HTMLElement
2023-12-15 17:20:34 +00:00
{
global $user;
if (count($editor_parts) == 0) {
2023-12-31 01:10:03 +00:00
return emptyHTML($image->is_locked() ? "[Post Locked]" : "");
2023-12-15 17:20:34 +00:00
}
2023-12-31 01:10:03 +00:00
if(
2023-12-15 17:20:34 +00:00
(!$image->is_locked() || $user->can(Permissions::EDIT_IMAGE_LOCK)) &&
$user->can(Permissions::EDIT_IMAGE_TAG)
) {
2023-12-31 01:10:03 +00:00
$editor_parts[] = TR(TD(["colspan" => 4], INPUT(["type" => "submit", "value" => "Set"])));
2023-12-15 17:20:34 +00:00
}
2023-12-31 01:10:03 +00:00
return SHM_SIMPLE_FORM(
"post/set",
INPUT(["type" => "hidden", "name" => "image_id", "value" => $image->id]),
TABLE(
[
"class" => "image_info form",
"style" => "width: 500px; max-width: 100%;"
],
...$editor_parts,
),
);
2023-12-15 17:20:34 +00:00
}
}