diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 4e18268cba4..ec3aa463e65 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -4922,6 +4922,47 @@ class core_renderer_maintenance extends core_renderer { } + /** + * Overridden confirm message for upgrades. + * + * @param string $message The question to ask the user + * @param single_button|moodle_url|string $continue The single_button component representing the Continue answer. + * @param single_button|moodle_url|string $cancel The single_button component representing the Cancel answer. + * @return string HTML fragment + */ + public function confirm($message, $continue, $cancel) { + // We need plain styling of confirm boxes on upgrade because we don't know which stylesheet we have (it could be + // from any previous version of Moodle). + if ($continue instanceof single_button) { + $continue->primary = true; + } else if (is_string($continue)) { + $continue = new single_button(new moodle_url($continue), get_string('continue'), 'post', true); + } else if ($continue instanceof moodle_url) { + $continue = new single_button($continue, get_string('continue'), '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.'); + } + + if ($cancel instanceof single_button) { + $output = ''; + } else if (is_string($cancel)) { + $cancel = new single_button(new moodle_url($cancel), get_string('cancel'), 'get'); + } else if ($cancel instanceof moodle_url) { + $cancel = new single_button($cancel, get_string('cancel'), '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.'); + } + + $output = $this->box_start('generalbox', 'notice'); + $output .= html_writer::tag('h4', get_string('confirm')); + $output .= html_writer::tag('p', $message); + $output .= html_writer::tag('div', $this->render($continue) . $this->render($cancel), array('class' => 'buttons')); + $output .= $this->box_end(); + return $output; + } + /** * Does nothing. The maintenance renderer does not support JS. * diff --git a/theme/bootstrapbase/less/moodle/admin.less b/theme/bootstrapbase/less/moodle/admin.less index 3fe8f59329b..0b31b18eb78 100644 --- a/theme/bootstrapbase/less/moodle/admin.less +++ b/theme/bootstrapbase/less/moodle/admin.less @@ -204,7 +204,21 @@ img.iconsmall { .modal.modal-in-page { position: static; z-index: 0; - margin: 0; + margin: 0 auto 0 auto; +} + +// We need to keep this rule because confirm messages during upgrade use it. We can never change it because we don't +// serve new stylesheets until after upgrade. +#page-admin-index #notice { + width: 60%; + min-width: 220px; + margin: auto; + + .buttons { + padding-left: 0; + padding-right: 0; + text-align: center; + } } #page-admin-index .releasenoteslink, diff --git a/theme/bootstrapbase/style/moodle.css b/theme/bootstrapbase/style/moodle.css index c9b970d1eae..b483c98e3ca 100644 --- a/theme/bootstrapbase/style/moodle.css +++ b/theme/bootstrapbase/style/moodle.css @@ -2789,7 +2789,17 @@ img.iconsmall { .modal.modal-in-page { position: static; z-index: 0; - margin: 0; + margin: 0 auto 0 auto; +} +#page-admin-index #notice { + width: 60%; + min-width: 220px; + margin: auto; +} +#page-admin-index #notice .buttons { + padding-left: 0; + padding-right: 0; + text-align: center; } #page-admin-index .releasenoteslink, #page-admin-index .adminwarning,