Downgrading versions to fix recent mistake in upgrading them
[moodle.git] / help.php
blob49426df277c6f82eb0bbe7583ec89f640f5d284d
1 <?PHP /// $Id$
2 /// help.php - prints a very simple page and includes a
3 /// page content or a string from elsewhere
4 /// Usually this will appear in a popup
5 /// See helpbutton() in lib/moodlelib.php
7 require_once("config.php");
9 optional_variable($file, "");
10 optional_variable($text, "No text to display");
11 optional_variable($module, "moodle");
13 print_header();
15 if (detect_munged_arguments("$module/$file")) {
16 error("Filenames contain illegal characters!");
19 print_simple_box_start("center", "96%");
21 $helpfound = false;
22 $langs = array(current_language(), get_string("parentlanguage"), "en"); // Fallback
24 if (!empty($file)) {
25 foreach ($langs as $lang) {
26 if (empty($lang)) {
27 continue;
29 if ($module == "moodle") {
30 $filepath = "$CFG->dirroot/lang/$lang/help/$file";
31 } else {
32 $filepath = "$CFG->dirroot/lang/$lang/help/$module/$file";
35 if (file_exists("$filepath")) {
36 $helpfound = true;
37 include("$filepath"); // The actual helpfile
39 if ($module == "moodle" and ($file == "index.html" or $file == "mods.html")) {
40 // include file for each module
42 if (!$modules = get_records("modules", "visible", 1)) {
43 error("No modules found!!"); // Should never happen
46 foreach ($modules as $mod) {
47 $strmodulename = get_string("modulename", "$mod->name");
48 $modulebyname[$strmodulename] = $mod;
50 ksort($modulebyname);
52 foreach ($modulebyname as $mod) {
53 foreach ($langs as $lang) {
54 if (empty($lang)) {
55 continue;
57 $filepath = "$CFG->dirroot/lang/$lang/help/$mod->name/$file";
59 if (file_exists("$filepath")) {
60 echo '<hr size="1" />';
61 include("$filepath"); // The actual helpfile
62 break;
68 if ($module == "moodle" and ($file == "resource/types.html")) { // RESOURCES
69 require_once("$CFG->dirroot/mod/resource/lib.php");
70 $typelist = resource_get_resource_types();
71 $typelist['label'] = get_string('resourcetypelabel', 'resource');
73 foreach ($typelist as $type => $name) {
74 foreach ($langs as $lang) {
75 if (empty($lang)) {
76 continue;
78 $filepath = "$CFG->dirroot/lang/$lang/help/resource/type/$type.html";
79 if (file_exists("$filepath")) {
80 echo '<hr size="1" />';
81 include("$filepath"); // The actual helpfile
82 break;
87 break;
90 } else {
91 echo "<p>";
92 echo clean_text($text);
93 echo "</p>";
94 $helpfound = true;
97 print_simple_box_end();
99 if (!$helpfound) {
100 $file = clean_text($file); // Keep it clean!
101 notify("Help file '$file' could not be found!");
104 close_window_button();
106 echo "<center><p><a href=\"help.php?file=index.html\">".get_string("helpindex")."</a><p></center>";
108 </body>
109 </html>