2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
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
{
28 * @var bool Flag to indicate whether the header should be hidden or not.
30 private $headerhidden = true;
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() {
51 require_once($CFG->libdir
. '/filelib.php');
53 if($this->content
!== NULL) {
54 return $this->content
;
57 if (empty($this->instance
)) {
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
;