tag_history paging
This commit is contained in:
		
							parent
							
								
									f03af6cfcb
								
							
						
					
					
						commit
						40bcfafc66
					
				@ -58,23 +58,22 @@ class Tag_History extends Extension {
 | 
				
			|||||||
	public function onPageRequest(PageRequestEvent $event) {
 | 
						public function onPageRequest(PageRequestEvent $event) {
 | 
				
			||||||
		global $config, $page, $user;
 | 
							global $config, $page, $user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if ($event->page_matches("tag_history")) {
 | 
							if($event->page_matches("tag_history/revert")) {
 | 
				
			||||||
			if($event->get_arg(0) == "revert") {
 | 
								// this is a request to revert to a previous version of the tags
 | 
				
			||||||
				// this is a request to revert to a previous version of the tags
 | 
								if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
 | 
				
			||||||
				if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
 | 
									if(isset($_POST['revert'])) {
 | 
				
			||||||
					if(isset($_POST['revert'])) {
 | 
										$this->process_revert_request($_POST['revert']);
 | 
				
			||||||
						$this->process_revert_request($_POST['revert']);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else if($event->count_args() == 1) {
 | 
							}
 | 
				
			||||||
				// must be an attempt to view a tag history
 | 
							else if($event->page_matches("tag_history/all")) {
 | 
				
			||||||
				$image_id = int_escape($event->get_arg(0));
 | 
								$page_id = int_escape($event->get_arg(1));
 | 
				
			||||||
				$this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id));
 | 
								$this->theme->display_global_page($page, $this->get_global_tag_history($page_id), $page_id);
 | 
				
			||||||
			}
 | 
							}
 | 
				
			||||||
			else {
 | 
							else if($event->page_matches("tag_history") && $event->count_args() == 1) {
 | 
				
			||||||
				$this->theme->display_global_page($page, $this->get_global_tag_history());
 | 
								// must be an attempt to view a tag history
 | 
				
			||||||
			}
 | 
								$image_id = int_escape($event->get_arg(0));
 | 
				
			||||||
 | 
								$this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id, $page_id));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@ -100,7 +99,7 @@ class Tag_History extends Extension {
 | 
				
			|||||||
	public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
 | 
						public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
 | 
				
			||||||
		global $user;
 | 
							global $user;
 | 
				
			||||||
		if($user->is_admin()) {
 | 
							if($user->is_admin()) {
 | 
				
			||||||
			$event->add_link("Tag Changes", make_link("tag_history"));
 | 
								$event->add_link("Tag Changes", make_link("tag_history/all/1"));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@ -232,7 +231,7 @@ class Tag_History extends Extension {
 | 
				
			|||||||
		return ($row ? $row : array());
 | 
							return ($row ? $row : array());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public function get_global_tag_history()
 | 
						public function get_global_tag_history($page_id)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		global $database;
 | 
							global $database;
 | 
				
			||||||
		$row = $database->get_all("
 | 
							$row = $database->get_all("
 | 
				
			||||||
@ -240,7 +239,8 @@ class Tag_History extends Extension {
 | 
				
			|||||||
				FROM tag_histories
 | 
									FROM tag_histories
 | 
				
			||||||
				JOIN users ON tag_histories.user_id = users.id
 | 
									JOIN users ON tag_histories.user_id = users.id
 | 
				
			||||||
				ORDER BY tag_histories.id DESC
 | 
									ORDER BY tag_histories.id DESC
 | 
				
			||||||
				LIMIT 100");
 | 
									LIMIT 100 OFFSET :offset
 | 
				
			||||||
 | 
							", array("offset" => ($page_id-1)*100));
 | 
				
			||||||
		return ($row ? $row : array());
 | 
							return ($row ? $row : array());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
				
			|||||||
@ -50,7 +50,7 @@ class Tag_HistoryTheme extends Themelet {
 | 
				
			|||||||
		$page->add_block(new Block("Tag History", $history_html, "main", 10));
 | 
							$page->add_block(new Block("Tag History", $history_html, "main", 10));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public function display_global_page(Page $page, /*array*/ $history) {
 | 
						public function display_global_page(Page $page, /*array*/ $history, /*int*/ $page_number) {
 | 
				
			||||||
		$start_string = "
 | 
							$start_string = "
 | 
				
			||||||
			<div style='text-align: left'>
 | 
								<div style='text-align: left'>
 | 
				
			||||||
				".make_form(make_link("tag_history/revert"))."
 | 
									".make_form(make_link("tag_history/revert"))."
 | 
				
			||||||
@ -89,6 +89,16 @@ class Tag_HistoryTheme extends Themelet {
 | 
				
			|||||||
		$page->set_heading("Global Tag History");
 | 
							$page->set_heading("Global Tag History");
 | 
				
			||||||
		$page->add_block(new NavBlock());
 | 
							$page->add_block(new NavBlock());
 | 
				
			||||||
		$page->add_block(new Block("Tag History", $history_html, "main", 10));
 | 
							$page->add_block(new Block("Tag History", $history_html, "main", 10));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							$h_prev = ($page_number <= 1) ? "Prev" :
 | 
				
			||||||
 | 
								'<a href="'.make_link('comment/list/'.$prev).'">Prev</a>';
 | 
				
			||||||
 | 
							$h_index = "<a href='".make_link()."'>Index</a>";
 | 
				
			||||||
 | 
							$h_next = ($page_number >= $total_pages) ? "Next" :
 | 
				
			||||||
 | 
								'<a href="'.make_link('comment/list/'.$next).'">Next</a>';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							$nav = $h_prev.' | '.$h_index.' | '.$h_next;
 | 
				
			||||||
 | 
							$page->add_block(new Block("Navigation", $nav, "left"));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public function display_history_link(Page $page, /*int*/ $image_id) {
 | 
						public function display_history_link(Page $page, /*int*/ $image_id) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user