history_list($history, true); $page->set_title('Post '.$image_id.' Source History'); $page->set_heading('Source History: '.$image_id); $page->add_block(new NavBlock()); $page->add_block(new Block("Source History", $history_html, "main", 10)); } public function display_global_page(Page $page, array $history, int $page_number) { $history_html = $this->history_list($history, false); $page->set_title("Global Source History"); $page->set_heading("Global Source History"); $page->add_block(new Block("Source History", $history_html, "main", 10)); $h_prev = ($page_number <= 1) ? "Prev" : 'Prev'; $h_index = "Index"; $h_next = 'Next'; $nav = $h_prev.' | '.$h_index.' | '.$h_next; $page->add_block(new Block("Navigation", $nav, "left")); } /** * Add a section to the admin page. */ public function display_admin_block(string $validation_msg='') { global $page; if (!empty($validation_msg)) { $validation_msg = '
'. $validation_msg .''; } $html = ' Revert source changes by a specific IP address or username, optionally limited to recent changes. '.$validation_msg.'

'.make_form(make_link("source_history/bulk_revert"), 'POST')."
Username
IP Address
Since
"; $page->add_block(new Block("Mass Source Revert", $html)); } /* * Show a standard page for results to be put into */ public function display_revert_ip_results() { global $page; $html = implode("\n", $this->messages); $page->add_block(new Block("Bulk Revert Results", $html)); } public function add_status(string $title, string $body) { $this->messages[] = '

'. $title .'
'. $body .'

'; } protected function history_list(array $history, bool $select_2nd): string { $history_list = ""; foreach ($history as $n => $fields) { $history_list .= $this->history_entry($fields, $select_2nd && $n == 1); } return "
" . make_form(make_link("source_history/revert")) . "
"; } protected function history_entry(array $fields, bool $selected): string { global $user; $image_id = $fields['image_id']; $current_id = $fields['id']; $current_source = $fields['source']; $name = $fields['name']; $date_set = rawHTML(autodate($fields['date_set'])); $ip = $user->can(Permissions::VIEW_IP) ? rawHTML(" " . show_ip($fields['user_ip'], "Sourcing >>$image_id as '$current_source'")) : null; $setter = A(["href"=>make_link("user/" . url_escape($name))], $name); return (string)LI( INPUT(["type"=>"radio", "name"=>"revert", "id"=>"$current_id", "value"=>"$current_id", "checked"=>$selected]), A(["href"=>make_link("post/view/$image_id")], $image_id), ": ", LABEL( ["for"=>"$current_id"], $current_source, " - ", $setter, $ip, " - ", $date_set ) ); } }