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/ext/view/main.php
shish 0c5f7244db consistency
git-svn-id: file:///home/shish/svn/shimmie2/trunk@312 7f39781d-f577-437e-ae19-be835c7a54ca
2007-07-17 07:45:35 +00:00

29 lines
750 B
PHP

<?php
class ViewImage extends Extension {
var $theme;
public function receive_event($event) {
if(is_null($this->theme)) $this->theme = get_theme_object("view", "ViewTheme");
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "post") && ($event->get_arg(0) == "view")) {
$image_id = int_escape($event->get_arg(1));
global $database;
$image = $database->get_image($image_id);
if(!is_null($image)) {
send_event(new DisplayingImageEvent($image, $event->page));
}
else {
$this->theme->display_image_not_found($event->page, $image_id);
}
}
if(is_a($event, 'DisplayingImageEvent')) {
$this->theme->display_page($event->page, $event->get_image());
}
}
}
add_event_listener(new ViewImage());
?>