Merge branch 'MDL-87694-course-participant-profile-missing-heading-M5.0' of https://github.com/stopfstedt/moodle into MOODLE_500_STABLE

This commit is contained in:
Jun Pataleta
2026-02-03 15:18:08 +08:00
5 changed files with 56 additions and 20 deletions
@@ -0,0 +1,9 @@
issueNumber: MDL-87694
notes:
core:
- message: >-
`\core\output\core_renderer::confirm()`'s `$displayoptions` parameter
now also accepts a `headinglevel` option that developers can use to
specify the heading level of the confirmation's heading. If not
specified, the confirmation heading will be rendered in an `h4` tag.
type: changed
+4 -1
View File
@@ -111,8 +111,11 @@ class context_header implements renderable, templatable {
*/
public function export_for_template(renderer_base $output): array {
// Heading.
$heading = '';
$headingtext = isset($this->heading) ? $this->heading : $output->get_page()->heading;
$heading = $output->heading($headingtext, $this->headinglevel, "h2 mb-0");
if ('' !== $headingtext) {
$heading = $output->heading($headingtext, $this->headinglevel, "h2 mb-0");
}
// Buttons.
if (isset($this->additionalbuttons)) {
+24 -12
View File
@@ -1684,23 +1684,35 @@ class core_renderer extends renderer_base {
return $this->action_link($url, $text . $icon, $action, $attributes);
}
/**
* Print a message along with button choices for Continue/Cancel
*
* If a string or moodle_url is given instead of a single_button, method defaults to post.
*
* @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
*/
/**
* Print a message along with button choices for Continue/Cancel
*
* If a string or moodle_url is given instead of a single_button, method defaults to post.
*
* @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 Display options (Optional).
* Possible options:
* - confirmtitle: The title to display above the message
* - continuestr: The label to use for the continue button (if $continue is not a single_button)
* - cancelstr: The label to use for the cancel button (if $cancel is not a single_button)
* - headinglevel: The heading level to use for the title (1-6). Default is 4.
* - type: The button type to use for the continue button (if $continue is not a single_button). Default is BUTTON_PRIMARY.
* @return string HTML fragment
*/
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');
$headinglevel = $displayoptions['headinglevel'] ?? 4;
if ($headinglevel < 1 || $headinglevel > 6) {
throw new coding_exception('The headinglevel option to $OUTPUT->confirm() must be between 1 and 6.');
}
if ($continue instanceof single_button) {
// Continue button should be primary if set to secondary type as it is the fefault.
@@ -1745,7 +1757,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', $displayoptions['confirmtitle']);
$output .= html_writer::tag('h' . $headinglevel, $displayoptions['confirmtitle'], ['class' => 'h4']);
$output .= $this->box_end();
$attributes = [
'role' => 'alert',
+10 -4
View File
@@ -50,11 +50,17 @@ if (!empty($CFG->forceloginforprofiles)) {
require_login();
if (isguestuser()) {
$PAGE->set_context(context_system::instance());
$PAGE->set_title(get_string('user'));
$PAGE->set_title(get_string('loginrequired'));
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('guestcantaccessprofiles', 'error'),
get_login_url(),
$CFG->wwwroot);
echo $OUTPUT->confirm(
get_string('guestcantaccessprofiles', 'error'),
get_login_url(),
$CFG->wwwroot,
[
'headinglevel' => 1,
'confirmtitle' => get_string('loginrequired'),
],
);
echo $OUTPUT->footer();
die;
}
+9 -3
View File
@@ -68,9 +68,15 @@ if (!empty($CFG->forceloginforprofiles)) {
$PAGE->set_secondary_navigation(false);
$PAGE->set_title(get_string('loginrequired'));
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('guestcantaccessprofiles', 'error'),
get_login_url(),
$CFG->wwwroot);
echo $OUTPUT->confirm(
get_string('guestcantaccessprofiles', 'error'),
get_login_url(),
$CFG->wwwroot,
[
'headinglevel' => 1,
'confirmtitle' => get_string('loginrequired'),
],
);
echo $OUTPUT->footer();
die;
}