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 | |
6da4b261 |
39 | if ($module == "moodle" and ($file == "index.html" or $file == "mods.html")) { |
1517c0aa |
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")) { |
6da4b261 |
60 | echo '<hr size="1" />'; |
61 | include("$filepath"); // The actual helpfile |
62 | break; |
63 | } |
64 | } |
65 | } |
66 | } |
67 | |
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'); |
72 | |
73 | foreach ($typelist as $type => $name) { |
74 | foreach ($langs as $lang) { |
75 | if (empty($lang)) { |
76 | continue; |
77 | } |
78 | $filepath = "$CFG->dirroot/lang/$lang/help/resource/type/$type.html"; |
79 | if (file_exists("$filepath")) { |
80 | echo '<hr size="1" />'; |
1517c0aa |
81 | include("$filepath"); // The actual helpfile |
82 | break; |
83 | } |
84 | } |
85 | } |
86 | } |
aa635c47 |
87 | break; |
70442fe3 |
88 | } |
65cf9fc3 |
89 | } |
90 | } else { |
6c8e8b5e |
91 | echo "<p>"; |
4bd22e0f |
92 | echo clean_text($text); |
6c8e8b5e |
93 | echo "</p>"; |
aa635c47 |
94 | $helpfound = true; |
95 | } |
96 | |
d6f73f53 |
97 | print_simple_box_end(); |
98 | |
aa635c47 |
99 | if (!$helpfound) { |
32a4f1f1 |
100 | $file = clean_text($file); // Keep it clean! |
aa635c47 |
101 | notify("Help file '$file' could not be found!"); |
65cf9fc3 |
102 | } |
e5dfd0f3 |
103 | |
104 | close_window_button(); |
95b50076 |
105 | |
106 | echo "<center><p><a href=\"help.php?file=index.html\">".get_string("helpindex")."</a><p></center>"; |
ed5ab9f7 |
107 | ?> |
6c8e8b5e |
108 | </body> |
109 | </html> |
229b6580 |
110 | |