Skip to content

Commit

Permalink
MDL-57590 mod_forum: fixed search form with forumid and actionurl.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Churchward committed Jan 16, 2017
1 parent d97582f commit d679a45
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
4 changes: 4 additions & 0 deletions mod/forum/classes/output/big_search_form.php
Expand Up @@ -53,6 +53,8 @@ class big_search_form implements renderable, templatable {
public $subject;
public $user;
public $words;
/** @var string The URL of the search form. */
public $actionurl;

/**
* Constructor.
Expand All @@ -65,6 +67,7 @@ public function __construct($course) {
$this->course = $course;
$this->scripturl = new moodle_url('/mod/forum/forum.js');
$this->showfullwords = $DB->get_dbfamily() == 'mysql' || $DB->get_dbfamily() == 'postgres';
$this->actionurl = new moodle_url('/mod/forum/search.php');

$forumoptions = ['' => get_string('allforums', 'forum')] + forum_menu_list($course);
$this->forumoptions = array_map(function($option) use ($forumoptions) {
Expand Down Expand Up @@ -161,6 +164,7 @@ public function export_for_template(renderer_base $output) {
$data->subject = $this->subject;
$data->user = $this->user;
$data->showfullwords = $this->showfullwords;
$data->actionurl = $this->actionurl->out(false);

$datefrom = $this->datefrom;
if (empty($datefrom)) {
Expand Down
33 changes: 32 additions & 1 deletion mod/forum/templates/big_search_form.mustache
Expand Up @@ -15,7 +15,38 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/big_search_form
Big search form.
Example context (json):
{
"scripturl": "https://example.com/mod/forum/forum.js",
"actionurl": "https://example.com/mod/forum/search.php",
"courseid": "2",
"words": "apples",
"phrase": "Lorem ipsum dolor",
"notwords": "Not these words",
"showfullwords": [
{
"fullwords": "Exactly"
}
],
"datefromchecked": 1,
"datetochecked": "",
"forumoptions": [
{
"name": "Forum One",
"value": "23"
},
{
"name": "Forum Two",
"value": "34"
}
],
"subject": "Help me please",
"user": "Helpy McUser"
}
}}
<div id="intro" class="box searchbox boxaligncenter">
{{#str}}searchforumintro, forum{{/str}}
Expand Down Expand Up @@ -92,7 +123,7 @@
<label for="menuforumid">{{#str}}searchwhichforums, forum{{/str}}</label>
</td>
<td class="c1">
<select name="menuforumid" id="menuforumid">
<select name="forumid" id="menuforumid">
{{#forumoptions}}
<option value="{{value}}">{{name}}</option>
{{/forumoptions}}
Expand Down
33 changes: 32 additions & 1 deletion theme/boost/templates/mod_forum/big_search_form.mustache
Expand Up @@ -15,7 +15,38 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/big_search_form
Big search form.
Example context (json):
{
"scripturl": "https://example.com/mod/forum/forum.js",
"actionurl": "https://example.com/mod/forum/search.php",
"courseid": "2",
"words": "apples",
"phrase": "Lorem ipsum dolor",
"notwords": "Not these words",
"showfullwords": [
{
"fullwords": "Exactly"
}
],
"datefromchecked": 1,
"datetochecked": "",
"forumoptions": [
{
"name": "Forum One",
"value": "23"
},
{
"name": "Forum Two",
"value": "34"
}
],
"subject": "Help me please",
"user": "Helpy McUser"
}
}}
<div id="intro" class="box searchbox boxaligncenter">
{{#str}}searchforumintro, forum{{/str}}
Expand Down Expand Up @@ -92,7 +123,7 @@
<label for="menuforumid">{{#str}}searchwhichforums, forum{{/str}}</label>
</td>
<td class="c1">
<select name="menuforumid" id="menuforumid" class="form-control">
<select name="forumid" id="menuforumid" class="form-control">
{{#forumoptions}}
<option value="{{value}}">{{name}}</option>
{{/forumoptions}}
Expand Down

0 comments on commit d679a45

Please sign in to comment.