block_course_summary.php 2.78 KB
Newer Older
1
<?php
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// 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
 */
24

defacer's avatar
   
defacer committed
25
class block_course_summary extends block_base {
26
    function init() {
27
        $this->title = get_string('pluginname', 'block_course_summary');
28
29
    }

30
31
32
33
    function applicable_formats() {
        return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false);
    }

34
    function specialization() {
35
        if($this->page->pagetype == PAGE_COURSE_VIEW && $this->page->course->id != SITEID) {
36
37
38
39
            $this->title = get_string('coursesummary', 'block_course_summary');
        }
    }

40
    function get_content() {
41
        global $CFG, $OUTPUT;
42

43
44
        require_once($CFG->libdir . '/filelib.php');

45
46
47
48
        if($this->content !== NULL) {
            return $this->content;
        }

49
        if (empty($this->instance)) {
50
51
52
            return '';
        }

53
54
        $this->content = new stdClass();
        $options = new stdClass();
moodler's avatar
moodler committed
55
        $options->noclean = true;    // Don't clean Javascripts etc
56
        $options->overflowdiv = true;
57
        $context = context_course::instance($this->page->course->id);
58
        $this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
59
        $this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
60
61
        if ($this->page->user_is_editing()) {
            if($this->page->course->id == SITEID) {
62
                $editpage = $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=frontpagesettings';
gustav_delius's avatar
gustav_delius committed
63
            } else {
64
                $editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->page->course->id;
gustav_delius's avatar
gustav_delius committed
65
            }
66
            $this->content->text .= "<div class=\"editbutton\"><a href=\"$editpage\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" alt=\"".get_string('edit')."\" /></a></div>";
67
        }
68
        $this->content->footer = '';
69
70
71
72

        return $this->content;
    }

moodler's avatar
moodler committed
73
74
75
    function hide_header() {
        return true;
    }
76

77
78
}

79