2013-05-18 12:52:11 +00:00
|
|
|
<?php
|
2019-05-28 16:59:38 +00:00
|
|
|
class Source_HistoryTheme extends Themelet
|
|
|
|
{
|
|
|
|
private $messages = [];
|
|
|
|
|
|
|
|
public function display_history_page(Page $page, int $image_id, array $history)
|
|
|
|
{
|
|
|
|
global $user;
|
|
|
|
$start_string = "
|
2013-05-18 12:52:11 +00:00
|
|
|
<div style='text-align: left'>
|
|
|
|
".make_form(make_link("source_history/revert"))."
|
|
|
|
<ul style='list-style-type:none;'>
|
|
|
|
";
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$history_list = "";
|
|
|
|
$n = 0;
|
|
|
|
foreach ($history as $fields) {
|
|
|
|
$n++;
|
|
|
|
$current_id = $fields['id'];
|
|
|
|
$current_source = html_escape($fields['source']);
|
|
|
|
$name = $fields['name'];
|
|
|
|
$date_set = autodate($fields['date_set']);
|
|
|
|
$h_ip = $user->can("view_ip") ? " ".show_ip($fields['user_ip'], "Sourcing Image #$image_id as '$current_source'") : "";
|
|
|
|
$setter = "<a href='".make_link("user/".url_escape($name))."'>".html_escape($name)."</a>$h_ip";
|
|
|
|
|
|
|
|
$selected = ($n == 2) ? " checked" : "";
|
|
|
|
|
|
|
|
$history_list .= "
|
2013-05-18 12:52:11 +00:00
|
|
|
<li>
|
|
|
|
<input type='radio' name='revert' id='$current_id' value='$current_id'$selected>
|
2015-04-26 11:45:32 +00:00
|
|
|
<label for='$current_id'>
|
|
|
|
$current_source
|
|
|
|
<br>
|
|
|
|
Set by $setter $date_set
|
|
|
|
</label>
|
2013-05-18 12:52:11 +00:00
|
|
|
</li>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2013-05-18 12:52:11 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$end_string = "
|
2013-05-18 12:52:11 +00:00
|
|
|
</ul>
|
|
|
|
<input type='submit' value='Revert To'>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
$history_html = $start_string . $history_list . $end_string;
|
2013-05-18 12:52:11 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->set_title('Image '.$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));
|
|
|
|
}
|
2013-05-18 12:52:11 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function display_global_page(Page $page, array $history, int $page_number)
|
|
|
|
{
|
|
|
|
$start_string = "
|
2013-05-18 12:52:11 +00:00
|
|
|
<div style='text-align: left'>
|
|
|
|
".make_form(make_link("source_history/revert"))."
|
|
|
|
<ul style='list-style-type:none;'>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
$end_string = "
|
2013-05-18 12:52:11 +00:00
|
|
|
</ul>
|
|
|
|
<input type='submit' value='Revert To'>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
";
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
global $user;
|
|
|
|
$history_list = "";
|
|
|
|
foreach ($history as $fields) {
|
|
|
|
$current_id = $fields['id'];
|
|
|
|
$image_id = $fields['image_id'];
|
|
|
|
$current_source = html_escape($fields['source']);
|
|
|
|
$name = $fields['name'];
|
|
|
|
$h_ip = $user->can("view_ip") ? " ".show_ip($fields['user_ip'], "Sourcing Image #$image_id as '$current_source'") : "";
|
|
|
|
$setter = "<a href='".make_link("user/".url_escape($name))."'>".html_escape($name)."</a>$h_ip";
|
|
|
|
|
|
|
|
$history_list .= '
|
2013-05-18 12:52:11 +00:00
|
|
|
<li>
|
|
|
|
<input type="radio" name="revert" value="'.$current_id.'">
|
|
|
|
<a href="'.make_link('post/view/'.$image_id).'">'.$image_id.'</a>:
|
|
|
|
'.$current_source.' (Set by '.$setter.')
|
|
|
|
</li>
|
|
|
|
';
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$history_html = $start_string . $history_list . $end_string;
|
|
|
|
$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" :
|
|
|
|
'<a href="'.make_link('source_history/all/'.($page_number-1)).'">Prev</a>';
|
|
|
|
$h_index = "<a href='".make_link()."'>Index</a>";
|
|
|
|
$h_next = '<a href="'.make_link('source_history/all/'.($page_number+1)).'">Next</a>';
|
|
|
|
|
|
|
|
$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 = '<br><b>'. $validation_msg .'</b>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html = '
|
2019-06-09 07:32:01 +00:00
|
|
|
Revert source changes by a specific IP address or username, optionally limited to recent changes.
|
2013-05-18 12:52:11 +00:00
|
|
|
'.$validation_msg.'
|
|
|
|
|
|
|
|
<br><br>'.make_form(make_link("source_history/bulk_revert"), 'POST')."
|
|
|
|
<table class='form'>
|
|
|
|
<tr><th>Username</th> <td><input type='text' name='revert_name' size='15'></td></tr>
|
|
|
|
<tr><th>IP Address</th> <td><input type='text' name='revert_ip' size='15'></td></tr>
|
2019-06-09 07:32:01 +00:00
|
|
|
<tr><th>Since</th> <td><input type='date' name='revert_date' size='15'></td></tr>
|
2013-05-18 12:52:11 +00:00
|
|
|
<tr><td colspan='2'><input type='submit' value='Revert'></td></tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
$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($this->messages, "\n");
|
|
|
|
$page->add_block(new Block("Bulk Revert Results", $html));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function add_status(string $title, string $body)
|
|
|
|
{
|
|
|
|
$this->messages[] = '<p><b>'. $title .'</b><br>'. $body .'</p>';
|
|
|
|
}
|
2013-05-18 12:52:11 +00:00
|
|
|
}
|