block_course_summary.php 1.8 KB
Newer Older
1
<?php
2

defacer's avatar
   
defacer committed
3
class block_course_summary extends block_base {
4
    function init() {
5
        $this->title = get_string('pluginname', 'block_course_summary');
6
7
    }

8
    function specialization() {
9
        if($this->page->pagetype == PAGE_COURSE_VIEW && $this->page->course->id != SITEID) {
10
11
12
13
            $this->title = get_string('coursesummary', 'block_course_summary');
        }
    }

14
    function get_content() {
15
        global $CFG, $OUTPUT;
16

17
18
19
20
        if($this->content !== NULL) {
            return $this->content;
        }

21
        if (empty($this->instance)) {
22
23
24
            return '';
        }

25
26
        $this->content = new stdClass();
        $options = new stdClass();
moodler's avatar
moodler committed
27
        $options->noclean = true;    // Don't clean Javascripts etc
28
        $options->overflowdiv = true;
29
        $context = get_context_instance(CONTEXT_COURSE, $this->page->course->id);
30
        $this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
31
        $this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
32
33
        if ($this->page->user_is_editing()) {
            if($this->page->course->id == SITEID) {
34
                $editpage = $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=frontpagesettings';
gustav_delius's avatar
gustav_delius committed
35
            } else {
36
                $editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->page->course->id;
gustav_delius's avatar
gustav_delius committed
37
            }
38
            $this->content->text .= "<div class=\"editbutton\"><a href=\"$editpage\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" alt=\"".get_string('edit')."\" /></a></div>";
39
        }
40
        $this->content->footer = '';
41
42
43
44

        return $this->content;
    }

moodler's avatar
moodler committed
45
46
47
    function hide_header() {
        return true;
    }
48
49
50
51
52

    function preferred_width() {
        return 210;
    }

53
54
}

55