MDL-38788 behat: Generic form elements interaction compatibile with JS disabled
[moodle.git] / blocks / course_summary / block_course_summary.php
CommitLineData
4ca6cfbf 1<?php
0f3fe4b6 2
e89d741a 3class block_course_summary extends block_base {
9b4b78fd 4 function init() {
bdd7b93e 5 $this->title = get_string('pluginname', 'block_course_summary');
89adb174 6 }
7
bfe20414
MN
8 function applicable_formats() {
9 return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false);
10 }
11
9b4b78fd 12 function specialization() {
cb640229 13 if($this->page->pagetype == PAGE_COURSE_VIEW && $this->page->course->id != SITEID) {
9b4b78fd 14 $this->title = get_string('coursesummary', 'block_course_summary');
15 }
16 }
17
0f3fe4b6 18 function get_content() {
4096752d 19 global $CFG, $OUTPUT;
0f3fe4b6 20
99d19c13
PS
21 require_once($CFG->libdir . '/filelib.php');
22
6757c3cd 23 if($this->content !== NULL) {
24 return $this->content;
25 }
26
9b4b78fd 27 if (empty($this->instance)) {
675dbdd9 28 return '';
29 }
30
dd4bee83
PS
31 $this->content = new stdClass();
32 $options = new stdClass();
f28a2913 33 $options->noclean = true; // Don't clean Javascripts etc
367a75fa 34 $options->overflowdiv = true;
fe2fdd11 35 $context = context_course::instance($this->page->course->id);
64f93798 36 $this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
8bdc9cac 37 $this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
cb640229 38 if ($this->page->user_is_editing()) {
39 if($this->page->course->id == SITEID) {
275d8b36 40 $editpage = $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=frontpagesettings';
1ca17d43 41 } else {
cb640229 42 $editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->page->course->id;
1ca17d43 43 }
b5d0cafc 44 $this->content->text .= "<div class=\"editbutton\"><a href=\"$editpage\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" alt=\"".get_string('edit')."\" /></a></div>";
9b88d1a0 45 }
89adb174 46 $this->content->footer = '';
0f3fe4b6 47
48 return $this->content;
49 }
50
3e1fc10f 51 function hide_header() {
52 return true;
53 }
389a4df9 54
55 function preferred_width() {
56 return 210;
57 }
58
0f3fe4b6 59}
60
4ca6cfbf 61