bulk thumb regen
This commit is contained in:
parent
2666d83579
commit
53c6f6df30
@ -15,13 +15,24 @@
|
|||||||
|
|
||||||
class RegenThumb extends Extension {
|
class RegenThumb extends Extension {
|
||||||
public function onPageRequest(PageRequestEvent $event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $page, $user;
|
global $database, $page, $user;
|
||||||
|
|
||||||
if($event->page_matches("regen_thumb") && $user->can("delete_image") && isset($_POST['image_id'])) {
|
if($event->page_matches("regen_thumb/one") && $user->can("delete_image") && isset($_POST['image_id'])) {
|
||||||
$image = Image::by_id(int_escape($_POST['image_id']));
|
$image = Image::by_id(int_escape($_POST['image_id']));
|
||||||
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true));
|
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true));
|
||||||
$this->theme->display_results($page, $image);
|
$this->theme->display_results($page, $image);
|
||||||
}
|
}
|
||||||
|
if($event->page_matches("regen_thumb/mass") && $user->can("delete_image") && isset($_POST['tags'])) {
|
||||||
|
$tags = Tag::explode(strtolower($_POST['tags']), false);
|
||||||
|
$images = Image::find_images(0, 10000, $tags);
|
||||||
|
|
||||||
|
foreach($images as $image) {
|
||||||
|
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
$page->set_mode("redirect");
|
||||||
|
$page->set_redirect(make_link("post/list"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
|
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
|
||||||
@ -30,5 +41,12 @@ class RegenThumb extends Extension {
|
|||||||
$event->add_part($this->theme->get_buttons_html($event->image->id));
|
$event->add_part($this->theme->get_buttons_html($event->image->id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onPostListBuilding(PostListBuildingEvent $event) {
|
||||||
|
global $user;
|
||||||
|
if($user->can("delete_image") && !empty($event->search_terms)) {
|
||||||
|
$event->add_control($this->theme->mtr_html(implode(" ", $event->search_terms)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class RegenThumbTheme extends Themelet {
|
|||||||
*/
|
*/
|
||||||
public function get_buttons_html($image_id) {
|
public function get_buttons_html($image_id) {
|
||||||
return "
|
return "
|
||||||
".make_form(make_link("regen_thumb"))."
|
".make_form(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'>
|
<input type='submit' value='Regenerate Thumbnail'>
|
||||||
</form>
|
</form>
|
||||||
@ -29,5 +29,15 @@ class RegenThumbTheme extends Themelet {
|
|||||||
$page->add_block(new NavBlock());
|
$page->add_block(new NavBlock());
|
||||||
$page->add_block(new Block("Thumbnail", $this->build_thumb_html($image)));
|
$page->add_block(new Block("Thumbnail", $this->build_thumb_html($image)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function mtr_html($terms) {
|
||||||
|
$h_terms = html_escape($terms);
|
||||||
|
$html = make_form(make_link("regen_thumb/mass"), "POST") . "
|
||||||
|
<input type='hidden' name='tags' value='$h_terms'>
|
||||||
|
<input type='submit' value='Regen all thumbs' onclick='return confirm(\"This can use a lot of CPU time.\\nAre you sure you want to do this?\")'>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user