2020-01-26 13:19:35 +00:00
|
|
|
<?php declare(strict_types=1);
|
2020-01-26 23:12:48 +00:00
|
|
|
use function MicroHTML\INPUT;
|
2007-06-30 01:19:11 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class RegenThumbTheme extends Themelet
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Show a form which offers to regenerate the thumb of an image with ID #$image_id
|
|
|
|
*/
|
|
|
|
public function get_buttons_html(int $image_id): string
|
|
|
|
{
|
2020-01-26 23:12:48 +00:00
|
|
|
return (string)SHM_SIMPLE_FORM(
|
2020-01-30 10:31:11 +00:00
|
|
|
"regen_thumb/one",
|
2020-01-26 23:12:48 +00:00
|
|
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]),
|
|
|
|
SHM_SUBMIT('Regenerate Thumbnail')
|
|
|
|
);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2007-06-30 01:19:11 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
/**
|
|
|
|
* Show a link to the new thumbnail.
|
|
|
|
*/
|
|
|
|
public function display_results(Page $page, Image $image)
|
|
|
|
{
|
|
|
|
$page->set_title("Thumbnail Regenerated");
|
|
|
|
$page->set_heading("Thumbnail Regenerated");
|
|
|
|
$page->add_html_header("<meta http-equiv=\"cache-control\" content=\"no-cache\">");
|
|
|
|
$page->add_block(new NavBlock());
|
|
|
|
$page->add_block(new Block("Thumbnail", $this->build_thumb_html($image)));
|
|
|
|
}
|
2017-06-01 19:44:17 +00:00
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function bulk_html(): string
|
2019-06-14 12:47:50 +00:00
|
|
|
{
|
2019-06-09 18:22:48 +00:00
|
|
|
return "<label><input type='checkbox' name='bulk_regen_thumb_missing_only' id='bulk_regen_thumb_missing_only' style='width:13px' value='true' />Only missing thumbs</label>";
|
|
|
|
}
|
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function display_admin_block(): void
|
2019-06-09 18:22:48 +00:00
|
|
|
{
|
|
|
|
global $page, $database;
|
|
|
|
|
2020-06-14 16:05:55 +00:00
|
|
|
$mimes = [];
|
|
|
|
$results = $database->get_all("SELECT mime, count(*) count FROM images group by mime");
|
2019-06-09 18:22:48 +00:00
|
|
|
foreach ($results as $result) {
|
2020-06-14 16:05:55 +00:00
|
|
|
array_push($mimes, "<option value='".$result["mime"]."'>".$result["mime"]." (".$result["count"].")</option>");
|
2019-06-09 18:22:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$html = "
|
|
|
|
Will only regenerate missing thumbnails, unless force is selected. Force will override the limit and will likely take a very long time to process.
|
|
|
|
<p>".make_form(make_link("admin/regen_thumbs"))."
|
|
|
|
<table class='form'>
|
|
|
|
<tr><th><label for='regen_thumb_force'>Force</label></th><td><input type='checkbox' name='regen_thumb_force' id='regen_thumb_force' value='true' /></td></tr>
|
|
|
|
<tr><th><label for='regen_thumb_limit'>Limit</label></th><td><input type='number' name='regen_thumb_limit' id='regen_thumb_limit' value='1000' /></td></tr>
|
2020-06-14 16:05:55 +00:00
|
|
|
<tr><th><label for='regen_thumb_mime'>MIME</label></th><td>
|
|
|
|
<select name='regen_thumb_mime' id='regen_thumb_mime'>
|
2019-06-09 18:22:48 +00:00
|
|
|
<option value=''>All</option>
|
2020-06-14 16:05:55 +00:00
|
|
|
".implode($mimes)."
|
2019-06-09 18:22:48 +00:00
|
|
|
</select>
|
|
|
|
</td></tr>
|
|
|
|
<tr><td colspan='2'><input type='submit' value='Regenerate Thumbnails'></td></tr>
|
|
|
|
</table>
|
|
|
|
</form></p>
|
2019-06-14 12:47:50 +00:00
|
|
|
<p>".make_form(make_link("admin/delete_thumbs"), "POST", false, "", "return confirm('Are you sure you want to delete all thumbnails?')")."
|
2019-06-09 18:22:48 +00:00
|
|
|
<table class='form'>
|
2020-06-14 16:05:55 +00:00
|
|
|
<tr><th><label for='delete_thumb_mime'>MIME</label></th><td>
|
|
|
|
<select name='delete_thumb_mime' id='delete_thumb_mime'>
|
2019-06-09 18:22:48 +00:00
|
|
|
<option value=''>All</option>
|
2020-06-14 16:05:55 +00:00
|
|
|
".implode($mimes)."
|
2019-06-09 18:22:48 +00:00
|
|
|
</select>
|
|
|
|
</td></tr>
|
|
|
|
<tr><td colspan='2'><input type='submit' value='Delete Thumbnails'></td></tr>
|
|
|
|
</table>
|
|
|
|
</form></p>
|
|
|
|
";
|
|
|
|
$page->add_block(new Block("Regen Thumbnails", $html));
|
|
|
|
}
|
2007-06-30 01:19:11 +00:00
|
|
|
}
|