microhtml for user page
This commit is contained in:
parent
2c2381d965
commit
73c63e3477
@ -1,6 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
use function MicroHTML\FORM;
|
use function MicroHTML\FORM;
|
||||||
use function MicroHTML\INPUT;
|
use function MicroHTML\INPUT;
|
||||||
|
use function MicroHTML\DIV;
|
||||||
|
use function MicroHTML\PRE;
|
||||||
|
use function MicroHTML\P;
|
||||||
|
use function MicroHTML\TABLE;
|
||||||
|
use function MicroHTML\THEAD;
|
||||||
|
use function MicroHTML\TFOOT;
|
||||||
|
use function MicroHTML\TR;
|
||||||
|
use function MicroHTML\TH;
|
||||||
|
use function MicroHTML\TD;
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||||
* Misc *
|
* Misc *
|
||||||
@ -693,3 +702,30 @@ function SHM_FORM(string $target, string $method="POST", bool $multipart=false,
|
|||||||
|
|
||||||
return $f;
|
return $f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SHM_COMMAND_EXAMPLE(string $ex, string $desc)
|
||||||
|
{
|
||||||
|
return DIV(
|
||||||
|
["class"=>"command_example"],
|
||||||
|
PRE($ex),
|
||||||
|
P($desc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot)
|
||||||
|
{
|
||||||
|
if (is_string($foot)) {
|
||||||
|
$foot = TFOOT(TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>$foot]))));
|
||||||
|
}
|
||||||
|
$form = SHM_FORM(make_link($target));
|
||||||
|
$form->appendChild(P(
|
||||||
|
INPUT(["type"=>'hidden', "name"=>'id', "value"=>$duser->id]),
|
||||||
|
TABLE(
|
||||||
|
["class"=>"form"],
|
||||||
|
THEAD(TR(TH(["colspan"=>"2"], $title))),
|
||||||
|
$body,
|
||||||
|
$foot
|
||||||
|
)
|
||||||
|
));
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
use function \MicroHTML\{emptyHTML,rawHTML,TABLE,TBODY,TFOOT,TR,TH,TD,LABEL,INPUT,SMALL,A,BR,P};
|
use function \MicroHTML\emptyHTML;
|
||||||
|
use function \MicroHTML\rawHTML;
|
||||||
|
use function \MicroHTML\TABLE;
|
||||||
|
use function \MicroHTML\TBODY;
|
||||||
|
use function \MicroHTML\TFOOT;
|
||||||
|
use function \MicroHTML\TR;
|
||||||
|
use function \MicroHTML\TH;
|
||||||
|
use function \MicroHTML\TD;
|
||||||
|
use function \MicroHTML\LABEL;
|
||||||
|
use function \MicroHTML\INPUT;
|
||||||
|
use function \MicroHTML\SMALL;
|
||||||
|
use function \MicroHTML\A;
|
||||||
|
use function \MicroHTML\BR;
|
||||||
|
use function \MicroHTML\P;
|
||||||
|
use function \MicroHTML\SELECT;
|
||||||
|
use function \MicroHTML\OPTION;
|
||||||
|
|
||||||
class UserPageTheme extends Themelet
|
class UserPageTheme extends Themelet
|
||||||
{
|
{
|
||||||
@ -74,7 +89,7 @@ class UserPageTheme extends Themelet
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
TFOOT(
|
TFOOT(
|
||||||
TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"])))
|
TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"])))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -133,41 +148,35 @@ class UserPageTheme extends Themelet
|
|||||||
$page->add_block(new Block("Login", $html, "left", 90));
|
$page->add_block(new Block("Login", $html, "left", 90));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _ip_list(string $name, array $ips)
|
||||||
|
{
|
||||||
|
$td = TD("$name: ");
|
||||||
|
$n = 0;
|
||||||
|
foreach ($ips as $ip => $count) {
|
||||||
|
$td->appendChild(BR());
|
||||||
|
$td->appendChild("$ip ($count)");
|
||||||
|
if (++$n >= 20) {
|
||||||
|
$td->appendChild(BR());
|
||||||
|
$td->appendChild("...");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $td;
|
||||||
|
}
|
||||||
|
|
||||||
public function display_ip_list(Page $page, array $uploads, array $comments, array $events)
|
public function display_ip_list(Page $page, array $uploads, array $comments, array $events)
|
||||||
{
|
{
|
||||||
$html = "<table id='ip-history'>";
|
$html = TABLE(
|
||||||
$html .= "<tr><td>Uploaded from: ";
|
["id"=>"ip-history"],
|
||||||
$n = 0;
|
TR(
|
||||||
foreach ($uploads as $ip => $count) {
|
$this->_ip_list("Uploaded from", $uploads),
|
||||||
$html .= '<br>'.$ip.' ('.$count.')';
|
$this->_ip_list("Commented from", $comments),
|
||||||
if (++$n >= 20) {
|
$this->_ip_list("Logged Events", $events)
|
||||||
$html .= "<br>...";
|
),
|
||||||
break;
|
TR(
|
||||||
}
|
TD(["colspan"=>"3"], "(Most recent at top)")
|
||||||
}
|
)
|
||||||
|
);
|
||||||
$html .= "</td><td>Commented from:";
|
|
||||||
$n = 0;
|
|
||||||
foreach ($comments as $ip => $count) {
|
|
||||||
$html .= '<br>'.$ip.' ('.$count.')';
|
|
||||||
if (++$n >= 20) {
|
|
||||||
$html .= "<br>...";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= "</td><td>Logged Events:";
|
|
||||||
$n = 0;
|
|
||||||
foreach ($events as $ip => $count) {
|
|
||||||
$html .= '<br>'.$ip.' ('.$count.')';
|
|
||||||
if (++$n >= 20) {
|
|
||||||
$html .= "<br>...";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= "</td></tr>";
|
|
||||||
$html .= "<tr><td colspan='3'>(Most recent at top)</td></tr></table>";
|
|
||||||
|
|
||||||
$page->add_block(new Block("IPs", $html, "main", 70));
|
$page->add_block(new Block("IPs", $html, "main", 70));
|
||||||
}
|
}
|
||||||
@ -187,92 +196,84 @@ class UserPageTheme extends Themelet
|
|||||||
public function build_options(User $duser, UserOptionsBuildingEvent $event)
|
public function build_options(User $duser, UserOptionsBuildingEvent $event)
|
||||||
{
|
{
|
||||||
global $config, $user;
|
global $config, $user;
|
||||||
$html = "";
|
$html = emptyHTML();
|
||||||
if ($duser->id != $config->get_int('anon_id')) { //justa fool-admin protection so they dont mess around with anon users.
|
|
||||||
|
|
||||||
|
// just a fool-admin protection so they dont mess around with anon users.
|
||||||
|
if ($duser->id != $config->get_int('anon_id')) {
|
||||||
if ($user->can(Permissions::EDIT_USER_NAME)) {
|
if ($user->can(Permissions::EDIT_USER_NAME)) {
|
||||||
$html .= "
|
$html->appendChild(SHM_USER_FORM(
|
||||||
<p>".make_form(make_link("user_admin/change_name"))."
|
$duser,
|
||||||
<input type='hidden' name='id' value='{$duser->id}'>
|
"user_admin/change_name",
|
||||||
<table class='form'>
|
"Change Name",
|
||||||
<thead><tr><th colspan='2'>Change Name</th></tr></thead>
|
TBODY(TR(
|
||||||
<tbody><tr><th>New name</th><td><input type='text' name='name' value='".html_escape($duser->name)."'></td></tr></tbody>
|
TH("New name"),
|
||||||
<tfoot><tr><td colspan='2'><input type='Submit' value='Set'></td></tr></tfoot>
|
TD(INPUT(["type"=>'text', "name"=>'name', "value"=>$duser->name]))
|
||||||
</table>
|
)),
|
||||||
</form>
|
"Set"
|
||||||
</p>";
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= "
|
$html->appendChild(SHM_USER_FORM(
|
||||||
<p>".make_form(make_link("user_admin/change_pass"))."
|
$duser,
|
||||||
<input type='hidden' name='id' value='{$duser->id}'>
|
"user_admin/change_pass",
|
||||||
<table class='form'>
|
"Change Password",
|
||||||
<thead>
|
TBODY(
|
||||||
<tr><th colspan='2'>Change Password</th></tr>
|
TR(
|
||||||
</thead>
|
TH("Password"),
|
||||||
<tbody>
|
TD(INPUT(["type"=>'password', "name"=>'pass1', "autocomplete"=>'new-password']))
|
||||||
<tr><th>Password</th><td><input type='password' name='pass1' autocomplete='new-password'></td></tr>
|
),
|
||||||
<tr><th>Repeat Password</th><td><input type='password' name='pass2' autocomplete='new-password'></td></tr>
|
TR(
|
||||||
</tbody>
|
TH("Repeat Password"),
|
||||||
<tfoot>
|
TD(INPUT(["type"=>'password', "name"=>'pass2', "autocomplete"=>'new-password']))
|
||||||
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
|
),
|
||||||
</tfoot>
|
),
|
||||||
</table>
|
"Set"
|
||||||
</form>
|
));
|
||||||
</p>
|
|
||||||
<p>".make_form(make_link("user_admin/change_email"))."
|
|
||||||
<input type='hidden' name='id' value='{$duser->id}'>
|
|
||||||
<table class='form'>
|
|
||||||
<thead><tr><th colspan='2'>Change Email</th></tr></thead>
|
|
||||||
<tbody><tr><th>Address</th><td><input type='text' name='address' value='".html_escape($duser->email)."' autocomplete='email' inputmode='email'></td></tr></tbody>
|
|
||||||
<tfoot><tr><td colspan='2'><input type='Submit' value='Set'></td></tr></tfoot>
|
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
</p>";
|
|
||||||
|
|
||||||
$i_user_id = int_escape($duser->id);
|
$html->appendChild(SHM_USER_FORM(
|
||||||
|
$duser,
|
||||||
|
"user_admin/change_email",
|
||||||
|
"Change Email",
|
||||||
|
TBODY(TR(
|
||||||
|
TH("Address"),
|
||||||
|
TD(INPUT(["type"=>'text', "name"=>'address', "value"=>$duser->email, "autocomplete"=>'email', "inputmode"=>'email']))
|
||||||
|
)),
|
||||||
|
"Set"
|
||||||
|
));
|
||||||
|
|
||||||
if ($user->can(Permissions::EDIT_USER_CLASS)) {
|
if ($user->can(Permissions::EDIT_USER_CLASS)) {
|
||||||
global $_shm_user_classes;
|
global $_shm_user_classes;
|
||||||
$class_html = "";
|
$select = SELECT(["name"=>"class"]);
|
||||||
foreach ($_shm_user_classes as $name => $values) {
|
foreach ($_shm_user_classes as $name => $values) {
|
||||||
$h_name = html_escape($name);
|
$select->appendChild(
|
||||||
$h_title = html_escape(ucwords($name));
|
OPTION(["value"=>$name, "selected"=>$name == $duser->class->name], ucwords($name))
|
||||||
$h_selected = ($name == $duser->class->name ? " selected" : "");
|
);
|
||||||
$class_html .= "<option value='$h_name'$h_selected>$h_title</option>\n";
|
|
||||||
}
|
}
|
||||||
$html .= "
|
$html->appendChild(SHM_USER_FORM(
|
||||||
<p>".make_form(make_link("user_admin/change_class"))."
|
$duser,
|
||||||
<input type='hidden' name='id' value='$i_user_id'>
|
"user_admin/change_class",
|
||||||
<table style='width: 300px;'>
|
"Change Class",
|
||||||
<thead><tr><th colspan='2'>Change Class</th></tr></thead>
|
TBODY(TR(TD($select))),
|
||||||
<tbody><tr><td><select name='class'>$class_html</select></td></tr></tbody>
|
"Set"
|
||||||
<tfoot><tr><td><input type='submit' value='Set'></td></tr></tfoot>
|
));
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
</p>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->can(Permissions::DELETE_USER)) {
|
if ($user->can(Permissions::DELETE_USER)) {
|
||||||
$html .= "
|
$html->appendChild(SHM_USER_FORM(
|
||||||
<p>".make_form(make_link("user_admin/delete_user"))."
|
$duser,
|
||||||
<input type='hidden' name='id' value='$i_user_id'>
|
"user_admin/delete_user",
|
||||||
<table style='width: 300px;'>
|
"Delete User",
|
||||||
<thead>
|
TBODY(
|
||||||
<tr><th colspan='2'>Delete User</th></tr>
|
TR(TD(INPUT(["type"=>'checkbox', "name"=>'with_images'], "Delete images"))),
|
||||||
</thead>
|
TR(TD(INPUT(["type"=>'checkbox', "name"=>'with_comments'], "Delete comments"))),
|
||||||
<tbody>
|
),
|
||||||
<tr><td><input type='checkbox' name='with_images'> Delete images</td></tr>
|
TFOOT(
|
||||||
<tr><td><input type='checkbox' name='with_comments'> Delete comments</td></tr>
|
TR(TD(INPUT(["type"=>'button', "class"=>'shm-unlocker', "data-unlock-sel"=>'.deluser', "value"=>'Unlock']))),
|
||||||
</tbody>
|
TR(TD(INPUT(["type"=>'submit', "class"=>'deluser', "value"=>'Delete User', "disabled"=>'true']))),
|
||||||
<tfoot>
|
)
|
||||||
<tr><td><input type='button' class='shm-unlocker' data-unlock-sel='.deluser' value='Unlock'></td></tr>
|
));
|
||||||
<tr><td><input type='submit' class='deluser' value='Delete User' disabled='true'/></td></tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
</p>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($event->parts as $part) {
|
foreach ($event->parts as $part) {
|
||||||
$html .= $part;
|
$html .= $part;
|
||||||
}
|
}
|
||||||
@ -283,25 +284,21 @@ class UserPageTheme extends Themelet
|
|||||||
public function get_help_html()
|
public function get_help_html()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
$output = '<p>Search for images posted by particular individuals.</p>
|
$output = emptyHTML(P("Search for images posted by particular individuals."));
|
||||||
<div class="command_example">
|
$output->appendChild(SHM_COMMAND_EXAMPLE(
|
||||||
<pre>poster=username</pre>
|
"poster=username",
|
||||||
<p>Returns images posted by "username".</p>
|
'Returns images posted by "username".'
|
||||||
</div>
|
));
|
||||||
<div class="command_example">
|
$output->appendChild(SHM_COMMAND_EXAMPLE(
|
||||||
<pre>poster_id=123</pre>
|
"poster_id=123",
|
||||||
<p>Returns images posted by user 123.</p>
|
'Returns images posted by user 123.'
|
||||||
</div>
|
));
|
||||||
';
|
|
||||||
|
|
||||||
|
|
||||||
if ($user->can(Permissions::VIEW_IP)) {
|
if ($user->can(Permissions::VIEW_IP)) {
|
||||||
$output .="
|
$output->appendChild(SHM_COMMAND_EXAMPLE(
|
||||||
<div class=\"command_example\">
|
"poster_ip=127.0.0.1",
|
||||||
<pre>poster_ip=127.0.0.1</pre>
|
"Returns images posted from IP 127.0.0.1."
|
||||||
<p>Returns images posted from IP 127.0.0.1.</p>
|
));
|
||||||
</div>
|
|
||||||
";
|
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user