Automatic installer.php lang files by installer_builder (20060816)
[moodle.git] / help.php
blobef420dfd2700bf9347fb7a1dcece21eea4892e26
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_PATH);
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);
24 print_header();
26 print_simple_box_start('center', '96%');
28 $helpfound = false;
29 if (empty($forcelang)) {
30 $langs = array(current_language(), get_string('parentlanguage'), 'en_utf8'); // Fallback
31 } else {
32 $langs = array($forcelang);
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) and is_file($filepath) and is_readable($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>';
150 $CFG->docroot = ''; // We don't want a doc link here
152 print_footer('none');