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 optional_variable($file, '');
20 optional_variable($text, 'No text to display');
21 optional_variable($module, 'moodle');
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 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/'. $file;
42 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/'. $module .'/'. $file;
43 if (!file_exists($filepath)) {
44 $filepath = $CFG->dirroot
.'/mod/'.$module.'/lang/'. $lang .'/help/'. $module .'/'. $file;
48 if (file_exists($filepath)) {
50 include($filepath); // The actual helpfile
52 if ($module == 'moodle' and ($file == 'index.html' or $file == 'mods.html')) {
53 // include file for each module
55 if (!$modules = get_records('modules', 'visible', 1)) {
56 error('No modules found!!'); // Should never happen
59 foreach ($modules as $mod) {
60 $strmodulename = get_string('modulename', $mod->name
);
61 $modulebyname[$strmodulename] = $mod;
65 foreach ($modulebyname as $mod) {
66 foreach ($langs as $lang) {
70 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/'. $mod->name
.'/'. $file;
72 if (file_exists($filepath)) {
73 echo '<hr size="1" />';
74 include($filepath); // The actual helpfile
81 // Some horrible hardcoded stuff follows, should be delegated to modules to handle
83 if ($module == 'moodle' and ($file == 'resource/types.html')) { // RESOURCES
84 require_once($CFG->dirroot
.'/mod/resource/lib.php');
85 $typelist = resource_get_resource_types();
86 $typelist['label'] = get_string('resourcetypelabel', 'resource');
88 foreach ($typelist as $type => $name) {
89 foreach ($langs as $lang) {
93 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/resource/type/'. $type .'.html';
94 if (file_exists($filepath)) {
95 echo '<hr size="1" />';
96 include($filepath); // The actual helpfile
102 if ($module == 'moodle' and ($file == 'assignment/types.html')) { // ASSIGNMENTS
103 require_once($CFG->dirroot
.'/mod/assignment/lib.php');
104 $typelist = assignment_types();
106 foreach ($typelist as $type => $name) {
107 echo '<p><b>'.$name.'</b></p>';
108 echo get_string('help'.$type, 'assignment');
109 echo '<hr size="1" />';
117 echo clean_text($text);
122 print_simple_box_end();
125 $file = clean_text($file); // Keep it clean!
126 notify('Help file "'. $file .'" could not be found!');
129 close_window_button();
131 echo '<p align="center"><a href="help.php?file=index.html">'. get_string('helpindex') .'</a></p>';
132 print_footer('none');