Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   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  namespace format_topics\output;
  18  
  19  use core_courseformat\output\section_renderer;
  20  use moodle_page;
  21  
  22  /**
  23   * Basic renderer for topics format.
  24   *
  25   * @copyright 2012 Dan Poltawski
  26   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  27   */
  28  class renderer extends section_renderer {
  29  
  30      /**
  31       * Constructor method, calls the parent constructor.
  32       *
  33       * @param moodle_page $page
  34       * @param string $target one of rendering target constants
  35       */
  36      public function __construct(moodle_page $page, $target) {
  37          parent::__construct($page, $target);
  38  
  39          // Since format_topics_renderer::section_edit_control_items() only displays the 'Highlight' control
  40          // when editing mode is on we need to be sure that the link 'Turn editing mode on' is available for a user
  41          // who does not have any other managing capability.
  42          $page->set_other_editing_capability('moodle/course:setcurrentsection');
  43      }
  44  
  45      /**
  46       * Generate the section title, wraps it in a link to the section page if page is to be displayed on a separate page.
  47       *
  48       * @param section_info|stdClass $section The course_section entry from DB
  49       * @param stdClass $course The course entry from DB
  50       * @return string HTML to output.
  51       */
  52      public function section_title($section, $course) {
  53          return $this->render(course_get_format($course)->inplace_editable_render_section_name($section));
  54      }
  55  
  56      /**
  57       * Generate the section title to be displayed on the section page, without a link.
  58       *
  59       * @param section_info|stdClass $section The course_section entry from DB
  60       * @param int|stdClass $course The course entry from DB
  61       * @return string HTML to output.
  62       */
  63      public function section_title_without_link($section, $course) {
  64          return $this->render(course_get_format($course)->inplace_editable_render_section_name($section, false));
  65      }
  66  }