Commit | Line | Data |
---|---|---|
822a1063 | 1 | <?php |
ff95caa8 DM |
2 | |
3 | // This file is part of Moodle - http://moodle.org/ | |
4 | // | |
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. | |
9 | // | |
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. | |
14 | // | |
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/>. | |
17 | ||
6be7abc7 | 18 | /** |
ff95caa8 | 19 | * Displays help via AJAX call or in a new page |
6be7abc7 | 20 | * |
ff95caa8 DM |
21 | * Use {@link core_renderer::help_icon()} or {@link addHelpButton()} to display |
22 | * the help icon. | |
6be7abc7 | 23 | * |
ff95caa8 DM |
24 | * @copyright 2002 onwards Martin Dougiamas |
25 | * @package core | |
26 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
6be7abc7 | 27 | */ |
53a78cef PS |
28 | |
29 | define('NO_MOODLE_COOKIES', true); | |
30 | ||
ff95caa8 | 31 | require_once(dirname(__FILE__) . '/config.php'); |
6be7abc7 | 32 | |
ff95caa8 | 33 | $identifier = required_param('identifier', PARAM_STRINGID); |
aff24313 | 34 | $component = required_param('component', PARAM_COMPONENT); |
e4c3c7ea | 35 | $lang = required_param('lang', PARAM_LANG); // TODO: maybe split into separate scripts |
259c165d | 36 | $ajax = optional_param('ajax', 0, PARAM_BOOL); |
53a78cef PS |
37 | |
38 | if (!$lang) { | |
39 | $lang = 'en'; | |
40 | } | |
53a78cef | 41 | $SESSION->lang = $lang; // does not actually modify session because we do not use cookies here |
3a915b06 | 42 | |
259c165d | 43 | $sm = get_string_manager(); |
6be7abc7 | 44 | |
259c165d | 45 | $PAGE->set_url('/help.php'); |
5435c9dc | 46 | $PAGE->set_pagelayout('popup'); |
bf0f06b1 | 47 | $PAGE->set_context(context_system::instance()); |
259c165d PS |
48 | |
49 | if ($ajax) { | |
50 | @header('Content-Type: text/plain; charset=utf-8'); | |
51 | } else { | |
52 | echo $OUTPUT->header(); | |
53a78cef | 53 | } |
868ca14f | 54 | |
ed8eb15a DM |
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); | |
58 | } | |
59 | ||
5435c9dc | 60 | if ($sm->string_exists($identifier.'_help', $component)) { |
a226a972 | 61 | $options = new stdClass(); |
5435c9dc MD |
62 | $options->trusted = false; |
63 | $options->noclean = false; | |
64 | $options->smiley = false; | |
65 | $options->filter = false; | |
66 | $options->para = true; | |
67 | $options->newlines = false; | |
367a75fa | 68 | $options->overflowdiv = !$ajax; |
5435c9dc | 69 | |
ff95caa8 | 70 | echo $OUTPUT->heading(format_string(get_string($identifier, $component)), 1, 'helpheading'); |
5435c9dc | 71 | // Should be simple wiki only MDL-21695 |
4be9b128 | 72 | echo format_text(get_string($identifier.'_help', $component), FORMAT_MARKDOWN, $options); |
5435c9dc MD |
73 | |
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>'; | |
78 | } | |
79 | ||
259c165d | 80 | } else { |
ff95caa8 | 81 | echo "<p><strong>TODO</strong>: missing help string [{$identifier}_help, $component]</p>"; |
259c165d PS |
82 | } |
83 | ||
84 | if (!$ajax) { | |
85 | echo $OUTPUT->footer(); | |
86 | } |