Fixed things Shish pointed out
This commit is contained in:
		
							parent
							
								
									bf0146cc41
								
							
						
					
					
						commit
						2a51a9d6ba
					
				| @ -14,11 +14,22 @@ class TagCategories extends Extension { | |||||||
| 		//  note: only takes effect if /post/view shows the image's exact tags
 | 		//  note: only takes effect if /post/view shows the image's exact tags
 | ||||||
| 		$config->set_default_bool("tag_categories_split_on_view", true); | 		$config->set_default_bool("tag_categories_split_on_view", true); | ||||||
| 
 | 
 | ||||||
| 		$database->execute('CREATE TABLE IF NOT EXISTS image_tag_categories (category TEXT PRIMARY KEY, display_singular TEXT, display_multiple SINGULAR, color TEXT(7));'); | 		if($config->get_int("ext_tag_categories_version") < 1) { | ||||||
|  | 			// primary extension database, holds all our stuff!
 | ||||||
|  | 			$database->create_table('image_tag_categories', | ||||||
|  | 				'category VARCHAR(60) PRIMARY KEY, | ||||||
|  | 				display_singular TEXT(60), | ||||||
|  | 				display_multiple TEXT(60), | ||||||
|  | 				color TEXT(7)'); | ||||||
| 
 | 
 | ||||||
| 		$number_of_db_rows = $database->execute('SELECT COUNT(*) FROM image_tag_categories;')->fetchColumn(); |             $config->set_int("ext_tag_categories_version", 1); | ||||||
|  | 
 | ||||||
|  |             log_info("tag_categories", "extension installed"); | ||||||
|  | 		} | ||||||
| 
 | 
 | ||||||
| 		// if empty, add our default values
 | 		// if empty, add our default values
 | ||||||
|  | 		$number_of_db_rows = $database->execute('SELECT COUNT(*) FROM image_tag_categories;')->fetchColumn(); | ||||||
|  | 
 | ||||||
| 		if ($number_of_db_rows == 0) { | 		if ($number_of_db_rows == 0) { | ||||||
| 			$database->execute('INSERT INTO image_tag_categories VALUES ("artist", "Artist", "Artists", "#BB6666");'); | 			$database->execute('INSERT INTO image_tag_categories VALUES ("artist", "Artist", "Artists", "#BB6666");'); | ||||||
| 			$database->execute('INSERT INTO image_tag_categories VALUES ("series", "Series", "Series", "#AA00AA");'); | 			$database->execute('INSERT INTO image_tag_categories VALUES ("series", "Series", "Series", "#AA00AA");'); | ||||||
| @ -29,15 +40,11 @@ class TagCategories extends Extension { | |||||||
| 	public function onPageRequest(PageRequestEvent $event) { | 	public function onPageRequest(PageRequestEvent $event) { | ||||||
| 		global $page, $database, $user; | 		global $page, $database, $user; | ||||||
| 
 | 
 | ||||||
| 		if($event->page_matches("tags")) { | 		if($event->page_matches("tags/categories")) { | ||||||
| 			switch($event->get_arg(0)) { | 			if($user->is_admin()) { | ||||||
| 				case 'categories': |  | ||||||
| 					if(class_exists("TagCategories") and ($user->is_admin())) { |  | ||||||
| 				$this->page_update(); | 				$this->page_update(); | ||||||
| 				$this->show_tag_categories($page); | 				$this->show_tag_categories($page); | ||||||
| 			} | 			} | ||||||
| 					break; |  | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -83,27 +90,27 @@ class TagCategories extends Extension { | |||||||
| 					color=:color | 					color=:color | ||||||
| 				WHERE category=:category', | 				WHERE category=:category', | ||||||
| 				array( | 				array( | ||||||
| 					'category' => html_escape($_POST['tc_category']), | 					'category' => $_POST['tc_category'], | ||||||
| 					'display_singular' => html_escape($_POST['tc_display_singular']), | 					'display_singular' => $_POST['tc_display_singular'], | ||||||
| 					'display_multiple' => html_escape($_POST['tc_display_multiple']), | 					'display_multiple' => $_POST['tc_display_multiple'], | ||||||
| 					'color' => html_escape($_POST['tc_color']), | 					'color' => $_POST['tc_color'], | ||||||
| 				)); | 				)); | ||||||
| 		} | 		} | ||||||
| 		else if($_POST['tc_status'] == 'new') { | 		else if($_POST['tc_status'] == 'new') { | ||||||
| 			$is_success = $database->execute('INSERT INTO image_tag_categories | 			$is_success = $database->execute('INSERT INTO image_tag_categories | ||||||
| 				VALUES (:category, :display_singular, :display_multiple, :color)', | 				VALUES (:category, :display_singular, :display_multiple, :color)', | ||||||
| 				array( | 				array( | ||||||
| 					'category' => html_escape($_POST['tc_category']), | 					'category' => $_POST['tc_category'], | ||||||
| 					'display_singular' => html_escape($_POST['tc_display_singular']), | 					'display_singular' => $_POST['tc_display_singular'], | ||||||
| 					'display_multiple' => html_escape($_POST['tc_display_multiple']), | 					'display_multiple' => $_POST['tc_display_multiple'], | ||||||
| 					'color' => html_escape($_POST['tc_color']), | 					'color' => $_POST['tc_color'], | ||||||
| 				)); | 				)); | ||||||
| 		} | 		} | ||||||
| 		else if($_POST['tc_status'] == 'delete') { | 		else if($_POST['tc_status'] == 'delete') { | ||||||
| 			$is_success = $database->execute('DELETE FROM image_tag_categories | 			$is_success = $database->execute('DELETE FROM image_tag_categories | ||||||
| 				WHERE category=:category', | 				WHERE category=:category', | ||||||
| 				array( | 				array( | ||||||
| 					'category' => html_escape($_POST['tc_category']) | 					'category' => $_POST['tc_category'] | ||||||
| 				)); | 				)); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -67,10 +67,10 @@ class TagListTheme extends Themelet { | |||||||
| 
 | 
 | ||||||
| 		foreach(array_keys($tag_categories_html) as $category) { | 		foreach(array_keys($tag_categories_html) as $category) { | ||||||
| 			if($tag_categories_count[$category] < 2) { | 			if($tag_categories_count[$category] < 2) { | ||||||
| 				$category_display_name = $tag_category_dict[$category]['display_singular']; | 				$category_display_name = html_escape($tag_category_dict[$category]['display_singular']); | ||||||
| 			} | 			} | ||||||
| 			else{ | 			else{ | ||||||
| 				$category_display_name = $tag_category_dict[$category]['display_multiple']; | 				$category_display_name = html_escape($tag_category_dict[$category]['display_multiple']); | ||||||
| 			} | 			} | ||||||
| 			$page->add_block(new Block($category_display_name, $tag_categories_html[$category], "left", 9)); | 			$page->add_block(new Block($category_display_name, $tag_categories_html[$category], "left", 9)); | ||||||
| 		} | 		} | ||||||
| @ -199,7 +199,7 @@ class TagListTheme extends Themelet { | |||||||
| 			$category = $h_tag_split[0]; | 			$category = $h_tag_split[0]; | ||||||
| 			$h_tag = $h_tag_split[1]; | 			$h_tag = $h_tag_split[1]; | ||||||
| 			$tag_category_css .= ' tag_category_'.$category; | 			$tag_category_css .= ' tag_category_'.$category; | ||||||
| 			$tag_category_style .= 'style="color:'.$tag_category_dict[$category]['color'].';" '; | 			$tag_category_style .= 'style="color:'.html_escape($tag_category_dict[$category]['color']).';" '; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		$h_tag_no_underscores = str_replace("_", " ", $h_tag); | 		$h_tag_no_underscores = str_replace("_", " ", $h_tag); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user