Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   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.
   8  //
   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.
  13  //
  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/>.
  16  
  17  /**
  18   * Course summary block
  19   *
  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
  23   */
  24  
  25  class block_course_summary extends block_base {
  26  
  27      /**
  28       * @var bool Flag to indicate whether the header should be hidden or not.
  29       */
  30      private $headerhidden = true;
  31  
  32      function init() {
  33          $this->title = get_string('pluginname', 'block_course_summary');
  34      }
  35  
  36      function applicable_formats() {
  37          return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false);
  38      }
  39  
  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;
  45          }
  46      }
  47  
  48      function get_content() {
  49          global $CFG, $OUTPUT;
  50  
  51          require_once($CFG->libdir . '/filelib.php');
  52  
  53          if($this->content !== NULL) {
  54              return $this->content;
  55          }
  56  
  57          if (empty($this->instance)) {
  58              return '';
  59          }
  60  
  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 = '';
  69  
  70          return $this->content;
  71      }
  72  
  73      function hide_header() {
  74          return $this->headerhidden;
  75      }
  76  
  77  }
  78  
  79