Merge branch 'wip_MDL-57590_master_forum_search' of https://github.com/mchurchward/moodle

This commit is contained in:
Andrew Nicols 2017-01-18 08:36:58 +08:00
commit 3dc3305936
3 changed files with 68 additions and 2 deletions

View File

@ -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.
@ -65,6 +67,7 @@ class big_search_form implements renderable, templatable {
$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) {
@ -161,6 +164,7 @@ class big_search_form implements renderable, templatable {
$data->subject = $this->subject;
$data->user = $this->user;
$data->showfullwords = $this->showfullwords;
$data->actionurl = $this->actionurl->out(false);
$datefrom = $this->datefrom;
if (empty($datefrom)) {

View File

@ -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}}
@ -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}}

View File

@ -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}}
@ -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}}