diff --git a/ext/rating/theme.php b/ext/rating/theme.php index 0c3f1f57..fb3e12f2 100644 --- a/ext/rating/theme.php +++ b/ext/rating/theme.php @@ -31,7 +31,7 @@ class RatingsTheme extends Themelet public function get_upload_specific_rater_html(string $suffix): HTMLElement { - return TD($this->get_selection_rater_html(name:"rating${suffix}", selected_options: ["?"])); + return TD($this->get_selection_rater_html(name:"rating{$suffix}", selected_options: ["?"])); } /** diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php index 246b9b26..4b445862 100644 --- a/ext/wiki/theme.php +++ b/ext/wiki/theme.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Shimmie2; +use function MicroHTML\{FORM, INPUT, TABLE, TR, TD, emptyHTML, rawHTML, BR, TEXTAREA, DIV, HR, P, A}; + class WikiTheme extends Themelet { /** @@ -25,7 +27,7 @@ class WikiTheme extends Themelet // only the admin can edit the sidebar if ($user->can(Permissions::WIKI_ADMIN)) { - $tfe->formatted .= "
(Edit)"; + $tfe->formatted .= "
(Edit)";
}
// see if title is a category'd tag
@@ -75,23 +77,25 @@ class WikiTheme extends Themelet
protected function create_edit_html(WikiPage $page): string
{
- $u_title = url_escape($page->title);
- $i_revision = $page->revision + 1;
-
global $user;
- if ($user->can(Permissions::WIKI_ADMIN)) {
- $val = $page->is_locked() ? " checked" : "";
- $lock = "
Lock page: ";
- } else {
- $lock = "";
- }
- return make_form(make_link("wiki/$u_title/save"))."
-
-
- $lock
-
-
- ";
+
+ $lock = $user->can(Permissions::WIKI_ADMIN) ?
+ emptyHTML(
+ BR(),
+ "Lock page: ",
+ INPUT(["type" => "checkbox", "name" => "lock", "checked" => $page->is_locked()])
+ ) :
+ emptyHTML();
+
+ $u_title = url_escape($page->title);
+ return (string)SHM_SIMPLE_FORM(
+ "wiki/$u_title/save",
+ INPUT(["type" => "hidden", "name" => "revision", "value" => $page->revision + 1]),
+ TEXTAREA(["name" => "body", "style" => "width: 100%", "rows" => 20], $page->body),
+ $lock,
+ BR(),
+ SHM_SUBMIT("Save")
+ );
}
protected function create_display_html(WikiPage $page): string
@@ -101,41 +105,41 @@ class WikiTheme extends Themelet
$u_title = url_escape($page->title);
$owner = $page->get_owner();
- $formatted_body = Wiki::format_tag_wiki_page($page);
+ $formatted_body = rawHTML(Wiki::format_tag_wiki_page($page));
- $edit = "
".make_form(make_link("wiki/$u_title/edit"))." - - - | - " : - ""; - if ($user->can(Permissions::WIKI_ADMIN)) { - $edit .= " -".make_form(make_link("wiki/$u_title/delete_revision"))." - - - | -".make_form(make_link("wiki/$u_title/delete_all"))." - - | - "; + $edit = TR(); + if(Wiki::can_edit($user, $page)) { + $edit->appendChild(TD(FORM( + ["action" => make_link("wiki/$u_title/edit", "revision={$page->revision}")], + INPUT(["type" => "submit", "value" => "Edit"]) + ))); + } + if ($user->can(Permissions::WIKI_ADMIN)) { + $edit->appendChild( + TD(SHM_SIMPLE_FORM( + "wiki/$u_title/delete_revision", + INPUT(["type" => "hidden", "name" => "revision", "value" => $page->revision]), + SHM_SUBMIT("Delete") + )) + ); + $edit->appendChild(TD(SHM_SIMPLE_FORM( + "wiki/$u_title/delete_all", + SHM_SUBMIT("Delete All") + ))); } - $edit .= "