From 4163432e32b951cb0ea231f5cd459a910a289df4 Mon Sep 17 00:00:00 2001 From: Shish Moom Date: Wed, 1 Jul 2009 16:52:24 -0700 Subject: [PATCH] another simpleextnsion --- contrib/regen_thumb/main.php | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/contrib/regen_thumb/main.php b/contrib/regen_thumb/main.php index 99e19a69..18df0c26 100644 --- a/contrib/regen_thumb/main.php +++ b/contrib/regen_thumb/main.php @@ -12,27 +12,22 @@ * since been increased. */ -class RegenThumb implements Extension { - var $theme; - - public function receive_event(Event $event) { +class RegenThumb extends SimpleExtension { + public function onPageRequest($event) { global $config, $database, $page, $user; - if(is_null($this->theme)) $this->theme = get_theme_object($this); - if(($event instanceof PageRequestEvent) && $event->page_matches("regen_thumb")) { - if($user->is_admin() && isset($_POST['image_id'])) { - $image = Image::by_id(int_escape($_POST['image_id'])); - send_event(new ThumbnailGenerationEvent($image->hash, $image->ext)); - $this->theme->display_results($page, $image); - } + if($event->page_matches("regen_thumb") && $user->is_admin() && isset($_POST['image_id'])) { + $image = Image::by_id(int_escape($_POST['image_id'])); + send_event(new ThumbnailGenerationEvent($image->hash, $image->ext)); + $this->theme->display_results($page, $image); } + } - if($event instanceof ImageAdminBlockBuildingEvent) { - if($user->is_admin()) { - $event->add_part($this->theme->get_buttons_html($event->image->id)); - } + public function onImageAdminBlockBuilding($event) { + global $user; + if($user->is_admin()) { + $event->add_part($this->theme->get_buttons_html($event->image->id)); } } } -add_event_listener(new RegenThumb()); ?>