Skip to content

Commit

Permalink
theme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Dec 15, 2023
1 parent c1acf5c commit f6919cf
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
45 changes: 45 additions & 0 deletions themes/rule34v2/tag_edit.theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Shimmie2;

use MicroHTML\HTMLElement;

use function MicroHTML\{TR, TH, TD, emptyHTML, rawHTML, joinHTML, DIV, INPUT, A};

class CustomTagEditTheme extends TagEditTheme
{
public function display_mass_editor()
Expand Down Expand Up @@ -54,4 +58,45 @@ public function get_source_editor_html(Image $image): \MicroHTML\HTMLElement
</tr>
");
}

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",
$user->can(Permissions::EDIT_IMAGE_OWNER),
emptyHTML(
A(["class" => "username", "href" => make_link("user/$owner")], $owner),
$ip,
", ",
$date,
INPUT(["type" => "text", "name" => "tag_edit__owner", "value" => $owner])
),
);
// 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),
emptyHTML(
INPUT(["type" => "checkbox", "name" => "tag_edit__locked", "checked" => $image->is_locked()]),
$image->is_locked() ? "Yes (Only admins may edit these details)" : "No",
),
);
}
}
44 changes: 44 additions & 0 deletions themes/rule34v2/view.theme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace Shimmie2;

use MicroHTML\HTMLElement;

use function MicroHTML\{TR, TH, TD, emptyHTML, rawHTML, joinHTML, DIV, INPUT, A};

class CustomViewImageTheme extends ViewImageTheme
{
protected function build_info(Image $image, $editor_parts): string
{
global $user;

if (count($editor_parts) == 0) {
return ($image->is_locked() ? "<br>[Post Locked]" : "");
}

$html = make_form(make_link("post/set"))."
<input type='hidden' name='image_id' value='{$image->id}'>
<table style='width: 500px; max-width: 100%;' class='image_info form'>
";
foreach ($editor_parts as $part) {
$html .= $part;
}
if (
(!$image->is_locked() || $user->can(Permissions::EDIT_IMAGE_LOCK)) &&
$user->can(Permissions::EDIT_IMAGE_TAG)
) {
$html .= "
<tr><td colspan='4'>
<input class='edit' type='submit' value='Set'>
</td></tr>
";
}
$html .= "
</table>
</form>
";
return $html;
}
}

0 comments on commit f6919cf

Please sign in to comment.