[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/blocks/search_forums/ -> block_search_forums.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   * 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          $advancedsearch = get_string('advancedsearch', 'block_search_forums');
  46  
  47          $strsearch  = get_string('search');
  48          $strgo      = get_string('go');
  49  
  50          $this->content->text  = '<div class="searchform">';
  51          $this->content->text .= '<form action="'.$CFG->wwwroot.'/mod/forum/search.php" style="display:inline"><fieldset class="invisiblefieldset">';
  52          $this->content->text .= '<legend class="accesshide">'.$strsearch.'</legend>';
  53          $this->content->text .= '<input name="id" type="hidden" value="'.$this->page->course->id.'" />';  // course
  54          $this->content->text .= '<label class="accesshide" for="searchform_search">'.$strsearch.'</label>'.
  55                                  '<input id="searchform_search" name="search" type="text" size="16" />';
  56          $this->content->text .= '<button id="searchform_button" type="submit" title="'.$strsearch.'">'.$strgo.'</button><br />';
  57          $this->content->text .= '<a href="'.$CFG->wwwroot.'/mod/forum/search.php?id='.$this->page->course->id.'">'.$advancedsearch.'</a>';
  58          $this->content->text .= $OUTPUT->help_icon('search');
  59          $this->content->text .= '</fieldset></form></div>';
  60  
  61          return $this->content;
  62      }
  63  
  64      function applicable_formats() {
  65          return array('site' => true, 'course' => true);
  66      }
  67  
  68      /**
  69       * Returns the role that best describes the forum search block.
  70       *
  71       * @return string
  72       */
  73      public function get_aria_role() {
  74          return 'search';
  75      }
  76  }
  77  
  78  


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