MDL-55474 block_search_forums: Convert search form to templates
[moodle.git] / blocks / search_forums / block_search_forums.php
CommitLineData
4ca6cfbf 1<?php
f25a6839
SH
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 */
0f3fe4b6 24
e89d741a 25class block_search_forums extends block_base {
9b4b78fd 26 function init() {
adb04fa3 27 $this->title = get_string('pluginname', 'block_search_forums');
0f3fe4b6 28 }
29
30 function get_content() {
25c56af8 31 global $CFG, $OUTPUT;
ef4ee349 32
0f3fe4b6 33 if($this->content !== NULL) {
34 return $this->content;
35 }
36
ef4ee349 37 $this->content = new stdClass;
38 $this->content->footer = '';
39
9b4b78fd 40 if (empty($this->instance)) {
ef4ee349 41 $this->content->text = '';
675dbdd9 42 return $this->content;
43 }
44
270dd871
FM
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);
0f3fe4b6 48
0f3fe4b6 49 return $this->content;
50 }
0d6b9d4f 51
52 function applicable_formats() {
53 return array('site' => true, 'course' => true);
54 }
697f7bd7
SH
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 }
0f3fe4b6 64}
65
4ca6cfbf 66