Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are 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   * Block to search forum posts.
  19   *
  20   * @package   block_search_forums
  21   * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  class block_search_forums extends block_base {
  26      function init() {
  27          $this->title = get_string('pluginname', 'block_search_forums');
  28      }
  29  
  30      function get_content() {
  31          global $CFG, $OUTPUT;
  32  
  33          if($this->content !== NULL) {
  34              return $this->content;
  35          }
  36  
  37          $this->content = new stdClass;
  38          $this->content->footer = '';
  39  
  40          if (empty($this->instance)) {
  41              $this->content->text   = '';
  42              return $this->content;
  43          }
  44  
  45          $output = $this->page->get_renderer('block_search_forums');
  46          $searchform = new \block_search_forums\output\search_form($this->page->course->id);
  47          $this->content->text = $output->render($searchform);
  48  
  49          return $this->content;
  50      }
  51  
  52      function applicable_formats() {
  53          return array('site' => true, 'course' => true);
  54      }
  55  
  56      /**
  57       * Returns the role that best describes the forum search block.
  58       *
  59       * @return string
  60       */
  61      public function get_aria_role() {
  62          return 'search';
  63      }
  64  }
  65  
  66