microhtml for blocks

This commit is contained in:
Shish 2020-01-23 00:45:41 +00:00
parent d7a290b635
commit 1802b9c7f6
4 changed files with 37 additions and 35 deletions

View file

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
class BlocksInfo extends ExtensionInfo class BlocksInfo extends ExtensionInfo
{ {

View file

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
class Blocks extends Extension class Blocks extends Extension
{ {

View file

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
class BlocksTest extends ShimmiePHPUnitTestCase class BlocksTest extends ShimmiePHPUnitTestCase
{ {
public function testBlocks() public function testBlocks()

View file

@ -1,43 +1,45 @@
<?php <?php declare(strict_types=1);
use function MicroHTML\{TABLE,TR,TH,TD,INPUT,TEXTAREA,rawHTML,SELECT,OPTION};
class BlocksTheme extends Themelet class BlocksTheme extends Themelet
{ {
public function display_blocks($blocks) public function display_blocks($blocks)
{ {
global $page; global $page;
$html = "<table class='form' style='width: 100%;'>"; $html = TABLE(["class"=>"form", "style"=>"width: 100%;"]);
foreach ($blocks as $block) { foreach ($blocks as $block) {
$html .= make_form(make_link("blocks/update")); $form = SHM_FORM(make_link("blocks/update"));
$html .= "<input type='hidden' name='id' value='".html_escape($block['id'])."'>"; $form->appendChild(TR(
$html .= "<tr>"; INPUT(["type"=>"hidden", "name"=>"id", "value"=>$block['id']]),
$html .= "<th>Title</th><td><input type='text' name='title' value='".html_escape($block['title'])."'></td>"; TH("Title"), TD(INPUT(["type"=>"text", "name"=>"title", "value"=>$block['title']])),
$html .= "<th>Area</th><td><input type='text' name='area' value='".html_escape($block['area'])."'></td>"; TH("Area"), TD(INPUT(["type"=>"text", "name"=>"area", "value"=>$block['area']])),
$html .= "<th>Priority</th><td><input type='text' name='priority' value='".html_escape($block['priority'])."'></td>"; TH("Priority"), TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>$block['priority']])),
$html .= "<th>Pages</th><td><input type='text' name='pages' value='".html_escape($block['pages'])."'></td>"; TH("Pages"), TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>$block['pages']])),
$html .= "<th>Delete</th><td><input type='checkbox' name='delete'></td>"; TH("Delete"), TD(INPUT(["type"=>"checkbox", "name"=>"delete"])),
$html .= "<td><input type='submit' value='Save'></td>"; TD(INPUT(["type"=>"submit", "value"=>"Save"]))
$html .= "</tr>"; ));
$html .= "<tr>"; $form->appendChild(TR(
$html .= "<td colspan='11'><textarea rows='5' name='content'>".html_escape($block['content'])."</textarea></td>"; TD(["colspan"=>"11"], TEXTAREA(["rows"=>"5", "name"=>"content"], $block['content']))
$html .= "</tr>\n"; ));
$html .= "<tr>"; $form->appendChild(TR(
$html .= "<td colspan='11'>&nbsp;</td>"; TD(["colspan"=>"11"], rawHTML("&nbsp;"))
$html .= "</tr>\n"; ));
$html .= "</form>\n"; $html->appendChild($form);
} }
$html .= make_form(make_link("blocks/add"));
$html .= "<tr>"; $form = SHM_FORM(make_link("blocks/add"));
$html .= "<th>Title</th><td><input type='text' name='title' value=''></td>"; $form->appendChild(TR(
$html .= "<th>Area</th><td><select name='area'><option>left<option>main</select></td>"; TH("Title"), TD(INPUT(["type"=>"text", "name"=>"title", "value"=>""])),
$html .= "<th>Priority</th><td><input type='text' name='priority' value='50'></td>"; TH("Area"), TD(SELECT(["name"=>"area"], OPTION("left"), OPTION("main")),
$html .= "<th>Pages</th><td><input type='text' name='pages' value='post/list*'></td>"; TH("Priority"), TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>'50'])),
$html .= "<td colspan='3'><input type='submit' value='Add'></td>"; TH("Pages"), TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>'post/list*'])),
$html .= "</tr>"; TD(["colspan"=>'3'], INPUT(["type"=>"submit", "value"=>"Add"]))
$html .= "<tr>"; )));
$html .= "<td colspan='11'><textarea rows='5' name='content'></textarea></td>"; $form->appendChild(TR(
$html .= "</tr>\n"; TD(["colspan"=>"11"], TEXTAREA(["rows"=>"5", "name"=>"content"]))
$html .= "</form>"; ));
$html .= "</table>"; $html->appendChild($form);
$page->set_title("Blocks"); $page->set_title("Blocks");
$page->set_heading("Blocks"); $page->set_heading("Blocks");