have image admin controls block use microhtml consistently
This commit is contained in:
parent
2d6a318a3b
commit
dbb8bb8280
20 changed files with 60 additions and 44 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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']),
|
||||
|
|
|
@ -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("
|
||||
<form>
|
||||
<select class='shm-zoomer'>
|
||||
<option value='full'>Full Size</option>
|
||||
|
@ -64,7 +64,7 @@ class PixelFileHandler extends DataHandlerExtension
|
|||
<option value='both'>Fit Both</option>
|
||||
</select>
|
||||
</form>
|
||||
", 20);
|
||||
"), 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)"<span id='image_delete_form'>".SHM_SIMPLE_FORM(
|
||||
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"]),
|
||||
)."</span>";
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]),
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')."
|
||||
<input type='hidden' name='image_id' value='{$image->id}'>
|
||||
<input id='original_width' name='original_width' type='hidden' value='{$image->width}'>
|
||||
|
@ -33,7 +35,7 @@ class ResizeImageTheme extends Themelet
|
|||
<br><label><input type='checkbox' id='resize_aspect' name='resize_aspect' style='max-width: 20px;' checked='checked'> Keep Aspect</label>
|
||||
<br><input id='resizebutton' type='submit' value='Resize'>
|
||||
</form>
|
||||
";
|
||||
");
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ class RotateImageTheme extends Themelet
|
|||
/**
|
||||
* Display a link to rotate an image.
|
||||
*/
|
||||
public function get_rotate_html(int $image_id): string
|
||||
public function get_rotate_html(int $image_id): \MicroHTML\HTMLElement
|
||||
{
|
||||
return (string)SHM_SIMPLE_FORM(
|
||||
return SHM_SIMPLE_FORM(
|
||||
'rotate/'.$image_id,
|
||||
INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]),
|
||||
INPUT(["type" => 'number', "name" => 'rotate_deg', "id" => "rotate_deg", "placeholder" => "Rotation degrees"]),
|
||||
|
|
|
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shimmie2;
|
||||
|
||||
use function MicroHTML\{rawHTML};
|
||||
|
||||
class SourceHistory extends Extension
|
||||
{
|
||||
/** @var SourceHistoryTheme */
|
||||
|
@ -58,11 +60,11 @@ class SourceHistory extends Extension
|
|||
|
||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event): void
|
||||
{
|
||||
$event->add_part("
|
||||
$event->add_part(rawHTML("
|
||||
<form action='".make_link("source_history/{$event->image->id}")."' method='GET'>
|
||||
<input type='submit' value='View Source History'>
|
||||
</form>
|
||||
", 20);
|
||||
"), 20);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shimmie2;
|
||||
|
||||
use function MicroHTML\rawHTML;
|
||||
|
||||
class TagHistory extends Extension
|
||||
{
|
||||
/** @var TagHistoryTheme */
|
||||
|
@ -52,11 +54,11 @@ class TagHistory extends Extension
|
|||
|
||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event): void
|
||||
{
|
||||
$event->add_part("
|
||||
$event->add_part(rawHTML("
|
||||
<form action='".make_link("tag_history/{$event->image->id}")."' method='GET'>
|
||||
<input type='submit' value='View Tag History'>
|
||||
</form>
|
||||
", 20);
|
||||
"), 20);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -4,12 +4,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shimmie2;
|
||||
|
||||
use function MicroHTML\{rawHTML};
|
||||
|
||||
class TranscodeImageTheme extends Themelet
|
||||
{
|
||||
/*
|
||||
* Display a link to resize an image
|
||||
*/
|
||||
public function get_transcode_html(Image $image, array $options): string
|
||||
public function get_transcode_html(Image $image, array $options): \MicroHTML\HTMLElement
|
||||
{
|
||||
$html = "
|
||||
".make_form(
|
||||
|
@ -26,7 +28,7 @@ class TranscodeImageTheme extends Themelet
|
|||
</form>
|
||||
";
|
||||
|
||||
return $html;
|
||||
return rawHTML($html);
|
||||
}
|
||||
|
||||
public function get_transcode_picker_html(array $options): string
|
||||
|
|
|
@ -4,12 +4,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shimmie2;
|
||||
|
||||
use function MicroHTML\{rawHTML};
|
||||
|
||||
class TranscodeVideoTheme extends Themelet
|
||||
{
|
||||
/*
|
||||
* Display a link to resize an image
|
||||
*/
|
||||
public function get_transcode_html(Image $image, array $options): string
|
||||
public function get_transcode_html(Image $image, array $options): \MicroHTML\HTMLElement
|
||||
{
|
||||
$html = "
|
||||
".make_form(
|
||||
|
@ -26,7 +28,7 @@ class TranscodeVideoTheme extends Themelet
|
|||
</form>
|
||||
";
|
||||
|
||||
return $html;
|
||||
return rawHTML($html);
|
||||
}
|
||||
|
||||
public function get_transcode_picker_html(array $options): string
|
||||
|
|
|
@ -8,9 +8,9 @@ use function MicroHTML\INPUT;
|
|||
|
||||
class TrashTheme extends Themelet
|
||||
{
|
||||
public function get_image_admin_html(int $image_id): string
|
||||
public function get_image_admin_html(int $image_id): \MicroHTML\HTMLElement
|
||||
{
|
||||
return (string)SHM_SIMPLE_FORM(
|
||||
return SHM_SIMPLE_FORM(
|
||||
'trash_restore/'.$image_id,
|
||||
INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]),
|
||||
INPUT(["type" => 'submit', "value" => 'Restore From Trash']),
|
||||
|
|
|
@ -8,7 +8,7 @@ use MicroHTML\HTMLElement;
|
|||
|
||||
class ImageAdminBlockBuildingEvent extends Event
|
||||
{
|
||||
/** @var HTMLElement[]|string[] */
|
||||
/** @var HTMLElement[] */
|
||||
public array $parts = [];
|
||||
public Image $image;
|
||||
public User $user;
|
||||
|
@ -22,7 +22,7 @@ class ImageAdminBlockBuildingEvent extends Event
|
|||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function add_part(HTMLElement|string $html, int $position = 50)
|
||||
public function add_part(HTMLElement $html, int $position = 50)
|
||||
{
|
||||
while (isset($this->parts[$position])) {
|
||||
$position++;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Shimmie2;
|
|||
|
||||
use MicroHTML\HTMLElement;
|
||||
|
||||
use function MicroHTML\{A, joinHTML, TABLE, TR, TD, INPUT, emptyHTML};
|
||||
use function MicroHTML\{A, joinHTML, TABLE, TR, TD, INPUT, emptyHTML, DIV, BR};
|
||||
|
||||
class ViewPostTheme extends Themelet
|
||||
{
|
||||
|
@ -41,10 +41,13 @@ class ViewPostTheme extends Themelet
|
|||
}
|
||||
}
|
||||
|
||||
public function display_admin_block(Page $page, $parts): void
|
||||
/**
|
||||
* @param HTMLElement[] $parts
|
||||
*/
|
||||
public function display_admin_block(Page $page, array $parts): void
|
||||
{
|
||||
if (count($parts) > 0) {
|
||||
$page->add_block(new Block("Post Controls", join("<br>", $parts), "left", 50));
|
||||
$page->add_block(new Block("Post Controls", DIV(["class"=>"post_controls"], joinHTML(BR(), $parts)), "left", 50));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue