2009-11-01 12:00:47 +00:00
|
|
|
<?php
|
2014-02-13 10:55:46 +13:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Course summary block
|
|
|
|
*
|
|
|
|
* @package block_course_summary
|
|
|
|
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-11-23 18:53:34 +00:00
|
|
|
class block_course_summary extends block_base {
|
2015-10-23 23:50:01 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool Flag to indicate whether the header should be hidden or not.
|
|
|
|
*/
|
|
|
|
private $headerhidden = true;
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
function init() {
|
2010-04-11 11:17:02 +00:00
|
|
|
$this->title = get_string('pluginname', 'block_course_summary');
|
2004-05-28 10:53:54 +00:00
|
|
|
}
|
|
|
|
|
2012-11-29 14:12:58 +08:00
|
|
|
function applicable_formats() {
|
|
|
|
return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false);
|
|
|
|
}
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
function specialization() {
|
2015-10-23 23:50:01 -05:00
|
|
|
// Page type starts with 'course-view' and the page's course ID is not equal to the site ID.
|
|
|
|
if (strpos($this->page->pagetype, PAGE_COURSE_VIEW) === 0 && $this->page->course->id != SITEID) {
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->title = get_string('coursesummary', 'block_course_summary');
|
2015-10-23 23:50:01 -05:00
|
|
|
$this->headerhidden = false;
|
2004-10-19 21:04:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-18 23:20:53 +00:00
|
|
|
function get_content() {
|
2009-07-02 10:06:39 +00:00
|
|
|
global $CFG, $OUTPUT;
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2011-01-23 18:34:41 +01:00
|
|
|
require_once($CFG->libdir . '/filelib.php');
|
|
|
|
|
2004-04-19 09:36:07 +00:00
|
|
|
if($this->content !== NULL) {
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
if (empty($this->instance)) {
|
2004-08-11 09:00:53 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2010-09-21 08:10:17 +00:00
|
|
|
$this->content = new stdClass();
|
|
|
|
$options = new stdClass();
|
2004-09-03 03:39:50 +00:00
|
|
|
$options->noclean = true; // Don't clean Javascripts etc
|
2010-11-05 02:53:47 +00:00
|
|
|
$options->overflowdiv = true;
|
2012-07-23 15:55:09 +08:00
|
|
|
$context = context_course::instance($this->page->course->id);
|
2010-07-03 13:37:13 +00:00
|
|
|
$this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
|
2009-11-04 06:14:06 +00:00
|
|
|
$this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
|
2004-05-28 10:53:54 +00:00
|
|
|
$this->content->footer = '';
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
2004-07-30 06:34:11 +00:00
|
|
|
function hide_header() {
|
2015-10-23 23:50:01 -05:00
|
|
|
return $this->headerhidden;
|
2004-07-30 06:34:11 +00:00
|
|
|
}
|
2004-08-09 13:23:32 +00:00
|
|
|
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
2009-11-01 12:00:47 +00:00
|
|
|
|