This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/contrib/regen_thumb/main.php
shish 072b22ee8f Image code moved to image class
git-svn-id: file:///home/shish/svn/shimmie2/trunk@1058 7f39781d-f577-437e-ae19-be835c7a54ca
2008-10-09 03:21:18 +00:00

34 lines
946 B
PHP

<?php
/**
* Name: Regen Thumb
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Regenerate a thumbnail image
*/
class RegenThumb implements Extension {
var $theme;
public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this);
if(($event instanceof PageRequestEvent) && $event->page_matches("regen_thumb")) {
global $user;
if($user->is_admin() && isset($_POST['image_id'])) {
global $config;
global $database;
$image = Image::by_id($config, $database, int_escape($_POST['image_id']));
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext));
$this->theme->display_results($event->page, $image);
}
}
if($event instanceof ImageAdminBlockBuildingEvent) {
if($event->user->is_admin()) {
$event->add_part($this->theme->get_buttons_html($event->image->id));
}
}
}
}
add_event_listener(new RegenThumb());
?>