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/blocks/theme.php

69 lines
2.5 KiB
PHP
Raw Normal View History

2020-01-23 00:45:41 +00:00
<?php declare(strict_types=1);
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
class BlocksTheme extends Themelet
{
public function display_blocks($blocks)
{
global $page;
2020-01-23 00:45:41 +00:00
$html = TABLE(["class"=>"form", "style"=>"width: 100%;"]);
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(
INPUT(["type"=>"hidden", "name"=>"id", "value"=>$block['id']]),
2020-01-26 16:38:26 +00:00
TH("Title"),
TD(INPUT(["type"=>"text", "name"=>"title", "value"=>$block['title']])),
TH("Area"),
TD(INPUT(["type"=>"text", "name"=>"area", "value"=>$block['area']])),
TH("Priority"),
TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>$block['priority']])),
TH("Pages"),
TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>$block['pages']])),
TH("Delete"),
TD(INPUT(["type"=>"checkbox", "name"=>"delete"])),
2020-01-26 13:25:02 +00:00
TD(INPUT(["type"=>"submit", "value"=>"Save"]))
),
TR(
TD(["colspan"=>"11"], TEXTAREA(["rows"=>"5", "name"=>"content"], $block['content']))
),
TR(
TD(["colspan"=>"11"], rawHTML("&nbsp;"))
),
2020-01-23 00:45:41 +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"),
TD(INPUT(["type"=>"text", "name"=>"title", "value"=>""])),
TH("Area"),
TD(SELECT(["name"=>"area"], OPTION("left"), OPTION("main"))),
TH("Priority"),
TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>'50'])),
TH("Pages"),
TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>'post/list*'])),
2020-01-26 13:25:02 +00:00
TD(["colspan"=>'3'], INPUT(["type"=>"submit", "value"=>"Add"]))
),
TR(
TD(["colspan"=>"11"], TEXTAREA(["rows"=>"5", "name"=>"content"]))
),
2020-01-23 00:45:41 +00:00
));
$page->set_title("Blocks");
$page->set_heading("Blocks");
$page->add_block(new NavBlock());
2020-01-26 13:25:02 +00:00
$page->add_block(new Block("Block Editor", (string)$html));
}
}