mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-72112 output: Add new displayoption parameter to confirm function
This commit is contained in:
parent
18b2af60f5
commit
1f450065a6
@ -1995,16 +1995,23 @@ class core_renderer extends renderer_base {
|
||||
* @param string $message The question to ask the user
|
||||
* @param single_button|moodle_url|string $continue The single_button component representing the Continue answer. Can also be a moodle_url or string URL
|
||||
* @param single_button|moodle_url|string $cancel The single_button component representing the Cancel answer. Can also be a moodle_url or string URL
|
||||
* @param array $displayoptions optional extra display options
|
||||
* @return string HTML fragment
|
||||
*/
|
||||
public function confirm($message, $continue, $cancel) {
|
||||
public function confirm($message, $continue, $cancel, array $displayoptions = []) {
|
||||
|
||||
// Check existing displayoptions.
|
||||
$displayoptions['confirmtitle'] = $displayoptions['confirmtitle'] ?? get_string('confirm');
|
||||
$displayoptions['continuestr'] = $displayoptions['continuestr'] ?? get_string('continue');
|
||||
$displayoptions['cancelstr'] = $displayoptions['cancelstr'] ?? get_string('cancel');
|
||||
|
||||
if ($continue instanceof single_button) {
|
||||
// ok
|
||||
$continue->primary = true;
|
||||
} else if (is_string($continue)) {
|
||||
$continue = new single_button(new moodle_url($continue), get_string('continue'), 'post', true);
|
||||
$continue = new single_button(new moodle_url($continue), $displayoptions['continuestr'], 'post', true);
|
||||
} else if ($continue instanceof moodle_url) {
|
||||
$continue = new single_button($continue, get_string('continue'), 'post', true);
|
||||
$continue = new single_button($continue, $displayoptions['continuestr'], 'post', true);
|
||||
} else {
|
||||
throw new coding_exception('The continue param to $OUTPUT->confirm() must be either a URL (string/moodle_url) or a single_button instance.');
|
||||
}
|
||||
@ -2012,9 +2019,9 @@ class core_renderer extends renderer_base {
|
||||
if ($cancel instanceof single_button) {
|
||||
// ok
|
||||
} else if (is_string($cancel)) {
|
||||
$cancel = new single_button(new moodle_url($cancel), get_string('cancel'), 'get');
|
||||
$cancel = new single_button(new moodle_url($cancel), $displayoptions['cancelstr'], 'get');
|
||||
} else if ($cancel instanceof moodle_url) {
|
||||
$cancel = new single_button($cancel, get_string('cancel'), 'get');
|
||||
$cancel = new single_button($cancel, $displayoptions['cancelstr'], 'get');
|
||||
} else {
|
||||
throw new coding_exception('The cancel param to $OUTPUT->confirm() must be either a URL (string/moodle_url) or a single_button instance.');
|
||||
}
|
||||
@ -2029,7 +2036,7 @@ class core_renderer extends renderer_base {
|
||||
$output = $this->box_start('generalbox modal modal-dialog modal-in-page show', 'notice', $attributes);
|
||||
$output .= $this->box_start('modal-content', 'modal-content');
|
||||
$output .= $this->box_start('modal-header px-3', 'modal-header');
|
||||
$output .= html_writer::tag('h4', get_string('confirm'));
|
||||
$output .= html_writer::tag('h4', $displayoptions['confirmtitle']);
|
||||
$output .= $this->box_end();
|
||||
$attributes = [
|
||||
'role'=>'alert',
|
||||
|
@ -128,6 +128,8 @@ completely removed from Moodle core too.
|
||||
-get_safe_orderby() - where a single sort parameter is required.
|
||||
-get_safe_orderby_multiple() - where multiple sort parameters are required.
|
||||
* Added the cleanstr mustache template helper to clean strings after loading them from language packs.
|
||||
* A new parameter $displayoptions has been added to the core_renderer::confirm() to allow better customization for confirming page
|
||||
such as the title and strings for continue and cancel buttons.
|
||||
|
||||
=== 3.11.4 ===
|
||||
* A new option dontforcesvgdownload has been added to the $options parameter of the send_file() function.
|
||||
|
Loading…
x
Reference in New Issue
Block a user