mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-38196 Backup/restore: Display log if non-empty
When doing a backup or restore operation with the normal user interface, if there is anything in the backup/restore log, it will now be displayed at the end of the process below the Continue button. If you have developer debugging enabled, it sets the display level to LOG_DEBUG and there will always be content in the log. Otherwise, it uses LOG_INFO which generally means the log is empty, and nothing displays (no visible change for users).
This commit is contained in:
parent
56cc9b387e
commit
77b3d9dfdf
15 changed files with 220 additions and 73 deletions
|
@ -100,12 +100,24 @@ if ($backup->enforce_changed_dependencies()) {
|
||||||
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
|
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$loghtml = '';
|
||||||
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||||
// Display an extra progress bar so that we can show the progress first.
|
// Display an extra backup step bar so that we can show the 'processing' step first.
|
||||||
echo html_writer::start_div('', array('id' => 'executionprogress'));
|
echo html_writer::start_div('', array('id' => 'executionprogress'));
|
||||||
echo $renderer->progress_bar($backup->get_progress_bar());
|
echo $renderer->progress_bar($backup->get_progress_bar());
|
||||||
$backup->get_controller()->set_progress(new core_backup_display_progress());
|
$backup->get_controller()->set_progress(new core_backup_display_progress());
|
||||||
|
|
||||||
|
// Prepare logger and add to end of chain.
|
||||||
|
$logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
|
||||||
|
$backup->get_controller()->add_logger($logger);
|
||||||
|
|
||||||
|
// Carry out actual backup.
|
||||||
$backup->execute();
|
$backup->execute();
|
||||||
|
|
||||||
|
// Get HTML from logger.
|
||||||
|
$loghtml = $logger->get_html();
|
||||||
|
|
||||||
|
// Hide the progress display and first backup step bar (the 'finished' step will show next).
|
||||||
echo html_writer::end_div();
|
echo html_writer::end_div();
|
||||||
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
|
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
|
||||||
} else {
|
} else {
|
||||||
|
@ -116,4 +128,10 @@ echo $renderer->progress_bar($backup->get_progress_bar());
|
||||||
echo $backup->display($renderer);
|
echo $backup->display($renderer);
|
||||||
$backup->destroy();
|
$backup->destroy();
|
||||||
unset($backup);
|
unset($backup);
|
||||||
|
|
||||||
|
// Display log data if there was any.
|
||||||
|
if ($loghtml != '') {
|
||||||
|
echo $renderer->log_display($loghtml);
|
||||||
|
}
|
||||||
|
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
|
@ -40,7 +40,7 @@
|
||||||
*
|
*
|
||||||
* TODO: Finish phpdocs
|
* TODO: Finish phpdocs
|
||||||
*/
|
*/
|
||||||
class backup_controller extends backup implements loggable {
|
class backup_controller extends base_controller {
|
||||||
|
|
||||||
protected $backupid; // Unique identificator for this backup
|
protected $backupid; // Unique identificator for this backup
|
||||||
|
|
||||||
|
@ -62,12 +62,6 @@ class backup_controller extends backup implements loggable {
|
||||||
protected $executiontime; // epoch time when we want the backup to be executed (requires cron to run)
|
protected $executiontime; // epoch time when we want the backup to be executed (requires cron to run)
|
||||||
|
|
||||||
protected $destination; // Destination chain object (fs_moodle, fs_os, db, email...)
|
protected $destination; // Destination chain object (fs_moodle, fs_os, db, email...)
|
||||||
protected $logger; // Logging chain object (moodle, inline, fs, db, syslog)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var core_backup_progress Progress reporting object.
|
|
||||||
*/
|
|
||||||
protected $progress;
|
|
||||||
|
|
||||||
protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
|
protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
|
||||||
|
|
||||||
|
@ -307,29 +301,6 @@ class backup_controller extends backup implements loggable {
|
||||||
return $this->plan;
|
return $this->plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_logger() {
|
|
||||||
return $this->logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the progress reporter, which can be used to report progress within
|
|
||||||
* the backup or restore process.
|
|
||||||
*
|
|
||||||
* @return core_backup_progress Progress reporting object
|
|
||||||
*/
|
|
||||||
public function get_progress() {
|
|
||||||
return $this->progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the progress reporter.
|
|
||||||
*
|
|
||||||
* @param core_backup_progress $progress Progress reporting object
|
|
||||||
*/
|
|
||||||
public function set_progress(core_backup_progress $progress) {
|
|
||||||
$this->progress = $progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the backup
|
* Executes the backup
|
||||||
* @return void Throws and exception of completes
|
* @return void Throws and exception of completes
|
||||||
|
@ -353,10 +324,6 @@ class backup_controller extends backup implements loggable {
|
||||||
return $this->plan->get_results();
|
return $this->plan->get_results();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function log($message, $level, $a = null, $depth = null, $display = false) {
|
|
||||||
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save controller information
|
* Save controller information
|
||||||
*
|
*
|
||||||
|
|
85
backup/controller/base_controller.class.php
Normal file
85
backup/controller/base_controller.class.php
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class with shared stuff between backup controller and restore
|
||||||
|
* controller.
|
||||||
|
*
|
||||||
|
* @package core_backup
|
||||||
|
* @copyright 2013 The Open University
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
abstract class base_controller extends backup implements loggable {
|
||||||
|
/**
|
||||||
|
* @var core_backup_progress Progress reporting object.
|
||||||
|
*/
|
||||||
|
protected $progress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var base_logger Logging chain object (moodle, inline, fs, db, syslog)
|
||||||
|
*/
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the progress reporter, which can be used to report progress within
|
||||||
|
* the backup or restore process.
|
||||||
|
*
|
||||||
|
* @return core_backup_progress Progress reporting object
|
||||||
|
*/
|
||||||
|
public function get_progress() {
|
||||||
|
return $this->progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the progress reporter.
|
||||||
|
*
|
||||||
|
* @param core_backup_progress $progress Progress reporting object
|
||||||
|
*/
|
||||||
|
public function set_progress(core_backup_progress $progress) {
|
||||||
|
$this->progress = $progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets first logger in logging chain.
|
||||||
|
*
|
||||||
|
* @return base_logger Logger
|
||||||
|
*/
|
||||||
|
public function get_logger() {
|
||||||
|
return $this->logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts a new logger at end of logging chain.
|
||||||
|
*
|
||||||
|
* @param base_logger $logger New logger to add
|
||||||
|
*/
|
||||||
|
public function add_logger(base_logger $logger) {
|
||||||
|
$existing = $this->logger;
|
||||||
|
while ($existing->get_next()) {
|
||||||
|
$existing = $existing->get_next();
|
||||||
|
}
|
||||||
|
$existing->set_next($logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs data to the logger chain.
|
||||||
|
*
|
||||||
|
* @see loggable::log()
|
||||||
|
*/
|
||||||
|
public function log($message, $level, $a = null, $depth = null, $display = false) {
|
||||||
|
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* TODO: Finish phpdocs
|
* TODO: Finish phpdocs
|
||||||
*/
|
*/
|
||||||
class restore_controller extends backup implements loggable {
|
class restore_controller extends base_controller {
|
||||||
|
|
||||||
protected $tempdir; // Directory under tempdir/backup awaiting restore
|
protected $tempdir; // Directory under tempdir/backup awaiting restore
|
||||||
protected $restoreid; // Unique identificator for this restore
|
protected $restoreid; // Unique identificator for this restore
|
||||||
|
@ -55,13 +55,6 @@ class restore_controller extends backup implements loggable {
|
||||||
protected $execution; // inmediate/delayed
|
protected $execution; // inmediate/delayed
|
||||||
protected $executiontime; // epoch time when we want the restore to be executed (requires cron to run)
|
protected $executiontime; // epoch time when we want the restore to be executed (requires cron to run)
|
||||||
|
|
||||||
protected $logger; // Logging chain object (moodle, inline, fs, db, syslog)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var core_backup_progress Progress reporting object.
|
|
||||||
*/
|
|
||||||
protected $progress;
|
|
||||||
|
|
||||||
protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
|
protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -305,29 +298,6 @@ class restore_controller extends backup implements loggable {
|
||||||
return $this->info;
|
return $this->info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_logger() {
|
|
||||||
return $this->logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the progress reporter, which can be used to report progress within
|
|
||||||
* the backup or restore process.
|
|
||||||
*
|
|
||||||
* @return core_backup_progress Progress reporting object
|
|
||||||
*/
|
|
||||||
public function get_progress() {
|
|
||||||
return $this->progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the progress reporter.
|
|
||||||
*
|
|
||||||
* @param core_backup_progress $progress Progress reporting object
|
|
||||||
*/
|
|
||||||
public function set_progress(core_backup_progress $progress) {
|
|
||||||
$this->progress = $progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute_plan() {
|
public function execute_plan() {
|
||||||
// Basic/initial prevention against time/memory limits
|
// Basic/initial prevention against time/memory limits
|
||||||
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
|
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
|
||||||
|
@ -395,10 +365,6 @@ class restore_controller extends backup implements loggable {
|
||||||
return $this->precheck;
|
return $this->precheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function log($message, $level, $a = null, $depth = null, $display = false) {
|
|
||||||
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save controller information
|
* Save controller information
|
||||||
*
|
*
|
||||||
|
|
|
@ -99,6 +99,10 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||||
$progress->start_progress('', 2);
|
$progress->start_progress('', 2);
|
||||||
$backup->get_controller()->set_progress($progress);
|
$backup->get_controller()->set_progress($progress);
|
||||||
|
|
||||||
|
// Prepare logger for backup.
|
||||||
|
$logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
|
||||||
|
$backup->get_controller()->add_logger($logger);
|
||||||
|
|
||||||
// First execute the backup
|
// First execute the backup
|
||||||
$backup->execute();
|
$backup->execute();
|
||||||
$backup->destroy();
|
$backup->destroy();
|
||||||
|
@ -123,6 +127,10 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||||
// (the precheck and then the actual restore).
|
// (the precheck and then the actual restore).
|
||||||
$progress->start_progress('Restore process', 2);
|
$progress->start_progress('Restore process', 2);
|
||||||
$rc->set_progress($progress);
|
$rc->set_progress($progress);
|
||||||
|
|
||||||
|
// Set logger for restore.
|
||||||
|
$rc->add_logger($logger);
|
||||||
|
|
||||||
// Convert the backup if required.... it should NEVER happed
|
// Convert the backup if required.... it should NEVER happed
|
||||||
if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
|
if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
|
||||||
$rc->convert();
|
$rc->convert();
|
||||||
|
@ -178,6 +186,13 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||||
}
|
}
|
||||||
echo $OUTPUT->notification(get_string('importsuccess', 'backup'), 'notifysuccess');
|
echo $OUTPUT->notification(get_string('importsuccess', 'backup'), 'notifysuccess');
|
||||||
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id'=>$course->id)));
|
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id'=>$course->id)));
|
||||||
|
|
||||||
|
// Get and display log data if there was any.
|
||||||
|
$loghtml = $logger->get_html();
|
||||||
|
if ($loghtml != '') {
|
||||||
|
echo $renderer->log_display($loghtml);
|
||||||
|
}
|
||||||
|
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
|
|
||||||
die();
|
die();
|
||||||
|
|
|
@ -3625,7 +3625,7 @@ class restore_process_file_aliases_queue extends restore_execution_step {
|
||||||
protected function define_execution() {
|
protected function define_execution() {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
$this->log('processing file aliases queue', backup::LOG_INFO);
|
$this->log('processing file aliases queue', backup::LOG_DEBUG);
|
||||||
|
|
||||||
$fs = get_file_storage();
|
$fs = get_file_storage();
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ if (!$restore->is_independent() && $restore->enforce_changed_dependencies()) {
|
||||||
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
|
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$loghtml = '';
|
||||||
if (!$restore->is_independent()) {
|
if (!$restore->is_independent()) {
|
||||||
// Use a temporary (disappearing) progress bar to show the precheck progress if any.
|
// Use a temporary (disappearing) progress bar to show the precheck progress if any.
|
||||||
$precheckprogress = new core_backup_display_progress_if_slow(get_string('preparingdata', 'backup'));
|
$precheckprogress = new core_backup_display_progress_if_slow(get_string('preparingdata', 'backup'));
|
||||||
|
@ -72,9 +73,14 @@ if (!$restore->is_independent()) {
|
||||||
// Show the current restore state (header with bolded item).
|
// Show the current restore state (header with bolded item).
|
||||||
echo $renderer->progress_bar($restore->get_progress_bar());
|
echo $renderer->progress_bar($restore->get_progress_bar());
|
||||||
// Start displaying the actual progress bar percentage.
|
// Start displaying the actual progress bar percentage.
|
||||||
$restore->get_controller()->set_progress(new core_backup_display_progress(true));
|
$restore->get_controller()->set_progress(new core_backup_display_progress());
|
||||||
|
// Prepare logger.
|
||||||
|
$logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
|
||||||
|
$restore->get_controller()->add_logger($logger);
|
||||||
// Do actual restore.
|
// Do actual restore.
|
||||||
$restore->execute();
|
$restore->execute();
|
||||||
|
// Get HTML from logger.
|
||||||
|
$loghtml = $logger->get_html();
|
||||||
// Hide this section because we are now going to make the page show 'finished'.
|
// Hide this section because we are now going to make the page show 'finished'.
|
||||||
echo html_writer::end_div();
|
echo html_writer::end_div();
|
||||||
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
|
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
|
||||||
|
@ -91,4 +97,10 @@ echo $renderer->progress_bar($restore->get_progress_bar());
|
||||||
echo $restore->display($renderer);
|
echo $restore->display($renderer);
|
||||||
$restore->destroy();
|
$restore->destroy();
|
||||||
unset($restore);
|
unset($restore);
|
||||||
|
|
||||||
|
// Display log data if there was any.
|
||||||
|
if ($loghtml != '') {
|
||||||
|
echo $renderer->log_display($loghtml);
|
||||||
|
}
|
||||||
|
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
|
|
|
@ -69,6 +69,7 @@ require_once($CFG->dirroot . '/backup/util/xml/parser/progressive_parser.class.p
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/base_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/base_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/error_log_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/error_log_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/file_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/file_logger.class.php');
|
||||||
|
require_once($CFG->dirroot . '/backup/util/loggers/core_backup_html_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/database_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/database_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/progress/core_backup_progress.class.php');
|
require_once($CFG->dirroot . '/backup/util/progress/core_backup_progress.class.php');
|
||||||
|
@ -89,6 +90,7 @@ require_once($CFG->dirroot . '/backup/util/plan/base_step.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/plan/backup_step.class.php');
|
require_once($CFG->dirroot . '/backup/util/plan/backup_step.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/plan/backup_structure_step.class.php');
|
require_once($CFG->dirroot . '/backup/util/plan/backup_structure_step.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/plan/backup_execution_step.class.php');
|
require_once($CFG->dirroot . '/backup/util/plan/backup_execution_step.class.php');
|
||||||
|
require_once($CFG->dirroot . '/backup/controller/base_controller.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/controller/backup_controller.class.php');
|
require_once($CFG->dirroot . '/backup/controller/backup_controller.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/ui/base_moodleform.class.php');
|
require_once($CFG->dirroot . '/backup/util/ui/base_moodleform.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/ui/base_ui.class.php');
|
require_once($CFG->dirroot . '/backup/util/ui/base_ui.class.php');
|
||||||
|
|
|
@ -58,6 +58,7 @@ require_once($CFG->dirroot . '/backup/util/checks/restore_check.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/base_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/base_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/error_log_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/error_log_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/file_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/file_logger.class.php');
|
||||||
|
require_once($CFG->dirroot . '/backup/util/loggers/core_backup_html_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/database_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/database_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.php');
|
require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/progress/core_backup_progress.class.php');
|
require_once($CFG->dirroot . '/backup/util/progress/core_backup_progress.class.php');
|
||||||
|
@ -84,6 +85,7 @@ require_once($CFG->dirroot . '/backup/util/plan/restore_step.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/plan/restore_structure_step.class.php');
|
require_once($CFG->dirroot . '/backup/util/plan/restore_structure_step.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/plan/restore_execution_step.class.php');
|
require_once($CFG->dirroot . '/backup/util/plan/restore_execution_step.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/moodle2/restore_plan_builder.class.php');
|
require_once($CFG->dirroot . '/backup/moodle2/restore_plan_builder.class.php');
|
||||||
|
require_once($CFG->dirroot . '/backup/controller/base_controller.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/controller/restore_controller.class.php');
|
require_once($CFG->dirroot . '/backup/controller/restore_controller.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/ui/base_moodleform.class.php');
|
require_once($CFG->dirroot . '/backup/util/ui/base_moodleform.class.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/ui/base_ui.class.php');
|
require_once($CFG->dirroot . '/backup/util/ui/base_ui.class.php');
|
||||||
|
|
46
backup/util/loggers/core_backup_html_logger.class.php
Normal file
46
backup/util/loggers/core_backup_html_logger.class.php
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logger that stores HTML log data in memory, ready for later display.
|
||||||
|
*
|
||||||
|
* @package core_backup
|
||||||
|
* @copyright 2013 The Open University
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
class core_backup_html_logger extends base_logger {
|
||||||
|
/**
|
||||||
|
* @var string HTML output
|
||||||
|
*/
|
||||||
|
protected $html = '';
|
||||||
|
|
||||||
|
protected function action($message, $level, $options = null) {
|
||||||
|
$prefix = $this->get_prefix($level, $options);
|
||||||
|
$depth = isset($options['depth']) ? $options['depth'] : 0;
|
||||||
|
$this->html .= $prefix . str_repeat(' ', $depth) .
|
||||||
|
s($message) . '<br/>' . PHP_EOL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the full HTML content of the log.
|
||||||
|
*
|
||||||
|
* @return string HTML content of log
|
||||||
|
*/
|
||||||
|
public function get_html() {
|
||||||
|
return $this->html;
|
||||||
|
}
|
||||||
|
}
|
|
@ -55,6 +55,24 @@ class core_backup_renderer extends plugin_renderer_base {
|
||||||
}
|
}
|
||||||
return html_writer::tag('div', join(get_separator(), $items), array('class'=>'backup_progress clearfix'));
|
return html_writer::tag('div', join(get_separator(), $items), array('class'=>'backup_progress clearfix'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The backup and restore pages may display a log (if any) in a scrolling box.
|
||||||
|
*
|
||||||
|
* @param string $loghtml Log content in HTML format
|
||||||
|
* @return string HTML content that shows the log
|
||||||
|
*/
|
||||||
|
public function log_display($loghtml) {
|
||||||
|
global $OUTPUT;
|
||||||
|
$out = html_writer::start_div('backup_log');
|
||||||
|
$out .= $OUTPUT->heading(get_string('backuplog', 'backup'));
|
||||||
|
$out .= html_writer::start_div('backup_log_contents');
|
||||||
|
$out .= $loghtml;
|
||||||
|
$out .= html_writer::end_div();
|
||||||
|
$out .= html_writer::end_div();
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a dependency notification
|
* Prints a dependency notification
|
||||||
* @param string $message
|
* @param string $message
|
||||||
|
|
|
@ -49,6 +49,7 @@ $string['backupformatmoodle2'] = 'Moodle 2';
|
||||||
$string['backupformatimscc1'] = 'IMS Common Cartridge 1.0';
|
$string['backupformatimscc1'] = 'IMS Common Cartridge 1.0';
|
||||||
$string['backupformatimscc11'] = 'IMS Common Cartridge 1.1';
|
$string['backupformatimscc11'] = 'IMS Common Cartridge 1.1';
|
||||||
$string['backupformatunknown'] = 'Unknown format';
|
$string['backupformatunknown'] = 'Unknown format';
|
||||||
|
$string['backuplog'] = 'Technical information and warnings';
|
||||||
$string['backupmode'] = 'Mode';
|
$string['backupmode'] = 'Mode';
|
||||||
$string['backupmode10'] = 'General';
|
$string['backupmode10'] = 'General';
|
||||||
$string['backupmode20'] = 'Import';
|
$string['backupmode20'] = 'Import';
|
||||||
|
|
|
@ -567,6 +567,9 @@ body.tag .managelink {padding: 5px;}
|
||||||
.path-backup .wibbler .state10 { background: #444; }
|
.path-backup .wibbler .state10 { background: #444; }
|
||||||
.path-backup .wibbler .state11 { background: #333; }
|
.path-backup .wibbler .state11 { background: #333; }
|
||||||
.path-backup .wibbler .state12 { background: #222; }
|
.path-backup .wibbler .state12 { background: #222; }
|
||||||
|
.path-backup .backup_log { margin-top: 2em; }
|
||||||
|
.path-backup .backup_log h2 { font-size: 1em; }
|
||||||
|
.path-backup .backup_log_contents { border: 1px solid #ddd; padding: 10px; height: 300px; overflow-y: scroll; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web Service
|
* Web Service
|
||||||
|
|
|
@ -217,3 +217,15 @@
|
||||||
.path-backup .wibbler .state12 {
|
.path-backup .wibbler .state12 {
|
||||||
background: #222;
|
background: #222;
|
||||||
}
|
}
|
||||||
|
.path-backup .backup_log {
|
||||||
|
margin-top: 2em;
|
||||||
|
}
|
||||||
|
.path-backup .backup_log h2 {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
.path-backup .backup_log_contents {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
padding: 10px;
|
||||||
|
height: 300px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue