Quiz directory path incorect in download link fixed (bug #4424)
[moodle-linuxchix.git] / help.php
blob38de024358449aa227305ef941402dabf41ab4ef
1 <?php
3 /**
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
12 * @version $Id$
13 * @package moodlecore
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);
23 print_header();
25 if (detect_munged_arguments($module .'/'. $file)) {
26 error('Filenames contain illegal characters!');
29 print_simple_box_start('center', '96%');
31 $helpfound = false;
32 $langs = array(current_language(), get_string('parentlanguage'), 'en'); // Fallback
34 if (!empty($file)) {
35 foreach ($langs as $lang) {
36 if (empty($lang)) {
37 continue;
39 if ($module == 'moodle') {
40 if ($lang == 'en_utf8') {
41 $filepath = $CFG->dirroot .'/lang/'. $lang .'/help/'. $file;
42 } else {
43 $filepath = $CFG->dataroot .'/lang/'. $lang .'/help/'. $file;
45 } else {
46 if ($lang == 'en_utf8') {
47 $filepath = $CFG->dirroot .'/lang/'. $lang .'/help/'. $module .'/'. $file;
48 } else {
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)) {
60 $helpfound = true;
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;
74 ksort($modulebyname);
76 foreach ($modulebyname as $mod) {
77 foreach ($langs as $lang) {
78 if (empty($lang)) {
79 continue;
81 if ($lang == 'en_utf8') {
82 $filepath = $CFG->dirroot .'/lang/'. $lang .'/help/'. $mod->name .'/'. $file;
83 } else {
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
90 break;
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) {
105 if (empty($lang)) {
106 continue;
108 if ($lang == 'en_utf8') {
109 $filepath = $CFG->dirroot .'/lang/'. $lang .'/help/resource/type/'. $type .'.html';
110 } else {
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
116 break;
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" />';
131 break;
134 } else {
135 echo '<p>'.s($text).'</p>'; // This param was already cleaned
136 $helpfound = true;
139 print_simple_box_end();
141 if (!$helpfound) {
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');