[wiki] fixes
This commit is contained in:
parent
ed0eb1401c
commit
426f30e8d5
2 changed files with 55 additions and 51 deletions
|
@ -31,7 +31,7 @@ class RatingsTheme extends Themelet
|
||||||
|
|
||||||
public function get_upload_specific_rater_html(string $suffix): HTMLElement
|
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: ["?"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shimmie2;
|
namespace Shimmie2;
|
||||||
|
|
||||||
|
use function MicroHTML\{FORM, INPUT, TABLE, TR, TD, emptyHTML, rawHTML, BR, TEXTAREA, DIV, HR, P, A};
|
||||||
|
|
||||||
class WikiTheme extends Themelet
|
class WikiTheme extends Themelet
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +27,7 @@ class WikiTheme extends Themelet
|
||||||
|
|
||||||
// only the admin can edit the sidebar
|
// only the admin can edit the sidebar
|
||||||
if ($user->can(Permissions::WIKI_ADMIN)) {
|
if ($user->can(Permissions::WIKI_ADMIN)) {
|
||||||
$tfe->formatted .= "<p>(<a href='".make_link("wiki/wiki:sidebar", "edit=on")."'>Edit</a>)";
|
$tfe->formatted .= "<p>(<a href='".make_link("wiki/wiki:sidebar/edit")."'>Edit</a>)";
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if title is a category'd tag
|
// see if title is a category'd tag
|
||||||
|
@ -75,23 +77,25 @@ class WikiTheme extends Themelet
|
||||||
|
|
||||||
protected function create_edit_html(WikiPage $page): string
|
protected function create_edit_html(WikiPage $page): string
|
||||||
{
|
{
|
||||||
$u_title = url_escape($page->title);
|
|
||||||
$i_revision = $page->revision + 1;
|
|
||||||
|
|
||||||
global $user;
|
global $user;
|
||||||
if ($user->can(Permissions::WIKI_ADMIN)) {
|
|
||||||
$val = $page->is_locked() ? " checked" : "";
|
$lock = $user->can(Permissions::WIKI_ADMIN) ?
|
||||||
$lock = "<br>Lock page: <input type='checkbox' name='lock'$val>";
|
emptyHTML(
|
||||||
} else {
|
BR(),
|
||||||
$lock = "";
|
"Lock page: ",
|
||||||
}
|
INPUT(["type" => "checkbox", "name" => "lock", "checked" => $page->is_locked()])
|
||||||
return make_form(make_link("wiki/$u_title/save"))."
|
) :
|
||||||
<input type='hidden' name='revision' value='$i_revision'>
|
emptyHTML();
|
||||||
<textarea name='body' style='width: 100%' rows='20'>".html_escape($page->body)."</textarea>
|
|
||||||
$lock
|
$u_title = url_escape($page->title);
|
||||||
<br><input type='submit' value='Save'>
|
return (string)SHM_SIMPLE_FORM(
|
||||||
</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
|
protected function create_display_html(WikiPage $page): string
|
||||||
|
@ -101,41 +105,41 @@ class WikiTheme extends Themelet
|
||||||
$u_title = url_escape($page->title);
|
$u_title = url_escape($page->title);
|
||||||
$owner = $page->get_owner();
|
$owner = $page->get_owner();
|
||||||
|
|
||||||
$formatted_body = Wiki::format_tag_wiki_page($page);
|
$formatted_body = rawHTML(Wiki::format_tag_wiki_page($page));
|
||||||
|
|
||||||
$edit = "<table><tr>";
|
$edit = TR();
|
||||||
$edit .= Wiki::can_edit($user, $page) ?
|
if(Wiki::can_edit($user, $page)) {
|
||||||
"
|
$edit->appendChild(TD(FORM(
|
||||||
<td>".make_form(make_link("wiki/$u_title/edit"))."
|
["action" => make_link("wiki/$u_title/edit", "revision={$page->revision}")],
|
||||||
<input type='hidden' name='revision' value='".$page->revision."'>
|
INPUT(["type" => "submit", "value" => "Edit"])
|
||||||
<input type='submit' value='Edit'>
|
)));
|
||||||
</form></td>
|
}
|
||||||
" :
|
if ($user->can(Permissions::WIKI_ADMIN)) {
|
||||||
"";
|
$edit->appendChild(
|
||||||
if ($user->can(Permissions::WIKI_ADMIN)) {
|
TD(SHM_SIMPLE_FORM(
|
||||||
$edit .= "
|
"wiki/$u_title/delete_revision",
|
||||||
<td>".make_form(make_link("wiki/$u_title/delete_revision"))."
|
INPUT(["type" => "hidden", "name" => "revision", "value" => $page->revision]),
|
||||||
<input type='hidden' name='revision' value='".$page->revision."'>
|
SHM_SUBMIT("Delete")
|
||||||
<input type='submit' value='Delete This Version'>
|
))
|
||||||
</form></td>
|
);
|
||||||
<td>".make_form(make_link("wiki/$u_title/delete_all"))."
|
$edit->appendChild(TD(SHM_SIMPLE_FORM(
|
||||||
<input type='submit' value='Delete All'>
|
"wiki/$u_title/delete_all",
|
||||||
</form></td>
|
SHM_SUBMIT("Delete All")
|
||||||
";
|
)));
|
||||||
}
|
}
|
||||||
$edit .= "</tr></table>";
|
|
||||||
|
|
||||||
return "
|
return (string)DIV(
|
||||||
<div class='wiki-page'>
|
["class" => "wiki-page"],
|
||||||
$formatted_body
|
$formatted_body,
|
||||||
<hr>
|
HR(),
|
||||||
<p class='wiki-footer'>
|
P(
|
||||||
<a href='".make_link("wiki/$u_title/history")."'>Revision {$page->revision}</a>
|
["class" => "wiki-footer"],
|
||||||
by <a href='".make_link("user/{$owner->name}")."'>{$owner->name}</a>
|
A(["href" => make_link("wiki/$u_title/history")], "Revision {$page->revision}"),
|
||||||
at {$page->date}
|
" by ",
|
||||||
$edit
|
A(["href" => make_link("user/{$owner->name}")], $owner->name),
|
||||||
</p>
|
" at {$page->date}",
|
||||||
</div>
|
TABLE($edit),
|
||||||
";
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue