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
);
22 $forcelang = optional_param('forcelang', '', PARAM_ALPHAEXT
);
26 if (detect_munged_arguments($module .'/'. $file)) {
27 error('Filenames contain illegal characters!');
30 print_simple_box_start('center', '96%');
33 if (empty($forcelang)) {
34 $langs = array(current_language(), get_string('parentlanguage'), 'en_utf8'); // Fallback
36 $langs = array($forcelang);
39 foreach ($langs as $lang) {
43 if ($module == 'moodle') {
44 if ($lang == 'en_utf8') {
45 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/'. $file;
47 $filepath = $CFG->dataroot
.'/lang/'. $lang .'/help/'. $file;
50 if ($lang == 'en_utf8') {
51 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/'. $module .'/'. $file;
53 $filepath = $CFG->dataroot
.'/lang/'. $lang .'/help/'. $module .'/'. $file;
54 if (!file_exists($filepath)) {
55 $filepath = $CFG->dirroot
.'/lang/en_utf8/help/'. $module .'/'. $file;
58 if (!file_exists($filepath)) {
59 $filepath = $CFG->dirroot
.'/mod/'.$module.'/lang/'. $lang .'/help/'. $module .'/'. $file;
63 if (file_exists($filepath)) {
65 include($filepath); // The actual helpfile
67 if ($module == 'moodle' and ($file == 'index.html' or $file == 'mods.html')) {
68 // include file for each module
70 if (!$modules = get_records('modules', 'visible', 1)) {
71 error('No modules found!!'); // Should never happen
74 foreach ($modules as $mod) {
75 $strmodulename = get_string('modulename', $mod->name
);
76 $modulebyname[$strmodulename] = $mod;
80 foreach ($modulebyname as $mod) {
81 foreach ($langs as $lang) {
85 if ($lang == 'en_utf8') {
86 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/'. $mod->name
.'/'. $file;
88 $filepath = $CFG->dataroot
.'/lang/'. $lang .'/help/'. $mod->name
.'/'. $file;
91 if (file_exists($filepath)) {
92 echo '<hr size="1" />';
93 include($filepath); // The actual helpfile
100 // Some horrible hardcoded stuff follows, should be delegated to modules to handle
102 if ($module == 'moodle' and ($file == 'resource/types.html')) { // RESOURCES
103 require_once($CFG->dirroot
.'/mod/resource/lib.php');
104 $typelist = resource_get_resource_types();
105 $typelist['label'] = get_string('resourcetypelabel', 'resource');
107 foreach ($typelist as $type => $name) {
108 foreach ($langs as $lang) {
112 if ($lang == 'en_utf8') {
113 $filepath = $CFG->dirroot
.'/lang/'. $lang .'/help/resource/type/'. $type .'.html';
115 $filepath = $CFG->dataroot
.'/lang/'. $lang .'/help/resource/type/'. $type .'.html';
117 if (file_exists($filepath)) {
118 echo '<hr size="1" />';
119 include($filepath); // The actual helpfile
125 if ($module == 'moodle' and ($file == 'assignment/types.html')) { // ASSIGNMENTS
126 require_once($CFG->dirroot
.'/mod/assignment/lib.php');
127 $typelist = assignment_types();
129 foreach ($typelist as $type => $name) {
130 echo '<p><b>'.$name.'</b></p>';
131 echo get_string('help'.$type, 'assignment');
132 echo '<hr size="1" />';
139 echo '<p>'.s($text).'</p>'; // This param was already cleaned
143 print_simple_box_end();
146 //$file = clean_text($file); // Keep it clean!
147 notify('Help file "'. $file .'" could not be found!');
150 close_window_button();
152 echo '<p align="center"><a href="help.php?file=index.html">'. get_string('helpindex') .'</a></p>';
154 $CFG->docroot
= ''; // We don't want a doc link here
156 print_footer('none');