diff --git a/ext/approval/main.php b/ext/approval/main.php index d3725580..9417157e 100644 --- a/ext/approval/main.php +++ b/ext/approval/main.php @@ -229,7 +229,7 @@ class Approval extends Extension { global $user, $config; if ($user->can(Permissions::APPROVE_IMAGE) && $config->get_bool(ApprovalConfig::IMAGES)) { - $event->add_part((string)$this->theme->get_image_admin_html($event->image)); + $event->add_part($this->theme->get_image_admin_html($event->image)); } } diff --git a/ext/favorites/main.php b/ext/favorites/main.php index 171f7108..43189490 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -44,7 +44,7 @@ class Favorites extends Extension ["user_id" => $user_id, "image_id" => $image_id] ) > 0; - $event->add_part((string)$this->theme->get_voter_html($event->image, $is_favorited)); + $event->add_part($this->theme->get_voter_html($event->image, $is_favorited)); } } diff --git a/ext/featured/theme.php b/ext/featured/theme.php index fd9c1e42..d3c5f58d 100644 --- a/ext/featured/theme.php +++ b/ext/featured/theme.php @@ -16,9 +16,9 @@ class FeaturedTheme extends Themelet $page->add_block(new Block("Featured Post", $this->build_featured_html($image), "left", 3)); } - public function get_buttons_html(int $image_id): string + public function get_buttons_html(int $image_id): \MicroHTML\HTMLElement { - return (string)SHM_SIMPLE_FORM( + return SHM_SIMPLE_FORM( "featured_image/set", INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), INPUT(["type" => 'submit', "value" => 'Feature This']), diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index ba2af98d..9c89e4d3 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -55,7 +55,7 @@ class PixelFileHandler extends DataHandlerExtension public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event): void { if ($event->context == "view") { - $event->add_part(" + $event->add_part(\MicroHTML\rawHTML("
- ", 20); + "), 20); } } } diff --git a/ext/image/theme.php b/ext/image/theme.php index 8b4a99cb..3fceb2d7 100644 --- a/ext/image/theme.php +++ b/ext/image/theme.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shimmie2; -use function MicroHTML\INPUT; +use function MicroHTML\{INPUT, SPAN}; class ImageIOTheme extends Themelet { @@ -12,12 +12,15 @@ class ImageIOTheme extends Themelet * Display a link to delete an image * (Added inline Javascript to confirm the deletion) */ - public function get_deleter_html(int $image_id): string + public function get_deleter_html(int $image_id): \MicroHTML\HTMLElement { - return (string)"".SHM_SIMPLE_FORM( - "image/delete", - INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), - INPUT(["type" => 'submit', "value" => 'Delete', "onclick" => 'return confirm("Delete the image?");', "id" => "image_delete_button"]), - ).""; + return SPAN( + ["id"=>"image_delete_form"], + SHM_SIMPLE_FORM( + "image/delete", + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), + INPUT(["type" => 'submit', "value" => 'Delete', "onclick" => 'return confirm("Delete the image?");', "id" => "image_delete_button"]), + ) + ); } } diff --git a/ext/image_hash_ban/theme.php b/ext/image_hash_ban/theme.php index 7d347d38..3671ac0f 100644 --- a/ext/image_hash_ban/theme.php +++ b/ext/image_hash_ban/theme.php @@ -22,9 +22,9 @@ class ImageBanTheme extends Themelet /* * Display a link to delete an image */ - public function get_buttons_html(Image $image): string + public function get_buttons_html(Image $image): \MicroHTML\HTMLElement { - return (string)SHM_SIMPLE_FORM( + return SHM_SIMPLE_FORM( "image_hash_ban/add", INPUT(["type" => 'hidden', "name" => 'c_hash', "value" => $image->hash]), INPUT(["type" => 'hidden', "name" => 'c_image_id', "value" => $image->id]), diff --git a/ext/media/theme.php b/ext/media/theme.php index ca020597..3438b866 100644 --- a/ext/media/theme.php +++ b/ext/media/theme.php @@ -8,9 +8,9 @@ use function MicroHTML\INPUT; class MediaTheme extends Themelet { - public function get_buttons_html(int $image_id): string + public function get_buttons_html(int $image_id): \MicroHTML\HTMLElement { - return (string)SHM_SIMPLE_FORM( + return SHM_SIMPLE_FORM( "media_rescan/", INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), SHM_SUBMIT('Scan Media Properties'), diff --git a/ext/pools/main.php b/ext/pools/main.php index c0fc0beb..5308a1fc 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -497,7 +497,7 @@ class Pools extends Extension $pools = $database->get_pairs("SELECT id,title FROM pools WHERE user_id=:id ORDER BY title", ["id" => $user->id]); } if (count($pools) > 0) { - $event->add_part((string)$this->theme->get_adder_html($event->image, $pools)); + $event->add_part($this->theme->get_adder_html($event->image, $pools)); } } } diff --git a/ext/private_image/theme.php b/ext/private_image/theme.php index 44387653..9e8fe687 100644 --- a/ext/private_image/theme.php +++ b/ext/private_image/theme.php @@ -8,7 +8,7 @@ use function MicroHTML\INPUT; class PrivateImageTheme extends Themelet { - public function get_image_admin_html(Image $image): string + public function get_image_admin_html(Image $image): \MicroHTML\HTMLElement { if ($image['private'] === false) { $html = SHM_SIMPLE_FORM( @@ -24,7 +24,7 @@ class PrivateImageTheme extends Themelet ); } - return (string)$html; + return $html; } public function get_help_html(): string diff --git a/ext/regen_thumb/theme.php b/ext/regen_thumb/theme.php index 9a0d2ab1..e6f4a16f 100644 --- a/ext/regen_thumb/theme.php +++ b/ext/regen_thumb/theme.php @@ -11,9 +11,9 @@ class RegenThumbTheme extends Themelet /** * Show a form which offers to regenerate the thumb of an image with ID #$image_id */ - public function get_buttons_html(int $image_id): string + public function get_buttons_html(int $image_id): \MicroHTML\HTMLElement { - return (string)SHM_SIMPLE_FORM( + return SHM_SIMPLE_FORM( "regen_thumb/one", INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), SHM_SUBMIT('Regenerate Thumbnail') diff --git a/ext/replace_file/theme.php b/ext/replace_file/theme.php index 1eca111c..8fbbb4ca 100644 --- a/ext/replace_file/theme.php +++ b/ext/replace_file/theme.php @@ -66,11 +66,11 @@ class ReplaceFileTheme extends Themelet /** * Display link to replace the image */ - public function get_replace_html(int $image_id): string + public function get_replace_html(int $image_id): \MicroHTML\HTMLElement { $form = SHM_FORM("replace/$image_id", "GET"); $form->appendChild(INPUT(["type" => 'submit', "value" => 'Replace'])); - return (string)$form; + return $form; } protected function get_accept(): string diff --git a/ext/resize/theme.php b/ext/resize/theme.php index 384a27c0..04900c96 100644 --- a/ext/resize/theme.php +++ b/ext/resize/theme.php @@ -4,12 +4,14 @@ declare(strict_types=1); namespace Shimmie2; +use function MicroHTML\{rawHTML}; + class ResizeImageTheme extends Themelet { /* * Display a link to resize an image */ - public function get_resize_html(Image $image): string + public function get_resize_html(Image $image): \MicroHTML\HTMLElement { global $config; @@ -23,7 +25,7 @@ class ResizeImageTheme extends Themelet $default_height = $image->height; } - $html = " + $html = rawHTML(" ".make_form(make_link("resize/{$image->id}"), 'POST')." @@ -33,7 +35,7 @@ class ResizeImageTheme extends Themelet