tag_history paging
This commit is contained in:
		
							parent
							
								
									f03af6cfcb
								
							
						
					
					
						commit
						40bcfafc66
					
				@ -58,8 +58,7 @@ class Tag_History extends Extension {
 | 
			
		||||
	public function onPageRequest(PageRequestEvent $event) {
 | 
			
		||||
		global $config, $page, $user;
 | 
			
		||||
 | 
			
		||||
		if ($event->page_matches("tag_history")) {
 | 
			
		||||
			if($event->get_arg(0) == "revert") {
 | 
			
		||||
		if($event->page_matches("tag_history/revert")) {
 | 
			
		||||
			// this is a request to revert to a previous version of the tags
 | 
			
		||||
			if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
 | 
			
		||||
				if(isset($_POST['revert'])) {
 | 
			
		||||
@ -67,14 +66,14 @@ class Tag_History extends Extension {
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
			else if($event->count_args() == 1) {
 | 
			
		||||
		else if($event->page_matches("tag_history/all")) {
 | 
			
		||||
			$page_id = int_escape($event->get_arg(1));
 | 
			
		||||
			$this->theme->display_global_page($page, $this->get_global_tag_history($page_id), $page_id);
 | 
			
		||||
		}
 | 
			
		||||
		else if($event->page_matches("tag_history") && $event->count_args() == 1) {
 | 
			
		||||
			// 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));
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				$this->theme->display_global_page($page, $this->get_global_tag_history());
 | 
			
		||||
			}
 | 
			
		||||
			$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) {
 | 
			
		||||
		global $user;
 | 
			
		||||
		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());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public function get_global_tag_history()
 | 
			
		||||
	public function get_global_tag_history($page_id)
 | 
			
		||||
	{
 | 
			
		||||
		global $database;
 | 
			
		||||
		$row = $database->get_all("
 | 
			
		||||
@ -240,7 +239,8 @@ class Tag_History extends Extension {
 | 
			
		||||
				FROM tag_histories
 | 
			
		||||
				JOIN users ON tag_histories.user_id = users.id
 | 
			
		||||
				ORDER BY tag_histories.id DESC
 | 
			
		||||
				LIMIT 100");
 | 
			
		||||
				LIMIT 100 OFFSET :offset
 | 
			
		||||
		", array("offset" => ($page_id-1)*100));
 | 
			
		||||
		return ($row ? $row : array());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
@ -50,7 +50,7 @@ class Tag_HistoryTheme extends Themelet {
 | 
			
		||||
		$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 = "
 | 
			
		||||
			<div style='text-align: left'>
 | 
			
		||||
				".make_form(make_link("tag_history/revert"))."
 | 
			
		||||
@ -89,6 +89,16 @@ class Tag_HistoryTheme extends Themelet {
 | 
			
		||||
		$page->set_heading("Global Tag History");
 | 
			
		||||
		$page->add_block(new NavBlock());
 | 
			
		||||
		$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) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user