4 * help.php - Displays help page.
6 * Prints a very simple page and includes
7 * page content or a string from elsewhere.
8 * Usually this will appear in a popup
9 * See {@link helpbutton()} in {@link lib/moodlelib.php}
11 * @author Martin Dougiamas
17 require_once('config.php');
19 $file = optional_param('file', '', PARAM_CLEAN
);
20 $text = optional_param('text', 'No text to display', PARAM_CLEAN
);
21 $module = optional_param('module', 'moodle', PARAM_ALPHAEXT
);
25 if (detect_munged_arguments($module .'/'. $file)) {
26 error('Filenames contain illegal characters!');
29 print_simple_box_start('center', '96%');
32 $langs = array(current_language(), get_string('parentlanguage'), 'en'); // Fallback
35 foreach ($langs as $lang) {
39 if ($module == 'moodle') {
40 if ($lang == 'en_utf8') {
41 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/'. $file;
43 $filepath = $CFG->dataroot
.'/lang/'. $lang .'/help/'. $file;
46 if ($lang == 'en_utf8') {
47 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/'. $module .'/'. $file;
49 $filepath = $CFG->dataroot
.'/lang/'. $lang .'/help/'. $module .'/'. $file;
50 if (!file_exists($filepath)) {
51 $filepath = $CFG->dirroot
.'/lang/en_utf8/help/'. $module .'/'. $file;
54 if (!file_exists($filepath)) {
55 $filepath = $CFG->dirroot
.'/mod/'.$module.'/lang/'. $lang .'/help/'. $module .'/'. $file;
59 if (file_exists($filepath)) {
61 include($filepath); // The actual helpfile
63 if ($module == 'moodle' and ($file == 'index.html' or $file == 'mods.html')) {
64 // include file for each module
66 if (!$modules = get_records('modules', 'visible', 1)) {
67 error('No modules found!!'); // Should never happen
70 foreach ($modules as $mod) {
71 $strmodulename = get_string('modulename', $mod->name
);
72 $modulebyname[$strmodulename] = $mod;
76 foreach ($modulebyname as $mod) {
77 foreach ($langs as $lang) {
81 if ($lang == 'en_utf8') {
82 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/'. $mod->name
.'/'. $file;
84 $filepath = $CFG->dataroot
.'/lang/'. $lang .'/help/'. $mod->name
.'/'. $file;
87 if (file_exists($filepath)) {
88 echo '<hr size="1" />';
89 include($filepath); // The actual helpfile
96 // Some horrible hardcoded stuff follows, should be delegated to modules to handle
98 if ($module == 'moodle' and ($file == 'resource/types.html')) { // RESOURCES
99 require_once($CFG->dirroot
.'/mod/resource/lib.php');
100 $typelist = resource_get_resource_types();
101 $typelist['label'] = get_string('resourcetypelabel', 'resource');
103 foreach ($typelist as $type => $name) {
104 foreach ($langs as $lang) {
108 if ($lang == 'en_utf8') {
109 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/resource/type/'. $type .'.html';
111 $filepath = $CFG->dataroot
.'/lang/'. $lang .'/help/resource/type/'. $type .'.html';
113 if (file_exists($filepath)) {
114 echo '<hr size="1" />';
115 include($filepath); // The actual helpfile
121 if ($module == 'moodle' and ($file == 'assignment/types.html')) { // ASSIGNMENTS
122 require_once($CFG->dirroot
.'/mod/assignment/lib.php');
123 $typelist = assignment_types();
125 foreach ($typelist as $type => $name) {
126 echo '<p><b>'.$name.'</b></p>';
127 echo get_string('help'.$type, 'assignment');
128 echo '<hr size="1" />';
135 echo '<p>'.s($text).'</p>'; // This param was already cleaned
139 print_simple_box_end();
142 //$file = clean_text($file); // Keep it clean!
143 notify('Help file "'. $file .'" could not be found!');
146 close_window_button();
148 echo '<p align="center"><a href="help.php?file=index.html">'. get_string('helpindex') .'</a></p>';
149 print_footer('none');