requestcontext stuff is messy, go back to globals :(
This commit is contained in:
@ -23,12 +23,10 @@ class RandomImage implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("random_image")) {
|
||||
global $config;
|
||||
global $database;
|
||||
|
||||
if($event->count_args() == 1) {
|
||||
$action = $event->get_arg(0);
|
||||
$search_terms = array();
|
||||
@ -37,18 +35,18 @@ class RandomImage implements Extension {
|
||||
$action = $event->get_arg(0);
|
||||
$search_terms = explode(' ', $event->get_arg(1));
|
||||
}
|
||||
$image = Image::by_random($config, $database, $search_terms);
|
||||
$image = Image::by_random($search_terms);
|
||||
|
||||
if($event->get_arg(0) == "download") {
|
||||
if(!is_null($image)) {
|
||||
$event->page->set_mode("data");
|
||||
$event->page->set_type("image/jpeg");
|
||||
$event->page->set_data(file_get_contents($image->get_image_filename()));
|
||||
$page->set_mode("data");
|
||||
$page->set_type("image/jpeg");
|
||||
$page->set_data(file_get_contents($image->get_image_filename()));
|
||||
}
|
||||
}
|
||||
if($event->get_arg(0) == "view") {
|
||||
if(!is_null($image)) {
|
||||
send_event(new DisplayingImageEvent($image, $event->page));
|
||||
send_event(new DisplayingImageEvent($image, $page));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,11 +58,10 @@ class RandomImage implements Extension {
|
||||
}
|
||||
|
||||
if($event instanceof PostListBuildingEvent) {
|
||||
global $config, $database;
|
||||
if($config->get_bool("show_random_block")) {
|
||||
$image = Image::by_random($config, $database, $event->search_terms);
|
||||
$image = Image::by_random($event->search_terms);
|
||||
if(!is_null($image)) {
|
||||
$this->theme->display_random($event->page, $image);
|
||||
$this->theme->display_random($page, $image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user