2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2023-01-10 22:44:09 +00:00
|
|
|
|
|
|
|
namespace Shimmie2;
|
|
|
|
|
2020-01-26 16:38:26 +00:00
|
|
|
use function MicroHTML\TABLE;
|
|
|
|
use function MicroHTML\TR;
|
|
|
|
use function MicroHTML\TH;
|
|
|
|
use function MicroHTML\TD;
|
|
|
|
use function MicroHTML\INPUT;
|
|
|
|
use function MicroHTML\TEXTAREA;
|
|
|
|
use function MicroHTML\rawHTML;
|
|
|
|
use function MicroHTML\SELECT;
|
|
|
|
use function MicroHTML\OPTION;
|
2020-01-23 00:45:41 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class BlocksTheme extends Themelet
|
|
|
|
{
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
|
|
|
* @param array<array{id:int,title:string,area:string,priority:int,userclass:string,pages:string,content:string}> $blocks
|
|
|
|
*/
|
|
|
|
public function display_blocks(array $blocks): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $page;
|
2012-03-19 18:40:37 +00:00
|
|
|
|
2023-11-11 21:49:12 +00:00
|
|
|
$html = TABLE(["class" => "form", "style" => "width: 100%;"]);
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($blocks as $block) {
|
2020-01-26 13:25:02 +00:00
|
|
|
$html->appendChild(SHM_SIMPLE_FORM(
|
2020-01-30 10:31:11 +00:00
|
|
|
"blocks/update",
|
2020-01-26 13:25:02 +00:00
|
|
|
TR(
|
2023-11-11 21:49:12 +00:00
|
|
|
INPUT(["type" => "hidden", "name" => "id", "value" => $block['id']]),
|
2020-01-26 16:38:26 +00:00
|
|
|
TH("Title"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "text", "name" => "title", "value" => $block['title']])),
|
2020-01-26 16:38:26 +00:00
|
|
|
TH("Area"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "text", "name" => "area", "value" => $block['area']])),
|
2020-01-26 16:38:26 +00:00
|
|
|
TH("Priority"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "text", "name" => "priority", "value" => $block['priority']])),
|
2023-06-26 04:46:43 +00:00
|
|
|
TH("User Class"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "text", "name" => "userclass", "value" => $block['userclass']])),
|
2020-01-26 16:38:26 +00:00
|
|
|
TH("Pages"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "text", "name" => "pages", "value" => $block['pages']])),
|
2020-01-26 16:38:26 +00:00
|
|
|
TH("Delete"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "checkbox", "name" => "delete"])),
|
|
|
|
TD(INPUT(["type" => "submit", "value" => "Save"]))
|
2020-01-26 13:25:02 +00:00
|
|
|
),
|
|
|
|
TR(
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(["colspan" => "13"], TEXTAREA(["rows" => "5", "name" => "content"], $block['content']))
|
2020-01-26 13:25:02 +00:00
|
|
|
),
|
|
|
|
TR(
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(["colspan" => "13"], rawHTML(" "))
|
2020-01-26 13:25:02 +00:00
|
|
|
),
|
2020-01-23 00:45:41 +00:00
|
|
|
));
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2020-01-23 00:45:41 +00:00
|
|
|
|
2020-01-26 13:25:02 +00:00
|
|
|
$html->appendChild(SHM_SIMPLE_FORM(
|
2020-01-30 10:31:11 +00:00
|
|
|
"blocks/add",
|
2020-01-26 13:25:02 +00:00
|
|
|
TR(
|
2020-01-26 16:38:26 +00:00
|
|
|
TH("Title"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "text", "name" => "title", "value" => ""])),
|
2020-01-26 16:38:26 +00:00
|
|
|
TH("Area"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(SELECT(["name" => "area"], OPTION("left"), OPTION("main"))),
|
2020-01-26 16:38:26 +00:00
|
|
|
TH("Priority"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "text", "name" => "priority", "value" => '50'])),
|
2023-06-26 04:46:43 +00:00
|
|
|
TH("User Class"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "text", "name" => "userclass", "value" => ""])),
|
2020-01-26 16:38:26 +00:00
|
|
|
TH("Pages"),
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(INPUT(["type" => "text", "name" => "pages", "value" => 'post/list*'])),
|
|
|
|
TD(["colspan" => '3'], INPUT(["type" => "submit", "value" => "Add"]))
|
2020-01-26 13:25:02 +00:00
|
|
|
),
|
|
|
|
TR(
|
2023-11-11 21:49:12 +00:00
|
|
|
TD(["colspan" => "13"], TEXTAREA(["rows" => "5", "name" => "content"]))
|
2020-01-26 13:25:02 +00:00
|
|
|
),
|
2020-01-23 00:45:41 +00:00
|
|
|
));
|
2012-03-19 18:40:37 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->set_title("Blocks");
|
|
|
|
$page->set_heading("Blocks");
|
|
|
|
$page->add_block(new NavBlock());
|
2023-06-27 10:59:39 +00:00
|
|
|
$page->add_block(new Block("Block Editor", $html));
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2012-03-19 18:40:37 +00:00
|
|
|
}
|