MDL-46269 tool_httpsreplace: Add multiple steps

This commit is contained in:
John Okely
2017-09-18 11:18:18 +08:00
committed by Marina Glancy
parent 4b86dd7ba6
commit 55b1d231ed
7 changed files with 116 additions and 63 deletions
+3 -57
View File
@@ -22,10 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_OUTPUT_BUFFERING', true);
require_once(__DIR__ . '/../../../config.php');
require_once($CFG->dirroot . '/course/lib.php');
require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('toolhttpsreplace');
@@ -54,60 +51,9 @@ if (!is_https()) {
echo $OUTPUT->notification(get_string('httpwarning', 'tool_httpsreplace'), 'warning');
}
echo '<p>'.get_string('domainexplain', 'tool_httpsreplace').'</p>';
echo '<p>'.page_doc_link(get_string('doclink', 'tool_httpsreplace')).'</p>';
$form = new \tool_httpsreplace\form();
echo $OUTPUT->continue_button(new moodle_url('/admin/tool/httpsreplace/tool.php'));
$finder = new \tool_httpsreplace\url_finder();
if (!$data = $form->get_data()) {
echo '<p>'.get_string('domainexplain', 'tool_httpsreplace').'</p>';
echo '<p>'.page_doc_link(get_string('doclink', 'tool_httpsreplace')).'</p>';
$PAGE->set_cacheable(false);
$progressbar = new progress_bar();
echo $progressbar->create();
$results = $finder->http_link_stats($progressbar);
$progressbar->update_full(100, get_string('complete', 'tool_httpsreplace'));
if (empty($results)) {
echo '<p>'.get_string('oktoprocede', 'tool_httpsreplace').'</p>';
} else {
arsort($results);
$table = new html_table();
$table->id = 'plugins-check';
$table->head = array(
get_string('domain', 'tool_httpsreplace'),
get_string('count', 'tool_httpsreplace'),
);
$data = array();
foreach ($results as $domain => $count) {
$cleandomain = format_text($domain, FORMAT_PLAIN);
$data[] = [$cleandomain, $count];
}
$table->data = $data;
echo html_writer::table($table);
}
echo $OUTPUT->notification(get_string('takeabackupwarning', 'tool_httpsreplace'), 'warning');
$form->display();
} else {
// Scroll to the end when finished.
$PAGE->requires->js_init_code("window.scrollTo(0, 5000000);");
echo '<p>'.get_string('replacing', 'tool_httpsreplace').'</p>';
$PAGE->set_cacheable(false);
$progressbar = new progress_bar();
echo $progressbar->create();
echo $OUTPUT->box_start();
$finder->upgrade_http_links($progressbar);
echo $OUTPUT->box_end();
$progressbar->update_full(100, get_string('complete', 'tool_httpsreplace'));
echo $OUTPUT->continue_button(new moodle_url('/admin/settings.php', ['section' => 'httpsecurity']));
}
echo $OUTPUT->footer();