2007-04-16 11:58:25 +00:00
|
|
|
<?php
|
|
|
|
|
2007-11-14 10:11:56 +00:00
|
|
|
class ImageInfoBoxBuildingEvent extends Event {
|
|
|
|
var $parts = array();
|
|
|
|
var $image;
|
|
|
|
var $user;
|
|
|
|
|
|
|
|
public function ImageInfoBoxBuildingEvent($image, $user) {
|
|
|
|
$this->image = $image;
|
|
|
|
$this->user = $user;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function add_part($html, $position=50) {
|
|
|
|
while(isset($this->parts[$position])) $position++;
|
|
|
|
$this->parts[$position] = $html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ImageInfoSetEvent extends Event {
|
|
|
|
var $image_id;
|
|
|
|
|
|
|
|
public function ImageInfoSetEvent($image_id) {
|
|
|
|
$this->image_id = int_escape($image_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-16 11:58:25 +00:00
|
|
|
class ViewImage extends Extension {
|
2007-07-16 13:15:56 +00:00
|
|
|
var $theme;
|
2007-07-16 14:35:49 +00:00
|
|
|
|
2007-04-16 11:58:25 +00:00
|
|
|
public function receive_event($event) {
|
2007-07-16 13:15:56 +00:00
|
|
|
if(is_null($this->theme)) $this->theme = get_theme_object("view", "ViewTheme");
|
|
|
|
|
2007-07-17 07:45:35 +00:00
|
|
|
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "post") && ($event->get_arg(0) == "view")) {
|
2007-04-16 11:58:25 +00:00
|
|
|
$image_id = int_escape($event->get_arg(1));
|
|
|
|
|
|
|
|
global $database;
|
|
|
|
$image = $database->get_image($image_id);
|
|
|
|
|
|
|
|
if(!is_null($image)) {
|
2007-07-17 07:45:35 +00:00
|
|
|
send_event(new DisplayingImageEvent($image, $event->page));
|
2007-04-16 11:58:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-07-28 20:30:01 +00:00
|
|
|
$this->theme->display_error($event->page, "Image not found", "No image in the database has the ID #$image_id");
|
2007-04-16 11:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-14 10:11:56 +00:00
|
|
|
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "post") && ($event->get_arg(0) == "set")) {
|
|
|
|
$image_id = int_escape($_POST['image_id']);
|
|
|
|
|
|
|
|
send_event(new ImageInfoSetEvent($image_id));
|
|
|
|
|
|
|
|
$query = $_POST['query'];
|
|
|
|
$event->page->set_mode("redirect");
|
|
|
|
$event->page->set_redirect(make_link("post/view/$image_id", $query));
|
|
|
|
}
|
|
|
|
|
2007-04-16 11:58:25 +00:00
|
|
|
if(is_a($event, 'DisplayingImageEvent')) {
|
2008-02-06 17:33:08 +00:00
|
|
|
global $user;
|
|
|
|
$iibbe = new ImageInfoBoxBuildingEvent($event->get_image(), $user);
|
2007-11-14 10:11:56 +00:00
|
|
|
send_event($iibbe);
|
|
|
|
ksort($iibbe->parts);
|
|
|
|
$this->theme->display_page($event->page, $event->get_image(), $iibbe->parts);
|
2007-04-16 11:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
add_event_listener(new ViewImage());
|
|
|
|
?>
|