mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
The display() method in backup/restore UI returns the HTML rather then echoing it
This implementation uses a hacky trick with the output buffer unless someone finds a time to add support for returning the HTML from quickforms.
This commit is contained in:
parent
383f6f63c7
commit
4eb2a097c5
3 changed files with 23 additions and 11 deletions
|
@ -140,16 +140,14 @@ abstract class base_ui {
|
||||||
/**
|
/**
|
||||||
* Displays the UI for the backup!
|
* Displays the UI for the backup!
|
||||||
*
|
*
|
||||||
* Note: The UI makes use of mforms (ewww!) thus it will automatically print
|
* @throws base_ui_exception
|
||||||
* out the result rather than returning a string of HTML like other parts of Moodle
|
* @return string HTML code
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function display() {
|
public function display() {
|
||||||
if ($this->progress < self::PROGRESS_SAVED) {
|
if ($this->progress < self::PROGRESS_SAVED) {
|
||||||
throw new base_ui_exception('backupsavebeforedisplay');
|
throw new base_ui_exception('backupsavebeforedisplay');
|
||||||
}
|
}
|
||||||
$this->stage->display();
|
return $this->stage->display();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets all backup tasks from the controller
|
* Gets all backup tasks from the controller
|
||||||
|
|
|
@ -108,17 +108,29 @@ abstract class base_ui_stage {
|
||||||
final public function get_uniqueid() {
|
final public function get_uniqueid() {
|
||||||
return $this->ui->get_uniqueid();
|
return $this->ui->get_uniqueid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the stage.
|
* Displays the stage.
|
||||||
*
|
*
|
||||||
* By default this involves instantiating the form for the stage and the calling
|
* By default this involves instantiating the form for the stage and the calling
|
||||||
* it to display. Remember this is a moodleform instance so it will print
|
* it to display.
|
||||||
* rather than return.
|
*
|
||||||
|
* @return string HTML code to display
|
||||||
*/
|
*/
|
||||||
public function display() {
|
public function display() {
|
||||||
|
|
||||||
$form = $this->initialise_stage_form();
|
$form = $this->initialise_stage_form();
|
||||||
|
// 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();
|
$form->display();
|
||||||
|
$output = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the stage.
|
* Processes the stage.
|
||||||
*
|
*
|
||||||
|
|
|
@ -252,13 +252,15 @@ class restore_ui extends base_ui {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Displays this stage
|
* Displays this stage
|
||||||
|
*
|
||||||
* @param core_backup_renderer $renderer
|
* @param core_backup_renderer $renderer
|
||||||
|
* @return string HTML code to echo
|
||||||
*/
|
*/
|
||||||
public function display($renderer) {
|
public function display($renderer) {
|
||||||
if ($this->progress < self::PROGRESS_SAVED) {
|
if ($this->progress < self::PROGRESS_SAVED) {
|
||||||
throw new base_ui_exception('backupsavebeforedisplay');
|
throw new base_ui_exception('backupsavebeforedisplay');
|
||||||
}
|
}
|
||||||
$this->stage->display($renderer);
|
return $this->stage->display($renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue