Skip to content

Commit

Permalink
MDL-72413 forum: Use the common module for setting the header
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Dias committed Dec 13, 2021
1 parent 93782ec commit ab40bc5
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 25 deletions.
8 changes: 4 additions & 4 deletions mod/folder/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
$PAGE->set_heading($course->fullname);
$PAGE->set_activity_record($folder);
$PAGE->set_secondary_active_tab('modulepage');

$PAGE->activityheader->set_attrs([
'hidecompletion' => true,
'description' => ''
]);
$data = new stdClass();
$data->id = $cm->id;
$maxbytes = get_user_max_upload_file_size($context, $CFG->maxbytes);
Expand Down Expand Up @@ -79,9 +82,6 @@
}

echo $OUTPUT->header();
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($folder->name));
}
echo $OUTPUT->box_start('generalbox foldertree');
$mform->display();
echo $OUTPUT->box_end();
Expand Down
1 change: 1 addition & 0 deletions mod/forum/discuss.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
$isnestedv2displaymode = $displaymode == FORUM_MODE_NESTED_V2;
$PAGE->set_title("$course->shortname: " . format_string($discussion->get_name()));
$PAGE->set_heading($course->fullname);
$PAGE->activityheader->disable();
if ($isnestedv2displaymode) {
$PAGE->add_body_class('nested-v2-display-mode reset-style');
$settingstrigger = $OUTPUT->render_from_template('mod_forum/settings_drawer_trigger', null);
Expand Down
1 change: 1 addition & 0 deletions mod/forum/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function($exportdata) use ($fields, $striphtml, $humandates, $canviewfullname, $
$PAGE->set_title($pagetitle);
$PAGE->set_pagelayout('admin');
$PAGE->set_heading($pagetitle);
$PAGE->activityheader->disable();

echo $OUTPUT->header();
if (!$PAGE->has_secondary_navigation()) {
Expand Down
13 changes: 5 additions & 8 deletions mod/forum/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -1094,11 +1094,12 @@
$PAGE->set_title("{$course->shortname}: {$strdiscussionname}{$titlesubject}");
$PAGE->set_heading($course->fullname);
$PAGE->set_secondary_active_tab("modulepage");

echo $OUTPUT->header();
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($forum->name), 2);
$activityheaderconfig['hidecompletion'] = true;
if (!empty($parententity)) {
$activityheaderconfig['description'] = '';
}
$PAGE->activityheader->set_attrs($activityheaderconfig);
echo $OUTPUT->header();

// Checkup.
if (!empty($parententity) && !$capabilitymanager->can_view_post($USER, $discussionentity, $parententity)) {
Expand Down Expand Up @@ -1141,10 +1142,6 @@
$rendererfactory = mod_forum\local\container::get_renderer_factory();
$postsrenderer = $rendererfactory->get_single_discussion_posts_renderer(FORUM_MODE_THREADED, true);
echo $postsrenderer->render($USER, [$forumentity], [$discussionentity], $postentities);
} else {
if (!empty($forum->intro)) {
echo $OUTPUT->box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro');
}
}

// Call print disclosure for enabled plagiarism plugins.
Expand Down
1 change: 1 addition & 0 deletions mod/forum/report/summary/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
$PAGE->set_pagelayout('report');
$PAGE->set_title($title);
$PAGE->set_heading($course->fullname);
$PAGE->activityheader->disable();
$PAGE->navbar->add(get_string('nodetitle', 'forumreport_summary'));

// Activate the secondary nav tab.
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/subscribers.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@

// Output starts from here.
$actionbar = new \mod_forum\output\subscription_actionbar($id, $url, $forum);
$PAGE->activityheader->disable();
echo $OUTPUT->header();
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(get_string('forum', 'forum') . ' ' . $strsubscribers);
}
echo $forumoutput->subscription_actionbar($actionbar);


if ($edit === 0) {
$subscribers = \mod_forum\subscriptions::fetch_subscribed_users($forum, $currentgroup, $context);
if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
Expand Down
21 changes: 9 additions & 12 deletions mod/forum/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,21 @@
]) . ': ' . format_string($forum->get_name());
rss_add_http_header($forum->get_context(), 'mod_forum', $forumrecord, $rsstitle);
}

// Output starts from here.
echo $OUTPUT->header();
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($forum->get_name()), 2);
$activityheader = $PAGE->activityheader;
$pageheader = [];
if ($activityheader->is_title_allowed()) {
$pageheader['title'] = format_string($forum->get_name());
}

// Render the activity information.
$completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id);
$activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id);
echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates);

// Fetch the current groupid.
$groupid = groups_get_activity_group($cm, true) ?: null;

if (!$istypesingle && !empty($forum->get_intro())) {
echo $OUTPUT->box(format_module_intro('forum', $forumrecord, $cm->id), 'generalbox', 'intro');
if ($istypesingle || empty($forum->get_intro())) {
$pageheader['description'] = '';
}
$activityheader->set_attrs($pageheader);

echo $OUTPUT->header();

$rendererfactory = mod_forum\local\container::get_renderer_factory();
// The elements for view action are rendered and added to the page.
Expand Down

0 comments on commit ab40bc5

Please sign in to comment.