2007-04-16 11:58:25 +00:00
|
|
|
<?php
|
2009-08-20 22:37:17 +00:00
|
|
|
/*
|
2008-04-11 06:12:07 +00:00
|
|
|
* Name: Regen Thumb
|
|
|
|
* Author: Shish <webmaster@shishnet.org>
|
2012-02-08 02:52:11 +00:00
|
|
|
* Link: http://code.shishnet.org/shimmie2/
|
2008-04-11 06:12:07 +00:00
|
|
|
* License: GPLv2
|
|
|
|
* Description: Regenerate a thumbnail image
|
2009-01-16 08:18:41 +00:00
|
|
|
* Documentation:
|
|
|
|
* This adds a button in the image control section on an
|
|
|
|
* image's view page, which allows an admin to regenerate
|
|
|
|
* an image's thumbnail; useful for instance if the first
|
|
|
|
* attempt failed due to lack of memory, and memory has
|
|
|
|
* since been increased.
|
2008-04-11 06:12:07 +00:00
|
|
|
*/
|
2007-04-16 11:58:25 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class RegenThumb extends Extension
|
|
|
|
{
|
|
|
|
public function onPageRequest(PageRequestEvent $event)
|
|
|
|
{
|
|
|
|
global $database, $page, $user;
|
2007-06-30 01:19:11 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if ($event->page_matches("regen_thumb/one") && $user->can("delete_image") && isset($_POST['image_id'])) {
|
|
|
|
$image = Image::by_id(int_escape($_POST['image_id']));
|
|
|
|
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true));
|
|
|
|
$database->cache->delete("thumb-block:{$image->id}");
|
|
|
|
$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);
|
2017-06-01 19:44:17 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($images as $image) {
|
|
|
|
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true));
|
|
|
|
$database->cache->delete("thumb-block:{$image->id}");
|
|
|
|
}
|
2017-06-01 19:44:17 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->set_mode("redirect");
|
|
|
|
$page->set_redirect(make_link("post/list"));
|
|
|
|
}
|
|
|
|
}
|
2007-04-16 11:58:25 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
|
|
|
{
|
|
|
|
global $user;
|
|
|
|
if ($user->can("delete_image")) {
|
|
|
|
$event->add_part($this->theme->get_buttons_html($event->image->id));
|
|
|
|
}
|
|
|
|
}
|
2017-06-01 19:44:17 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function onPostListBuilding(PostListBuildingEvent $event)
|
|
|
|
{
|
|
|
|
global $user;
|
|
|
|
if ($user->can("delete_image") && !empty($event->search_terms)) {
|
|
|
|
$event->add_control($this->theme->mtr_html(Tag::implode($event->search_terms)));
|
|
|
|
}
|
|
|
|
}
|
2007-04-16 11:58:25 +00:00
|
|
|
}
|