git-svn-id: file:///home/shish/svn/shimmie2/trunk@312 7f39781d-f577-437e-ae19-be835c7a54ca
		
			
				
	
	
		
			30 lines
		
	
	
		
			750 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			30 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());
 | |
| ?>
 |