MDL-55074 theme_boost: Navigation and blocks
[moodle.git] / admin / search.php
CommitLineData
20207b82 1<?php
1857cd7f 2
3// searches for admin settings
4
5require_once('../config.php');
6require_once($CFG->libdir.'/adminlib.php');
7
1d8bf5f0 8$query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string
9
bf006d2c 10$PAGE->set_context(context_system::instance());
3506dfa2
SH
11
12admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page
30f6bd51 13
4d933beb 14$adminroot = admin_get_root(); // need all settings here
220a90c5 15$adminroot->search = $query; // So we can reference it in search boxes later in this invocation
da259fa1 16$statusmsg = '';
220a90c5 17$errormsg = '';
18$focus = '';
da259fa1 19
220a90c5 20// now we'll deal with the case that the admin has submitted the form with changed settings
294ce987 21if ($data = data_submitted() and confirm_sesskey()) {
220a90c5 22 if (admin_write_settings($data)) {
9c489dbc 23 redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
220a90c5 24 }
1857cd7f 25
220a90c5 26 if (!empty($adminroot->errors)) {
27 $errormsg = get_string('errorwithsettings', 'admin');
28 $firsterror = reset($adminroot->errors);
29 $focus = $firsterror->id;
9c489dbc
BH
30 } else {
31 redirect($PAGE->url);
1857cd7f 32 }
1857cd7f 33}
34
35// and finally, if we get here, then there are matching settings and we have to print a form
36// to modify them
61ef8f9f 37echo $OUTPUT->header($focus);
1857cd7f 38
99061152
DW
39echo $OUTPUT->heading(get_string('administrationsite'));
40
220a90c5 41if ($errormsg !== '') {
8fbce1c8 42 echo $OUTPUT->notification($errormsg);
220a90c5 43
44} else if ($statusmsg !== '') {
8fbce1c8 45 echo $OUTPUT->notification($statusmsg, 'notifysuccess');
da259fa1 46}
47
99061152
DW
48require_once("admin_settings_search_form.php");
49$form = new admin_settings_search_form();
50$form->display();
51echo '<hr>';
52
53if ($query) {
54 echo admin_search_settings_html($query);
55} else {
56 $node = $PAGE->settingsnav->find('root', navigation_node::TYPE_SITE_ADMIN);
57 if ($node) {
58 echo $OUTPUT->render_from_template('core/settings_link_page', ['node' => $node]);
59 }
60}
1857cd7f 61
73d6f52f 62echo $OUTPUT->footer();