1 |
efrain |
1 |
{{!
|
|
|
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 |
@template mod_forum/big_search_form
|
|
|
19 |
|
|
|
20 |
Big search form.
|
|
|
21 |
|
|
|
22 |
Example context (json):
|
|
|
23 |
{
|
|
|
24 |
"actionurl": "https://example.com/mod/forum/search.php",
|
|
|
25 |
"courseid": "2",
|
|
|
26 |
"words": "apples",
|
|
|
27 |
"phrase": "Lorem ipsum dolor",
|
|
|
28 |
"notwords": "Not these words",
|
|
|
29 |
"showfullwords": [
|
|
|
30 |
{
|
|
|
31 |
"fullwords": "Exactly"
|
|
|
32 |
}
|
|
|
33 |
],
|
|
|
34 |
"datefromchecked": 1,
|
|
|
35 |
"datetochecked": "",
|
|
|
36 |
"forumoptions": [
|
|
|
37 |
{
|
|
|
38 |
"name": "Forum One",
|
|
|
39 |
"value": "23"
|
|
|
40 |
},
|
|
|
41 |
{
|
|
|
42 |
"name": "Forum Two",
|
|
|
43 |
"value": "34"
|
|
|
44 |
}
|
|
|
45 |
],
|
|
|
46 |
"subject": "Help me please",
|
|
|
47 |
"user": "Helpy McUser"
|
|
|
48 |
}
|
|
|
49 |
}}
|
|
|
50 |
<div id="intro" class="box searchbox boxaligncenter">
|
|
|
51 |
{{#str}}searchforumintro, forum{{/str}}
|
|
|
52 |
</div>
|
|
|
53 |
<div class="box generalbox boxaligncenter">
|
|
|
54 |
<form id="searchform" class="mform" action="{{actionurl}}" method="get">
|
|
|
55 |
<table class="searchbox table table-striped" id="form">
|
|
|
56 |
<tr>
|
|
|
57 |
<td class="c0 text-xs-right align-bottom">
|
|
|
58 |
<label for="words">{{#str}}searchwords, forum{{/str}}</label>
|
|
|
59 |
<input type="hidden" value="{{courseid}}" name="id">
|
|
|
60 |
</td>
|
|
|
61 |
<td class="c1">
|
|
|
62 |
<input type="text" class="form-control" name="words" id="words" value="{{words}}">
|
|
|
63 |
</td>
|
|
|
64 |
</tr>
|
|
|
65 |
<tr>
|
|
|
66 |
<td class="c0 text-xs-right align-bottom">
|
|
|
67 |
<label for="phrase">{{#str}}searchphrase, forum{{/str}}</label>
|
|
|
68 |
</td>
|
|
|
69 |
<td class="c1">
|
|
|
70 |
<input type="text" class="form-control" name="phrase" id="phrase" value="{{phrase}}">
|
|
|
71 |
</td>
|
|
|
72 |
</tr>
|
|
|
73 |
<tr>
|
|
|
74 |
<td class="c0 text-xs-right align-bottom">
|
|
|
75 |
<label for="notwords">{{#str}}searchnotwords, forum{{/str}}</label>
|
|
|
76 |
</td>
|
|
|
77 |
<td class="c1">
|
|
|
78 |
<input type="text" class="form-control" name="notwords" id="notwords" value="{{notwords}}">
|
|
|
79 |
</td>
|
|
|
80 |
</tr>
|
|
|
81 |
{{#showfullwords}}
|
|
|
82 |
<tr>
|
|
|
83 |
<td class="c0 text-xs-right align-bottom">
|
|
|
84 |
<label for="fullwords">{{#str}}searchfullwords, forum{{/str}}</label>
|
|
|
85 |
</td>
|
|
|
86 |
<td class="c1">
|
|
|
87 |
<input type="text" class="form-control" name="fullwords" id="fullwords" value="{{fullwords}}">
|
|
|
88 |
</td>
|
|
|
89 |
</tr>
|
|
|
90 |
{{/showfullwords}}
|
|
|
91 |
<tr>
|
|
|
92 |
<td class="c0 text-xs-right align-bottom">
|
|
|
93 |
<label for="timefromrestrict">{{#str}}searchdatefrom, forum{{/str}}</label>
|
|
|
94 |
</td>
|
|
|
95 |
<td class="c1 text-nowrap d-flex flex-wrap align-items-center">
|
|
|
96 |
<div class="fdate_time_selector d-flex flex-wrap align-items-center">
|
|
|
97 |
<input type="checkbox" name="timefromrestrict" value="1" {{#datefromchecked}}checked{{/datefromchecked}}>
|
|
|
98 |
{{{datefromfields}}}
|
|
|
99 |
</div>
|
|
|
100 |
<input type="hidden" name="hfromday" value="0">
|
|
|
101 |
<input type="hidden" name="hfrommonth" value="0">
|
|
|
102 |
<input type="hidden" name="hfromyear" value="0">
|
|
|
103 |
<input type="hidden" name="hfromhour" value="0">
|
|
|
104 |
<input type="hidden" name="hfromminute" value="0">
|
|
|
105 |
</td>
|
|
|
106 |
</tr>
|
|
|
107 |
<tr>
|
|
|
108 |
<td class="c0 text-xs-right align-bottom">
|
|
|
109 |
<label for="timetorestrict">{{#str}}searchdateto, forum{{/str}}</label>
|
|
|
110 |
</td>
|
|
|
111 |
<td class="c1 text-nowrap d-flex flex-wrap align-items-center">
|
|
|
112 |
<div class="fdate_time_selector d-flex flex-wrap align-items-center">
|
|
|
113 |
<input type="checkbox" name="timetorestrict" value="1" {{#datetochecked}}checked{{/datetochecked}}>
|
|
|
114 |
{{{datetofields}}}
|
|
|
115 |
</div>
|
|
|
116 |
<input type="hidden" name="htoday" value="0">
|
|
|
117 |
<input type="hidden" name="htomonth" value="0">
|
|
|
118 |
<input type="hidden" name="htoyear" value="0">
|
|
|
119 |
<input type="hidden" name="htohour" value="0">
|
|
|
120 |
<input type="hidden" name="htominute" value="0">
|
|
|
121 |
</td>
|
|
|
122 |
</tr>
|
|
|
123 |
<tr>
|
|
|
124 |
<td class="c0 text-xs-right align-bottom">
|
|
|
125 |
<label for="menuforumid">{{#str}}searchwhichforums, forum{{/str}}</label>
|
|
|
126 |
</td>
|
|
|
127 |
<td class="c1">
|
|
|
128 |
<select name="forumid" id="menuforumid" class="form-control custom-select">
|
|
|
129 |
{{#forumoptions}}
|
|
|
130 |
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
|
|
131 |
{{/forumoptions}}
|
|
|
132 |
</select>
|
|
|
133 |
</td>
|
|
|
134 |
</tr>
|
|
|
135 |
<tr>
|
|
|
136 |
<td class="c0 text-xs-right align-bottom">
|
|
|
137 |
<label for="subject">{{#str}}searchsubject, forum{{/str}}</label>
|
|
|
138 |
</td>
|
|
|
139 |
<td class="c1">
|
|
|
140 |
<input type="text" class="form-control" name="subject" id="subject" value="{{subject}}">
|
|
|
141 |
</td>
|
|
|
142 |
</tr>
|
|
|
143 |
<tr>
|
|
|
144 |
<td class="c0 text-xs-right align-bottom">
|
|
|
145 |
<label for="user">{{#str}}searchuser, forum{{/str}}</label>
|
|
|
146 |
</td>
|
|
|
147 |
<td class="c1">
|
|
|
148 |
<input type="text" class="form-control" name="user" id="user" value="{{user}}">
|
|
|
149 |
</td>
|
|
|
150 |
</tr>
|
|
|
151 |
{{^guestuser}}
|
|
|
152 |
<tr>
|
|
|
153 |
<td class="c0 text-xs-right align-bottom">
|
|
|
154 |
<label for="starredonly">{{#str}}starredonly, forum{{/str}}</label>
|
|
|
155 |
</td>
|
|
|
156 |
<td class="c1 align-middle d-flex flex-wrap align-items-center">
|
|
|
157 |
<input type="checkbox" class="form-control" name="starredonly" id="starredonly" value="1" {{#starredonly}}checked{{/starredonly}} />
|
|
|
158 |
</td>
|
|
|
159 |
</tr>
|
|
|
160 |
{{/guestuser}}
|
|
|
161 |
{{#tagsenabled}}
|
|
|
162 |
<tr>
|
|
|
163 |
<td class="c0">
|
|
|
164 |
<label for="tags" class="mt-1">{{#str}}searchtags, forum{{/str}}</label>
|
|
|
165 |
</td>
|
|
|
166 |
<td class="c1">
|
|
|
167 |
<select class="custom-select" name="tags[]"
|
|
|
168 |
id="tags" multiple>
|
|
|
169 |
{{#tagoptions}}
|
|
|
170 |
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{{text}}}</option>
|
|
|
171 |
{{/tagoptions}}
|
|
|
172 |
</select>
|
|
|
173 |
</td>
|
|
|
174 |
</tr>
|
|
|
175 |
{{/tagsenabled}}
|
|
|
176 |
<tr>
|
|
|
177 |
<td> </td>
|
|
|
178 |
<td class="submit">
|
|
|
179 |
<button type="submit" class="btn btn-primary">{{#str}}searchforums, forum{{/str}}</button>
|
|
|
180 |
</td>
|
|
|
181 |
</tr>
|
|
|
182 |
</table>
|
|
|
183 |
</form>
|
|
|
184 |
</div>
|
|
|
185 |
{{#js}}
|
|
|
186 |
require(['jquery'], function($) {
|
|
|
187 |
var toggleDateFields = function(prefix, disabled) {
|
|
|
188 |
$('#searchform select[name^=' + prefix + ']').prop('disabled', disabled);
|
|
|
189 |
$('#searchform input[name^=h' + prefix + ']').val(disabled ? 1 : 0);
|
|
|
190 |
};
|
|
|
191 |
|
|
|
192 |
toggleDateFields('from', !$("#searchform input[name='timefromrestrict']").prop('checked'));
|
|
|
193 |
$("#searchform input[name='timefromrestrict']").click(function() {
|
|
|
194 |
toggleDateFields('from', !this.checked);
|
|
|
195 |
});
|
|
|
196 |
|
|
|
197 |
toggleDateFields('to', !$("#searchform input[name='timetorestrict']").prop('checked'));
|
|
|
198 |
$("#searchform input[name='timetorestrict']").click(function() {
|
|
|
199 |
toggleDateFields('to', !this.checked);
|
|
|
200 |
});
|
|
|
201 |
});
|
|
|
202 |
{{/js}}
|