[r34] use CSS to show and hide things rather than custom theme overrides
This commit is contained in:
parent
9e9225acf3
commit
d3cf2b9531
3 changed files with 16 additions and 120 deletions
|
@ -243,6 +243,22 @@ SECTION>H3 {
|
|||
margin: auto;
|
||||
}
|
||||
|
||||
/*
|
||||
* Image info - show both edit and view modes at the same time,
|
||||
* except for Tags, Locked, and the Edit button.
|
||||
*/
|
||||
.image_info.infomode-view .edit,
|
||||
.image_info.infomode-view .view {
|
||||
display: block;
|
||||
}
|
||||
.image_info.infomode-view TR[data-row="Tags"] .view,
|
||||
.image_info.infomode-view TR[data-row="Locked"] .view,
|
||||
.image_info INPUT[type="button"][value="Edit"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* responsive overrides *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shimmie2;
|
||||
|
||||
use MicroHTML\HTMLElement;
|
||||
|
||||
use function MicroHTML\{TR, TH, TD, emptyHTML, rawHTML, joinHTML, DIV, INPUT, A};
|
||||
|
||||
class CustomTagEditTheme extends TagEditTheme
|
||||
{
|
||||
public function get_tag_editor_html(Image $image): HTMLElement
|
||||
{
|
||||
global $user;
|
||||
return SHM_POST_INFO(
|
||||
"Tags",
|
||||
INPUT([
|
||||
"type" => "text",
|
||||
"name" => "tag_edit__tags",
|
||||
"value" => $image->get_tag_list(),
|
||||
"class" => "autocomplete_tags"
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
public function get_source_editor_html(Image $image): HTMLElement
|
||||
{
|
||||
global $user;
|
||||
return SHM_POST_INFO(
|
||||
A(["href" => make_link("source_history/{$image->id}")], rawHTML("Source Link")),
|
||||
emptyHTML(
|
||||
DIV(
|
||||
["style" => "overflow: hidden; white-space: nowrap; max-width: 350px; text-overflow: ellipsis;"],
|
||||
$this->format_source($image->get_source())
|
||||
),
|
||||
$user->can(Permissions::EDIT_IMAGE_SOURCE) ? INPUT(["type" => "text", "name" => "tag_edit__source", "value" => $image->get_source()]) : null
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function get_user_editor_html(Image $image): HTMLElement
|
||||
{
|
||||
global $user;
|
||||
$owner = $image->get_owner()->name;
|
||||
$date = rawHTML(autodate($image->posted));
|
||||
$ip = $user->can(Permissions::VIEW_IP) ? rawHTML(" (" . show_ip($image->owner_ip, "Post posted {$image->posted}") . ")") : "";
|
||||
$info = SHM_POST_INFO(
|
||||
"Uploader",
|
||||
emptyHTML(
|
||||
A(["class" => "username", "href" => make_link("user/$owner")], $owner),
|
||||
$ip,
|
||||
", ",
|
||||
$date,
|
||||
$user->can(Permissions::EDIT_IMAGE_OWNER) ? INPUT(["type" => "text", "name" => "tag_edit__owner", "value" => $owner]) : null
|
||||
),
|
||||
);
|
||||
// SHM_POST_INFO returns a TR, let's sneakily append
|
||||
// a TD with the avatar in it
|
||||
$info->appendChild(
|
||||
TD(
|
||||
["width" => "80px", "rowspan" => "4"],
|
||||
rawHTML($image->get_owner()->get_avatar_html())
|
||||
)
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
|
||||
public function get_lock_editor_html(Image $image): HTMLElement
|
||||
{
|
||||
global $user;
|
||||
return SHM_POST_INFO(
|
||||
"Locked",
|
||||
$user->can(Permissions::EDIT_IMAGE_LOCK) ?
|
||||
INPUT(["type" => "checkbox", "name" => "tag_edit__locked", "checked" => $image->is_locked()]) :
|
||||
emptyHTML($image->is_locked() ? "Yes (Only admins may edit these details)" : "No")
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shimmie2;
|
||||
|
||||
use MicroHTML\HTMLElement;
|
||||
|
||||
use function MicroHTML\{TR, TH, TD, emptyHTML, rawHTML, joinHTML, DIV, TABLE, INPUT, A};
|
||||
|
||||
class CustomViewPostTheme extends ViewPostTheme
|
||||
{
|
||||
// override to make info box always in edit mode
|
||||
protected function build_info(Image $image, $editor_parts): HTMLElement
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (count($editor_parts) == 0) {
|
||||
return emptyHTML($image->is_locked() ? "[Post Locked]" : "");
|
||||
}
|
||||
|
||||
if(
|
||||
(!$image->is_locked() || $user->can(Permissions::EDIT_IMAGE_LOCK)) &&
|
||||
$user->can(Permissions::EDIT_IMAGE_TAG)
|
||||
) {
|
||||
$editor_parts[] = TR(TD(["colspan" => 4], INPUT(["type" => "submit", "value" => "Set"])));
|
||||
}
|
||||
|
||||
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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in a new issue