Merge branch 'MDL-81457-main' of https://github.com/andrewnicols/moodle
[moodle.git] / blocks / course_summary / block_course_summary.php
blob516c36081d27a157d3d2f87fc890e7fb118d784b
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Course summary block
20 * @package block_course_summary
21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 class block_course_summary extends block_base {
27 /**
28 * @var bool Flag to indicate whether the header should be hidden or not.
30 private $headerhidden = true;
32 function init() {
33 $this->title = get_string('pluginname', 'block_course_summary');
36 function applicable_formats() {
37 return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false);
40 function specialization() {
41 // Page type starts with 'course-view' and the page's course ID is not equal to the site ID.
42 if (strpos($this->page->pagetype, PAGE_COURSE_VIEW) === 0 && $this->page->course->id != SITEID) {
43 $this->title = get_string('coursesummary', 'block_course_summary');
44 $this->headerhidden = false;
48 function get_content() {
49 global $CFG, $OUTPUT;
51 require_once($CFG->libdir . '/filelib.php');
53 if($this->content !== NULL) {
54 return $this->content;
57 if (empty($this->instance)) {
58 return '';
61 $this->content = new stdClass();
62 $options = new stdClass();
63 $options->noclean = true; // Don't clean Javascripts etc
64 $options->overflowdiv = true;
65 $context = context_course::instance($this->page->course->id);
66 $this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
67 $this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
68 $this->content->footer = '';
70 return $this->content;
73 function hide_header() {
74 return $this->headerhidden;