blocks the blocks to be displayed, unsorted * * It's recommended that the theme sort the blocks before doing anything * else, using: usort($panel->blocks, "blockcmp"); * * The page should wrap all the options in a form which links to setup_save */ public function display_page(Page $page, SetupPanel $panel): void { usort($panel->blocks, "Shimmie2\blockcmp"); /* * Try and keep the two columns even; count the line breaks in * each an calculate where a block would work best */ $setupblock_html = ""; foreach ($panel->blocks as $block) { $setupblock_html .= $this->sb_to_html($block); } $table = " ".make_form(make_link("setup/save"))."
$setupblock_html
"; $page->set_title("Shimmie Setup"); $page->set_heading("Shimmie Setup"); $page->add_block(new Block("Navigation", $this->build_navigation(), "left", 0)); $page->add_block(new Block("Setup", $table)); } /** * @param array $options */ public function display_advanced(Page $page, array $options): void { $h_rows = ""; ksort($options); foreach ($options as $name => $value) { if (is_null($value)) { $value = ''; } $h_name = html_escape($name); $h_value = html_escape((string)$value); $h_box = ""; if (is_string($value) && str_contains($value, "\n")) { $h_box .= ""; } else { $h_box .= ""; } $h_box .= ""; $h_rows .= "$h_name$h_box"; } $table = " ".make_form(make_link("setup/save"))." $h_rows
NameValue
"; $page->set_title("Shimmie Setup"); $page->set_heading("Shimmie Setup"); $page->add_block(new Block("Navigation", $this->build_navigation(), "left", 0)); $page->add_block(new Block("Setup", $table)); } protected function build_navigation(): string { return " Index
Help
Advanced "; } protected function sb_to_html(SetupBlock $block): string { $h = $block->header; $b = $block->body; $html = "
$h
$b
"; return $html; } }