MDL-32095 fix backup API to be E_STRICT compatible

This commit is contained in:
Petr Skoda 2012-03-26 15:57:57 +02:00
parent 5ec6c45fd4
commit 748e96512b
9 changed files with 45 additions and 24 deletions

View File

@ -101,7 +101,7 @@ if ($backup->enforce_changed_dependencies()) {
echo $renderer->dependency_notification(get_string('dependenciesenforced','backup'));
}
echo $renderer->progress_bar($backup->get_progress_bar());
echo $backup->display();
echo $backup->display($renderer);
$backup->destroy();
unset($backup);
echo $OUTPUT->footer();

View File

@ -157,7 +157,7 @@ if ($backup->enforce_changed_dependencies()) {
echo $renderer->dependency_notification(get_string('dependenciesenforced','backup'));
}
echo $renderer->progress_bar($backup->get_progress_bar());
echo $backup->display();
echo $backup->display($renderer);
$backup->destroy();
unset($backup);
echo $OUTPUT->footer();

View File

@ -2249,7 +2249,11 @@ class restore_block_instance_structure_step extends restore_structure_step {
// If there is already one block of that type in the parent context
// and the block is not multiple, stop processing
// Use blockslib loader / method executor
if (!block_method_result($data->blockname, 'instance_allow_multiple')) {
if (!$bi = block_instance($data->blockname)) {
return false;
}
if (!$bi->instance_allow_multiple()) {
if ($DB->record_exists_sql("SELECT bi.id
FROM {block_instances} bi
JOIN {block} b ON b.name = bi.blockname

View File

@ -410,7 +410,7 @@ class backup_ui_stage_final extends backup_ui_stage {
/**
* should NEVER be called... throws an exception
*/
public function display() {
public function display(core_backup_renderer $renderer) {
throw new backup_ui_exception('backup_ui_must_execute_first');
}
}
@ -444,13 +444,13 @@ class backup_ui_stage_complete extends backup_ui_stage_final {
/**
* Displays the completed backup stage.
*
* Currently this just envolves redirecting to the file browser with an
* Currently this just involves redirecting to the file browser with an
* appropriate message.
*
* @global core_renderer $OUTPUT
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
global $OUTPUT;
public function display(core_backup_renderer $renderer) {
// Get the resulting stored_file record
$type = $this->get_ui()->get_controller()->get_type();
@ -468,9 +468,12 @@ class backup_ui_stage_complete extends backup_ui_stage_final {
$restorerul = new moodle_url('/backup/restorefile.php', array('contextid'=>$coursecontext->id));
}
echo $OUTPUT->box_start();
echo $OUTPUT->notification(get_string('executionsuccess', 'backup'), 'notifysuccess');
echo $OUTPUT->continue_button($restorerul);
echo $OUTPUT->box_end();
$output = '';
$output .= $renderer->box_start();
$output .= $renderer->notification(get_string('executionsuccess', 'backup'), 'notifysuccess');
$output .= $renderer->continue_button($restorerul);
$output .= $renderer->box_end();
return $output;
}
}

View File

@ -140,14 +140,14 @@ abstract class base_ui {
/**
* Displays the UI for the backup!
*
* @throws base_ui_exception
* @return string HTML code
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
public function display(core_backup_renderer $renderer) {
if ($this->progress < self::PROGRESS_SAVED) {
throw new base_ui_exception('backupsavebeforedisplay');
}
return $this->stage->display();
return $this->stage->display($renderer);
}
/**
* Gets all backup tasks from the controller

View File

@ -115,9 +115,10 @@ abstract class base_ui_stage {
* By default this involves instantiating the form for the stage and the calling
* it to display.
*
* @return string HTML code to display
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
public function display(core_backup_renderer $renderer) {
$form = $this->initialise_stage_form();
// a nasty hack follows to work around the sad fact that moodle quickforms

View File

@ -133,8 +133,11 @@ class import_ui_stage_confirmation extends backup_ui_stage_confirmation {
*
* This function is overriden so that we can manipulate the strings on the
* buttons.
*
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
public function display(core_backup_renderer $renderer) {
$form = $this->initialise_stage_form();
$form->require_definition_after_data();
if ($e = $form->get_element('submitbutton')) {
@ -147,7 +150,16 @@ class import_ui_stage_confirmation extends backup_ui_stage_confirmation {
}
}
}
// a nasty hack follows to work around the sad fact that moodle quickforms
// do not allow to actually return the HTML content, just to echo it
flush();
ob_start();
$form->display();
$output = ob_get_contents();
ob_end_clean();
return $output;
}
}
/**

View File

@ -289,7 +289,7 @@ class restore_ui extends base_ui {
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
if ($this->progress < self::PROGRESS_SAVED) {
throw new base_ui_exception('backupsavebeforedisplay');
}

View File

@ -95,7 +95,7 @@ abstract class restore_ui_stage extends base_ui_stage {
abstract class restore_ui_independent_stage {
abstract public function __construct($contextid);
abstract public function process();
abstract public function display($renderer);
abstract public function display(core_backup_renderer $renderer);
abstract public function get_stage();
/**
* Gets an array of progress bar items that can be displayed through the restore renderer.
@ -177,7 +177,7 @@ class restore_ui_stage_confirm extends restore_ui_independent_stage {
* @param core_backup_renderer $renderer renderer instance to use
* @return string HTML code
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
$prevstageurl = new moodle_url('/backup/restorefile.php', array('contextid' => $this->contextid));
$nextstageurl = new moodle_url('/backup/restore.php', array(
@ -262,7 +262,7 @@ class restore_ui_stage_destination extends restore_ui_independent_stage {
* @param core_backup_renderer $renderer renderer instance to use
* @return string HTML code
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
$format = backup_general_helper::detect_backup_format($this->filepath);
@ -676,7 +676,7 @@ class restore_ui_stage_process extends restore_ui_stage {
* @param core_backup_renderer $renderer renderer instance to use
* @return string HTML code
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
global $PAGE;
$html = '';
@ -752,6 +752,7 @@ class restore_ui_stage_complete extends restore_ui_stage_process {
* appropriate message.
*
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display(core_backup_renderer $renderer) {