MDL-63445 core_renderer: display course image in context header

This commit is contained in:
Bas Brands
2018-10-23 09:41:26 +02:00
parent cc486e6125
commit a7712a9851
10 changed files with 88 additions and 3 deletions
+9 -1
View File
@@ -4141,7 +4141,7 @@ EOD;
}
public function context_header($headerinfo = null, $headinglevel = 1) {
global $DB, $USER, $CFG;
global $DB, $USER, $CFG, $COURSE;
require_once($CFG->dirroot . '/user/lib.php');
$context = $this->page->context;
$heading = null;
@@ -4152,6 +4152,14 @@ EOD;
if (isset($headerinfo['heading'])) {
$heading = $headerinfo['heading'];
}
// Show a course image if enabled.
if ($context->contextlevel == CONTEXT_COURSE && get_config('moodlecourse', 'showcourseimages')) {
$exporter = new core_course\external\course_summary_exporter($COURSE, ['context' => $context]);
$courseinfo = $exporter->export($this);
$imagedata = $this->render_from_template('core/course_header_image', $courseinfo);
}
// The user context currently has images and buttons. Other contexts may follow.
if (isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) {
if (isset($headerinfo['user'])) {