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/ext/view/events/image_admin_block_building_event.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
2024-01-05 04:06:19 +00:00
2024-01-05 02:03:41 +00:00
use MicroHTML\HTMLElement;
2024-02-10 18:35:55 +00:00
use function MicroHTML\{FORM,INPUT};
class ImageAdminBlockBuildingEvent extends Event
{
/** @var HTMLElement[] */
public array $parts = [];
public Image $image;
public User $user;
public string $context;
public function __construct(Image $image, User $user, string $context)
{
2020-01-26 13:19:35 +00:00
parent::__construct();
$this->image = $image;
$this->user = $user;
$this->context = $context;
}
public function add_part(HTMLElement $html, int $position = 50): void
{
while (isset($this->parts[$position])) {
$position++;
}
$this->parts[$position] = $html;
}
2024-02-10 18:35:55 +00:00
public function add_button(string $name, string $path, int $position = 50): void
{
$this->add_part(
SHM_SIMPLE_FORM(
$path,
2024-02-10 18:35:55 +00:00
INPUT([
"type" => "submit",
"value" => $name,
])
),
$position
);
}
2019-09-29 13:30:55 +00:00
}