Some blank index.html files to prevent browsing
[moodle.git] / help.php
CommitLineData
aa635c47 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
229b6580 6
aa635c47 7 require_once("config.php");
229b6580 8
aa635c47 9 optional_variable($file, "");
10 optional_variable($text, "No text to display");
11 optional_variable($module, "moodle");
65cf9fc3 12
aa635c47 13 print_header();
5c0ee23c 14
aa635c47 15 if (detect_munged_arguments("$module/$file")) {
16 error("Filenames contain illegal characters!");
17 }
70442fe3 18
d6f73f53 19 print_simple_box_start("center", "96%");
20
aa635c47 21 $helpfound = false;
1517c0aa 22 $langs = array(current_language(), get_string("parentlanguage"), "en"); // Fallback
23
aa635c47 24 if (!empty($file)) {
aa635c47 25 foreach ($langs as $lang) {
26 if (empty($lang)) {
27 continue;
28 }
70442fe3 29 if ($module == "moodle") {
aa635c47 30 $filepath = "$CFG->dirroot/lang/$lang/help/$file";
70442fe3 31 } else {
aa635c47 32 $filepath = "$CFG->dirroot/lang/$lang/help/$module/$file";
70442fe3 33 }
aa635c47 34
70442fe3 35 if (file_exists("$filepath")) {
aa635c47 36 $helpfound = true;
37 include("$filepath"); // The actual helpfile
1517c0aa 38
39 if ($module == "moodle" && ($file == "index.html" || $file == "mods.html")) {
40 // include file for each module
41
1e6e23fe 42 if (!$modules = get_records("modules", "visible", 1)) {
1517c0aa 43 error("No modules found!!"); // Should never happen
44 }
45
46 foreach ($modules as $mod) {
47 $strmodulename = get_string("modulename", "$mod->name");
48 $modulebyname[$strmodulename] = $mod;
49 }
50 ksort($modulebyname);
51
52 foreach ($modulebyname as $mod) {
53 foreach ($langs as $lang) {
54 if (empty($lang)) {
55 continue;
56 }
57 $filepath = "$CFG->dirroot/lang/$lang/help/$mod->name/$file";
58
59 if (file_exists("$filepath")) {
60 include("$filepath"); // The actual helpfile
61 break;
62 }
63 }
64 }
65 }
aa635c47 66 break;
70442fe3 67 }
65cf9fc3 68 }
69 } else {
6c8e8b5e 70 echo "<p>";
65cf9fc3 71 echo $text;
6c8e8b5e 72 echo "</p>";
aa635c47 73 $helpfound = true;
74 }
75
d6f73f53 76 print_simple_box_end();
77
aa635c47 78 if (!$helpfound) {
79 notify("Help file '$file' could not be found!");
65cf9fc3 80 }
e5dfd0f3 81
82 close_window_button();
95b50076 83
84 echo "<center><p><a href=\"help.php?file=index.html\">".get_string("helpindex")."</a><p></center>";
ed5ab9f7 85?>
6c8e8b5e 86</body>
87</html>
229b6580 88