mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-69454 core_search: consistent mod searches
This commit is contained in:
parent
411cf64738
commit
4c71e1d0d0
34
lib/templates/checkbox.mustache
Normal file
34
lib/templates/checkbox.mustache
Normal file
@ -0,0 +1,34 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core/checkbox
|
||||
|
||||
Chooser search template.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "fullsearch",
|
||||
"id": "fullsearch",
|
||||
"checked": true,
|
||||
"value": "1",
|
||||
"label": "Reset options"
|
||||
}
|
||||
}}
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" name={{{ name }}} class="custom-control-input" value={{{ value }}} id="{{{ id }}}" {{#checked}} checked="checked" {{/checked}}>
|
||||
<label class="custom-control-label" for="{{{ id }}}">{{{ label }}}</label>
|
||||
</div>
|
@ -62,5 +62,8 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{{#otherfields}}
|
||||
<div class="ml-2">{{{ otherfields }}}</div>
|
||||
{{/otherfields}}
|
||||
</form>
|
||||
</div>
|
@ -63,11 +63,16 @@ class quick_search_form implements renderable, templatable {
|
||||
}
|
||||
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$hiddenfields = [
|
||||
(object) ['name' => 'id', 'value' => $this->courseid],
|
||||
];
|
||||
$data = [
|
||||
'actionurl' => $this->actionurl->out(false),
|
||||
'courseid' => $this->courseid,
|
||||
'action' => $this->actionurl->out(false),
|
||||
'hiddenfields' => $hiddenfields,
|
||||
'query' => $this->query,
|
||||
'helpicon' => $this->helpicon->export_for_template($output),
|
||||
'inputname' => 'search',
|
||||
'searchstring' => get_string('searchforums', 'mod_forum')
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
@ -21,27 +21,14 @@
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"actionurl": "https://domain.example/mod/forum/search.php",
|
||||
"courseid": "2",
|
||||
"action": "https://domain.example/mod/forum/search.php",
|
||||
"helpicon": "<a class='btn'><i class='icon fa fa-question-circle'></i></a>",
|
||||
"query": "find this post"
|
||||
"query": "find this post",
|
||||
"inputname": "search"
|
||||
}
|
||||
}}
|
||||
<div class="forumsearch">
|
||||
<form action="{{actionurl}}" class="form-inline">
|
||||
<input type="hidden" name="id" value="{{courseid}}">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
{{#helpicon}}
|
||||
{{>core/help_icon}}
|
||||
{{/helpicon}}
|
||||
</div>
|
||||
<label class="sr-only" for="search">{{#str}}search, forum{{/str}}</label>
|
||||
<input id="search" name="search" type="text" class="form-control" value="{{query}}">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-secondary" id="searchforums" type="submit">{{#str}}searchforums, mod_forum{{/str}}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
{{#helpicon}}
|
||||
{{>core/help_icon}}
|
||||
{{/helpicon}}
|
||||
{{< core/search_input }}
|
||||
{{/ core/search_input }}
|
||||
|
@ -380,27 +380,35 @@ if ($glossary->intro && $showcommonelements) {
|
||||
|
||||
/// Search box
|
||||
if ($showcommonelements ) {
|
||||
echo '<form method="post" class="form form-inline mb-1" action="' . $CFG->wwwroot . '/mod/glossary/view.php">';
|
||||
|
||||
|
||||
if ($mode == 'search') {
|
||||
echo '<input type="text" name="hook" size="20" value="'.s($hook).'" alt="'.$strsearch.'" class="form-control"/> ';
|
||||
} else {
|
||||
echo '<input type="text" name="hook" size="20" value="" alt="'.$strsearch.'" class="form-control"/> ';
|
||||
}
|
||||
echo '<input type="submit" value="'.$strsearch.'" name="searchbutton" class="btn btn-secondary mr-1"/> ';
|
||||
$fullsearchchecked = false;
|
||||
if ($fullsearch || $mode != 'search') {
|
||||
$fullsearchchecked = 'checked="checked"';
|
||||
} else {
|
||||
$fullsearchchecked = '';
|
||||
$fullsearchchecked = true;
|
||||
}
|
||||
echo '<span class="checkbox"><label for="fullsearch">';
|
||||
echo ' <input type="checkbox" name="fullsearch" id="fullsearch" value="1" '.$fullsearchchecked.'/> ';
|
||||
echo '<input type="hidden" name="mode" value="search" />';
|
||||
echo '<input type="hidden" name="id" value="'.$cm->id.'" />';
|
||||
echo $strsearchindefinition.'</label></span>';
|
||||
|
||||
echo '</form>';
|
||||
$check = [
|
||||
'name' => 'fullsearch',
|
||||
'id' => 'fullsearch',
|
||||
'value' => '1',
|
||||
'checked' => $fullsearchchecked,
|
||||
'label' => $strsearchindefinition
|
||||
];
|
||||
|
||||
$checkbox = $OUTPUT->render_from_template('core/checkbox', $check);
|
||||
|
||||
$hiddenfields = [
|
||||
(object) ['name' => 'id', 'value' => $cm->id],
|
||||
(object) ['name' => 'mode', 'value' => 'search'],
|
||||
];
|
||||
$data = [
|
||||
'action' => new moodle_url('/mod/glossary/view.php'),
|
||||
'hiddenfields' => $hiddenfields,
|
||||
'otherfields' => $checkbox,
|
||||
'inputname' => 'hook',
|
||||
'query' => ($mode == 'search') ? s($hook) : '',
|
||||
'searchstring' => get_string('search'),
|
||||
'extraclasses' => 'my-2'
|
||||
];
|
||||
echo $OUTPUT->render_from_template('core/search_input', $data);
|
||||
}
|
||||
|
||||
/// Show the add entry button if allowed
|
||||
|
@ -441,28 +441,36 @@ function wiki_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for wiki
|
||||
*
|
||||
* @param stdClass $cm course module object
|
||||
* @param string $search searchword.
|
||||
* @param stdClass $subwiki Optional Subwiki.
|
||||
* @return Search wiki input form
|
||||
*/
|
||||
function wiki_search_form($cm, $search = '', $subwiki = null) {
|
||||
global $CFG, $OUTPUT;
|
||||
global $OUTPUT;
|
||||
|
||||
$output = '<div class="wikisearch">';
|
||||
$output .= '<form method="post" action="' . $CFG->wwwroot . '/mod/wiki/search.php" style="display:inline">';
|
||||
$output .= '<fieldset class="invisiblefieldset">';
|
||||
$output .= '<legend class="accesshide">'. get_string('searchwikis', 'wiki') .'</legend>';
|
||||
$output .= '<label class="accesshide" for="searchwiki">' . get_string("searchterms", "wiki") . '</label>';
|
||||
$output .= '<input id="searchwiki" name="searchstring" type="text" size="18" value="' . s($search, true) . '" alt="search" />';
|
||||
$output .= '<input name="courseid" type="hidden" value="' . $cm->course . '" />';
|
||||
$output .= '<input name="cmid" type="hidden" value="' . $cm->id . '" />';
|
||||
$hiddenfields = [
|
||||
(object) ['type' => 'hidden', 'name' => 'courseid', 'value' => $cm->course],
|
||||
(object) ['type' => 'hidden', 'name' => 'cmid', 'value' => $cm->id],
|
||||
(object) ['type' => 'hidden', 'name' => 'searchwikicontent', 'value' => 1],
|
||||
];
|
||||
if (!empty($subwiki->id)) {
|
||||
$output .= '<input name="subwikiid" type="hidden" value="' . $subwiki->id . '" />';
|
||||
$hiddenfields[] = (object) ['type' => 'hidden', 'name' => 'subwikiid', 'value' => $subwiki->id];
|
||||
}
|
||||
$output .= '<input name="searchwikicontent" type="hidden" value="1" />';
|
||||
$output .= '<input value="' . get_string('searchwikis', 'wiki') . '" class="btn btn-secondary" type="submit" />';
|
||||
$output .= '</fieldset>';
|
||||
$output .= '</form>';
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
$data = [
|
||||
'action' => new moodle_url('/mod/wiki/search.php'),
|
||||
'hiddenfields' => $hiddenfields,
|
||||
'inputname' => 'searchstring',
|
||||
'query' => s($search, true),
|
||||
'searchstring' => get_string('searchwikis', 'wiki'),
|
||||
'extraclasses' => 'mt-2'
|
||||
];
|
||||
return $OUTPUT->render_from_template('core/search_input', $data);
|
||||
}
|
||||
|
||||
function wiki_extend_navigation(navigation_node $navref, $course, $module, $cm) {
|
||||
global $CFG, $PAGE, $USER;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user