forms
This commit is contained in:
parent
50f3d04f0c
commit
4bd1d8b6ee
@ -32,7 +32,7 @@ class Block
|
|||||||
/**
|
/**
|
||||||
* How far down the section the block should appear, higher
|
* How far down the section the block should appear, higher
|
||||||
* numbers appear lower. The scale is 0-100 by convention,
|
* numbers appear lower. The scale is 0-100 by convention,
|
||||||
* though any number or string will work.
|
* though any number will work.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
@ -711,6 +711,11 @@ function SHM_SIMPLE_FORM($target, ...$children)
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SHM_SUBMIT(string $text)
|
||||||
|
{
|
||||||
|
return INPUT(["type"=>"submit", "value"=>$text]);
|
||||||
|
}
|
||||||
|
|
||||||
function SHM_COMMAND_EXAMPLE(string $ex, string $desc)
|
function SHM_COMMAND_EXAMPLE(string $ex, string $desc)
|
||||||
{
|
{
|
||||||
return DIV(
|
return DIV(
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
use function MicroHTML\INPUT;
|
||||||
|
|
||||||
class AdminPageTheme extends Themelet
|
class AdminPageTheme extends Themelet
|
||||||
{
|
{
|
||||||
@ -50,10 +51,11 @@ class AdminPageTheme extends Themelet
|
|||||||
}
|
}
|
||||||
$page->add_block(new Block("Misc Admin Tools", $html));
|
$page->add_block(new Block("Misc Admin Tools", $html));
|
||||||
|
|
||||||
$html = make_form(make_link("admin/set_tag_case"), "POST");
|
$html = (string)SHM_SIMPLE_FORM(
|
||||||
$html .= "<input type='text' name='tag' placeholder='Enter tag with correct case' class='autocomplete_tags' autocomplete='off'>";
|
make_link("admin/set_tag_case"),
|
||||||
$html .= "<input type='submit' value='Set Tag Case'>";
|
INPUT(["type"=>'text', "name"=>'tag', "placeholder"=>'Enter tag with correct case', "class"=>'autocomplete_tags', "autocomplete"=>'off']),
|
||||||
$html .= "</form>\n";
|
SHM_SUBMIT('Set Tag Case'),
|
||||||
|
);
|
||||||
$page->add_block(new Block("Set Tag Case", $html));
|
$page->add_block(new Block("Set Tag Case", $html));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
use function MicroHTML\BR;
|
||||||
|
use function MicroHTML\BUTTON;
|
||||||
|
use function MicroHTML\INPUT;
|
||||||
|
|
||||||
class ApprovalTheme extends Themelet
|
class ApprovalTheme extends Themelet
|
||||||
{
|
{
|
||||||
public function get_image_admin_html(Image $image)
|
public function get_image_admin_html(Image $image)
|
||||||
{
|
{
|
||||||
if ($image->approved===true) {
|
if ($image->approved===true) {
|
||||||
$html = "
|
$html = SHM_SIMPLE_FORM(
|
||||||
".make_form(make_link('disapprove_image/'.$image->id), 'POST')."
|
make_link('disapprove_image/'.$image->id),
|
||||||
<input type='hidden' name='image_id' value='$image->id'>
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]),
|
||||||
<input type='submit' value='Disapprove'>
|
SHM_SUBMIT("Disapprove")
|
||||||
</form>
|
);
|
||||||
";
|
|
||||||
} else {
|
} else {
|
||||||
$html = "
|
$html = SHM_SIMPLE_FORM(
|
||||||
".make_form(make_link('approve_image/'.$image->id), 'POST')."
|
make_link('approve_image/'.$image->id),
|
||||||
<input type='hidden' name='image_id' value='$image->id'>
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]),
|
||||||
<input type='submit' value='Approve'>
|
SHM_SUBMIT("Approve")
|
||||||
</form>
|
);
|
||||||
";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return (string)$html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -49,10 +50,12 @@ class ApprovalTheme extends Themelet
|
|||||||
{
|
{
|
||||||
global $page;
|
global $page;
|
||||||
|
|
||||||
$html = make_form(make_link("admin/approval"), "POST");
|
$html = (string)SHM_SIMPLE_FORM(
|
||||||
$html .= "<button name='approval_action' value='approve_all'>Approve All Images</button><br/>";
|
make_link("admin/approval"),
|
||||||
$html .= "<button name='approval_action' value='disapprove_all'>Disapprove All Images</button>";
|
BUTTON(["name"=>'approval_action', "value"=>'approve_all'], "Approve All Images"),
|
||||||
$html .= "</form>\n";
|
BR(),
|
||||||
|
BUTTON(["name"=>'approval_action', "value"=>'disapprove_all'], "Disapprove All Images"),
|
||||||
|
);
|
||||||
$page->add_block(new Block("Approval", $html));
|
$page->add_block(new Block("Approval", $html));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
use function MicroHTML\INPUT;
|
||||||
|
|
||||||
class FeaturedTheme extends Themelet
|
class FeaturedTheme extends Themelet
|
||||||
{
|
{
|
||||||
@ -9,14 +10,11 @@ class FeaturedTheme extends Themelet
|
|||||||
|
|
||||||
public function get_buttons_html(int $image_id): string
|
public function get_buttons_html(int $image_id): string
|
||||||
{
|
{
|
||||||
global $user;
|
return (string)SHM_SIMPLE_FORM(
|
||||||
return "
|
make_link("featured_image/set"),
|
||||||
".make_form(make_link("featured_image/set"))."
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]),
|
||||||
".$user->get_auth_html()."
|
INPUT(["type"=>'submit', "value"=>'Feature This']),
|
||||||
<input type='hidden' name='image_id' value='{$image_id}'>
|
);
|
||||||
<input type='submit' value='Feature This'>
|
|
||||||
</form>
|
|
||||||
";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build_featured_html(Image $image, ?string $query=null): string
|
public function build_featured_html(Image $image, ?string $query=null): string
|
||||||
|
@ -136,7 +136,6 @@ class Media extends Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
@ -145,11 +144,9 @@ class Media extends Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event)
|
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if ($user->can(Permissions::RESCAN_MEDIA)) {
|
if ($user->can(Permissions::RESCAN_MEDIA)) {
|
||||||
$event->add_action("bulk_media_rescan", "Scan Media Properties");
|
$event->add_action("bulk_media_rescan", "Scan Media Properties");
|
||||||
}
|
}
|
||||||
@ -282,11 +279,9 @@ class Media extends Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onTagTermParse(TagTermParseEvent $event)
|
public function onTagTermParse(TagTermParseEvent $event)
|
||||||
{
|
{
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
|
||||||
if (preg_match(self::CONTENT_SEARCH_TERM_REGEX, strtolower($event->term), $matches) && $event->parse) {
|
if (preg_match(self::CONTENT_SEARCH_TERM_REGEX, strtolower($event->term), $matches) && $event->parse) {
|
||||||
$event->metatag = true;
|
$event->metatag = true;
|
||||||
}
|
}
|
||||||
@ -466,7 +461,7 @@ class Media extends Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function determine_ext(String $format): String
|
public static function determine_ext(string $format): string
|
||||||
{
|
{
|
||||||
$format = self::normalize_format($format);
|
$format = self::normalize_format($format);
|
||||||
switch ($format) {
|
switch ($format) {
|
||||||
@ -599,8 +594,8 @@ class Media extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function image_resize_convert(
|
public static function image_resize_convert(
|
||||||
String $input_path,
|
string $input_path,
|
||||||
String $input_type,
|
string $input_type,
|
||||||
int $new_width,
|
int $new_width,
|
||||||
int $new_height,
|
int $new_height,
|
||||||
string $output_filename,
|
string $output_filename,
|
||||||
@ -687,7 +682,7 @@ class Media extends Extension
|
|||||||
* @throws InsufficientMemoryException if the estimated memory usage exceeds the memory limit.
|
* @throws InsufficientMemoryException if the estimated memory usage exceeds the memory limit.
|
||||||
*/
|
*/
|
||||||
public static function image_resize_gd(
|
public static function image_resize_gd(
|
||||||
String $image_filename,
|
string $image_filename,
|
||||||
array $info,
|
array $info,
|
||||||
int $new_width,
|
int $new_width,
|
||||||
int $new_height,
|
int $new_height,
|
||||||
@ -847,7 +842,7 @@ class Media extends Extension
|
|||||||
* @param String $image_filename The path of the file to check.
|
* @param String $image_filename The path of the file to check.
|
||||||
* @return bool true if the file is an animated gif, false if it is not.
|
* @return bool true if the file is an animated gif, false if it is not.
|
||||||
*/
|
*/
|
||||||
public static function is_animated_gif(String $image_filename): bool
|
public static function is_animated_gif(string $image_filename): bool
|
||||||
{
|
{
|
||||||
$is_anim_gif = 0;
|
$is_anim_gif = 0;
|
||||||
if (($fh = @fopen($image_filename, 'rb'))) {
|
if (($fh = @fopen($image_filename, 'rb'))) {
|
||||||
@ -865,7 +860,7 @@ class Media extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static function compare_file_bytes(String $file_name, array $comparison): bool
|
private static function compare_file_bytes(string $file_name, array $comparison): bool
|
||||||
{
|
{
|
||||||
$size = filesize($file_name);
|
$size = filesize($file_name);
|
||||||
if ($size < count($comparison)) {
|
if ($size < count($comparison)) {
|
||||||
@ -897,17 +892,17 @@ class Media extends Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function is_animated_webp(String $image_filename): bool
|
public static function is_animated_webp(string $image_filename): bool
|
||||||
{
|
{
|
||||||
return self::compare_file_bytes($image_filename, self::WEBP_ANIMATION_HEADER);
|
return self::compare_file_bytes($image_filename, self::WEBP_ANIMATION_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function is_lossless_webp(String $image_filename): bool
|
public static function is_lossless_webp(string $image_filename): bool
|
||||||
{
|
{
|
||||||
return self::compare_file_bytes($image_filename, self::WEBP_LOSSLESS_HEADER);
|
return self::compare_file_bytes($image_filename, self::WEBP_LOSSLESS_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function supports_alpha(string $format)
|
public static function supports_alpha(string $format): bool
|
||||||
{
|
{
|
||||||
return in_array(self::normalize_format($format), self::ALPHA_FORMATS);
|
return in_array(self::normalize_format($format), self::ALPHA_FORMATS);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
use function MicroHTML\INPUT;
|
||||||
|
use function MicroHTML\TABLE;
|
||||||
|
use function MicroHTML\TR;
|
||||||
|
use function MicroHTML\TH;
|
||||||
|
use function MicroHTML\TD;
|
||||||
|
use function MicroHTML\SELECT;
|
||||||
|
use function MicroHTML\OPTION;
|
||||||
|
|
||||||
class MediaTheme extends Themelet
|
class MediaTheme extends Themelet
|
||||||
{
|
{
|
||||||
@ -6,27 +13,31 @@ class MediaTheme extends Themelet
|
|||||||
{
|
{
|
||||||
global $page;
|
global $page;
|
||||||
|
|
||||||
$html = "Use this to force scanning for media properties.";
|
$select = SELECT(["name"=>"media_rescan_type"]);
|
||||||
$html .= make_form(make_link("admin/media_rescan"));
|
$select->appendChild(OPTION(["value"=>""], "All"));
|
||||||
$html .= "<table class='form'>";
|
|
||||||
$html .= "<tr><th>Image Type</th><td><select name='media_rescan_type'><option value=''>All</option>";
|
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$html .= "<option value='".$type["ext"]."'>".$type["ext"]." (".$type["count"].")</option>";
|
$select->appendChild(OPTION(["value"=>$type["ext"]], "{$type["ext"]} ({$type["count"]})"));
|
||||||
}
|
}
|
||||||
$html .= "</select></td></tr>";
|
|
||||||
$html .= "<tr><td colspan='2'><input type='submit' value='Scan Media Information'></td></tr>";
|
$html = (string)SHM_SIMPLE_FORM(
|
||||||
$html .= "</table></form>\n";
|
make_link("admin/media_rescan"),
|
||||||
|
"Use this to force scanning for media properties.",
|
||||||
|
TABLE(
|
||||||
|
["class"=>"form"],
|
||||||
|
TR(TH("Image Type"), TD($select)),
|
||||||
|
TR(TD(["colspan"=>"2"], SHM_SUBMIT('Scan Media Information')))
|
||||||
|
)
|
||||||
|
);
|
||||||
$page->add_block(new Block("Media Tools", $html));
|
$page->add_block(new Block("Media Tools", $html));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_buttons_html(int $image_id): string
|
public function get_buttons_html(int $image_id): string
|
||||||
{
|
{
|
||||||
return "
|
return (string)SHM_SIMPLE_FORM(
|
||||||
".make_form(make_link("media_rescan/"))."
|
make_link("media_rescan/"),
|
||||||
<input type='hidden' name='image_id' value='$image_id'>
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]),
|
||||||
<input type='submit' value='Scan Media Properties'>
|
SHM_SUBMIT('Scan Media Properties'),
|
||||||
</form>
|
);
|
||||||
";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_help_html()
|
public function get_help_html()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
use function MicroHTML\INPUT;
|
||||||
|
|
||||||
class RegenThumbTheme extends Themelet
|
class RegenThumbTheme extends Themelet
|
||||||
{
|
{
|
||||||
@ -7,12 +8,11 @@ class RegenThumbTheme extends Themelet
|
|||||||
*/
|
*/
|
||||||
public function get_buttons_html(int $image_id): string
|
public function get_buttons_html(int $image_id): string
|
||||||
{
|
{
|
||||||
return "
|
return (string)SHM_SIMPLE_FORM(
|
||||||
".make_form(make_link("regen_thumb/one"))."
|
make_link("regen_thumb/one"),
|
||||||
<input type='hidden' name='image_id' value='$image_id'>
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]),
|
||||||
<input type='submit' value='Regenerate Thumbnail'>
|
SHM_SUBMIT('Regenerate Thumbnail')
|
||||||
</form>
|
);
|
||||||
";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
use function MicroHTML\INPUT;
|
||||||
|
|
||||||
class ReportImageTheme extends Themelet
|
class ReportImageTheme extends Themelet
|
||||||
{
|
{
|
||||||
@ -88,14 +89,12 @@ class ReportImageTheme extends Themelet
|
|||||||
|
|
||||||
public function get_nuller(User $duser)
|
public function get_nuller(User $duser)
|
||||||
{
|
{
|
||||||
global $user, $page;
|
global $page;
|
||||||
$html = "
|
$html = (string)SHM_SIMPLE_FORM(
|
||||||
<form action='".make_link("image_report/remove_reports_by")."' method='POST'>
|
make_link("image_report/remove_reports_by"),
|
||||||
".$user->get_auth_html()."
|
INPUT(["type"=>'hidden', "name"=>'user_id', "value"=>$duser->id]),
|
||||||
<input type='hidden' name='user_id' value='{$duser->id}'>
|
SHM_SUBMIT('Delete all reports by this user')
|
||||||
<input type='submit' value='Delete all reports by this user'>
|
);
|
||||||
</form>
|
|
||||||
";
|
|
||||||
$page->add_block(new Block("Reports", $html, "main", 80));
|
$page->add_block(new Block("Reports", $html, "main", 80));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
use function MicroHTML\INPUT;
|
||||||
|
use function MicroHTML\LABEL;
|
||||||
|
use function MicroHTML\BR;
|
||||||
|
|
||||||
class Rule34Theme extends Themelet
|
class Rule34Theme extends Themelet
|
||||||
{
|
{
|
||||||
public function show_comic_changer(User $duser, bool $current_state): void
|
public function show_comic_changer(User $duser, bool $current_state): void
|
||||||
{
|
{
|
||||||
global $page;
|
global $page;
|
||||||
$checked = $current_state ? 'checked="checked"' : '';
|
$html = (string)SHM_SIMPLE_FORM(
|
||||||
$html = make_form(make_link("rule34/comic_admin"), "POST");
|
make_link("rule34/comic_admin"),
|
||||||
$html .= "<input type='hidden' name='user_id' value='{$duser->id}'>";
|
INPUT(["type"=>'hidden', "name"=>'user_id', "value"=>$duser->id]),
|
||||||
$html .= "<label><input type='checkbox' name='is_admin' $checked> Comic Admin</label>";
|
LABEL(INPUT(["type"=>'checkbox', "name"=>'is_admin', "checked"=>$current_state]), "Comic Admin"),
|
||||||
$html .= "<br/><input type='submit' id='Set'>";
|
BR(),
|
||||||
$html .= "</form>\n";
|
SHM_SUBMIT("Set")
|
||||||
|
);
|
||||||
|
|
||||||
$page->add_block(new Block("Rule34 Comic Options", $html));
|
$page->add_block(new Block("Rule34 Comic Options", $html));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user