3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Displays help via AJAX call or in a new page
21 * Use {@link core_renderer::help_icon()} or {@link addHelpButton()} to display
24 * @copyright 2002 onwards Martin Dougiamas
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29 define('NO_MOODLE_COOKIES', true);
31 require_once(dirname(__FILE__
) . '/config.php');
33 $identifier = required_param('identifier', PARAM_STRINGID
);
34 $component = required_param('component', PARAM_COMPONENT
);
35 $lang = required_param('lang', PARAM_LANG
); // TODO: maybe split into separate scripts
36 $ajax = optional_param('ajax', 0, PARAM_BOOL
);
41 $SESSION->lang
= $lang; // does not actually modify session because we do not use cookies here
43 $sm = get_string_manager();
45 $PAGE->set_url('/help.php');
46 $PAGE->set_pagelayout('popup');
47 $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM
));
50 @header
('Content-Type: text/plain; charset=utf-8');
52 echo $OUTPUT->header();
55 if (!$sm->string_exists($identifier.'_help', $component)) {
56 // strings on-diskc cache may be dirty - try to rebuild it and check again
57 $sm->load_component_strings($component, current_language(), true);
60 if ($sm->string_exists($identifier.'_help', $component)) {
61 $options = new stdClass();
62 $options->trusted
= false;
63 $options->noclean
= false;
64 $options->smiley
= false;
65 $options->filter
= false;
66 $options->para
= true;
67 $options->newlines
= false;
68 $options->overflowdiv
= !$ajax;
70 echo $OUTPUT->heading(format_string(get_string($identifier, $component)), 1, 'helpheading');
71 // Should be simple wiki only MDL-21695
72 echo format_text(get_string($identifier.'_help', $component), FORMAT_MARKDOWN
, $options);
74 if ($sm->string_exists($identifier.'_link', $component)) { // Link to further info in Moodle docs
75 $link = get_string($identifier.'_link', $component);
76 $linktext = get_string('morehelp');
77 echo '<div class="helpdoclink">'.$OUTPUT->doc_link($link, $linktext).'</div>';
81 echo "<p><strong>TODO</strong>: missing help string [{$identifier}_help, $component]</p>";
85 echo $OUTPUT->footer();