Tag List to simpleext
This commit is contained in:
		
							parent
							
								
									5c2140a028
								
							
						
					
					
						commit
						f5eadb9011
					
				| @ -5,15 +5,9 @@ | |||||||
|  * Description: Show the tags in various ways |  * Description: Show the tags in various ways | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| class TagList implements Extension { | class TagList extends SimpleExtension { | ||||||
| 	var $theme = null; | 	public function onInitExt($event) { | ||||||
| 
 | 		global $config; | ||||||
| // event handling {{{
 |  | ||||||
| 	public function receive_event(Event $event) { |  | ||||||
| 		global $config, $database, $page, $user; |  | ||||||
| 		if($this->theme == null) $this->theme = get_theme_object($this); |  | ||||||
| 
 |  | ||||||
| 		if($event instanceof InitExtEvent) { |  | ||||||
| 		$config->set_default_int("tag_list_length", 15); | 		$config->set_default_int("tag_list_length", 15); | ||||||
| 		$config->set_default_int("popular_tag_list_length", 15); | 		$config->set_default_int("popular_tag_list_length", 15); | ||||||
| 		$config->set_default_int("tags_min", 3); | 		$config->set_default_int("tags_min", 3); | ||||||
| @ -22,7 +16,10 @@ class TagList implements Extension { | |||||||
| 		$config->set_default_bool("tag_list_pages", false); | 		$config->set_default_bool("tag_list_pages", false); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 		if(($event instanceof PageRequestEvent) && $event->page_matches("tags")) { | 	public function onPageRequest($event) { | ||||||
|  | 		global $page, $database; | ||||||
|  | 
 | ||||||
|  | 		if($event->page_matches("tags")) { | ||||||
| 			$this->theme->set_navigation($this->build_navigation()); | 			$this->theme->set_navigation($this->build_navigation()); | ||||||
| 			switch($event->get_arg(0)) { | 			switch($event->get_arg(0)) { | ||||||
| 				default: | 				default: | ||||||
| @ -46,7 +43,7 @@ class TagList implements Extension { | |||||||
| 			$this->theme->display_page($page); | 			$this->theme->display_page($page); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if(($event instanceof PageRequestEvent) && $event->page_matches("api/internal/tag_list/complete")) { | 		if($event->page_matches("api/internal/tag_list/complete")) { | ||||||
| 			if(!isset($_GET["s"])) return; | 			if(!isset($_GET["s"])) return; | ||||||
| 
 | 
 | ||||||
| 			$all = $database->get_all( | 			$all = $database->get_all( | ||||||
| @ -60,8 +57,10 @@ class TagList implements Extension { | |||||||
| 			$page->set_type("text/plain"); | 			$page->set_type("text/plain"); | ||||||
| 			$page->set_data(implode("\n", $res)); | 			$page->set_data(implode("\n", $res)); | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 		if($event instanceof PostListBuildingEvent) { | 	public function onPostListBuilding($event) { | ||||||
|  | 		global $config, $page; | ||||||
| 		if($config->get_int('tag_list_length') > 0) { | 		if($config->get_int('tag_list_length') > 0) { | ||||||
| 			if(!empty($event->search_terms)) { | 			if(!empty($event->search_terms)) { | ||||||
| 				$this->add_refine_block($page, $event->search_terms); | 				$this->add_refine_block($page, $event->search_terms); | ||||||
| @ -72,7 +71,8 @@ class TagList implements Extension { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 		if($event instanceof DisplayingImageEvent) { | 	public function onDisplayingImage($event) { | ||||||
|  | 		global $config, $page; | ||||||
| 		if($config->get_int('tag_list_length') > 0) { | 		if($config->get_int('tag_list_length') > 0) { | ||||||
| 			if($config->get_string('tag_list_image_type') == 'related') { | 			if($config->get_string('tag_list_image_type') == 'related') { | ||||||
| 				$this->add_related_block($page, $event->image); | 				$this->add_related_block($page, $event->image); | ||||||
| @ -83,7 +83,7 @@ class TagList implements Extension { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 		if($event instanceof SetupBuildingEvent) { | 	public function onSetupBuilding($event) { | ||||||
| 		$sb = new SetupBlock("Tag Map Options"); | 		$sb = new SetupBlock("Tag Map Options"); | ||||||
| 		$sb->add_int_option("tags_min", "Only show tags used at least "); $sb->add_label(" times"); | 		$sb->add_int_option("tags_min", "Only show tags used at least "); $sb->add_label(" times"); | ||||||
| 		$sb->add_bool_option("tag_list_pages", "<br>Paged tag lists: "); | 		$sb->add_bool_option("tag_list_pages", "<br>Paged tag lists: "); | ||||||
| @ -100,7 +100,6 @@ class TagList implements Extension { | |||||||
| 		$sb->add_bool_option("tag_list_numbers", "<br>Show tag counts: "); | 		$sb->add_bool_option("tag_list_numbers", "<br>Show tag counts: "); | ||||||
| 		$event->panel->add_block($sb); | 		$event->panel->add_block($sb); | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
| // }}}
 | // }}}
 | ||||||
| // misc {{{
 | // misc {{{
 | ||||||
| 	private function tag_link($tag) { | 	private function tag_link($tag) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user