[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/blocks/course_summary/ -> block_course_summary.php (source)

   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          if ($this->page->user_is_editing()) {
  69              if($this->page->course->id == SITEID) {
  70                  $editpage = $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=frontpagesettings';
  71              } else {
  72                  $editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->page->course->id;
  73              }
  74              $this->content->text .= "<div class=\"editbutton\"><a href=\"$editpage\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" alt=\"".get_string('edit')."\" /></a></div>";
  75          }
  76          $this->content->footer = '';
  77  
  78          return $this->content;
  79      }
  80  
  81      function hide_header() {
  82          return $this->headerhidden;
  83      }
  84  
  85  }
  86  
  87  


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1