Don't display search buttons if all the courses are being displayed anyway
[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
aa635c47 19 $helpfound = false;
1517c0aa 20 $langs = array(current_language(), get_string("parentlanguage"), "en"); // Fallback
21
aa635c47 22 if (!empty($file)) {
aa635c47 23 foreach ($langs as $lang) {
24 if (empty($lang)) {
25 continue;
26 }
70442fe3 27 if ($module == "moodle") {
aa635c47 28 $filepath = "$CFG->dirroot/lang/$lang/help/$file";
70442fe3 29 } else {
aa635c47 30 $filepath = "$CFG->dirroot/lang/$lang/help/$module/$file";
70442fe3 31 }
aa635c47 32
70442fe3 33 if (file_exists("$filepath")) {
aa635c47 34 $helpfound = true;
35 include("$filepath"); // The actual helpfile
1517c0aa 36
37 if ($module == "moodle" && ($file == "index.html" || $file == "mods.html")) {
38 // include file for each module
39
1e6e23fe 40 if (!$modules = get_records("modules", "visible", 1)) {
1517c0aa 41 error("No modules found!!"); // Should never happen
42 }
43
44 foreach ($modules as $mod) {
45 $strmodulename = get_string("modulename", "$mod->name");
46 $modulebyname[$strmodulename] = $mod;
47 }
48 ksort($modulebyname);
49
50 foreach ($modulebyname as $mod) {
51 foreach ($langs as $lang) {
52 if (empty($lang)) {
53 continue;
54 }
55 $filepath = "$CFG->dirroot/lang/$lang/help/$mod->name/$file";
56
57 if (file_exists("$filepath")) {
58 include("$filepath"); // The actual helpfile
59 break;
60 }
61 }
62 }
63 }
aa635c47 64 break;
70442fe3 65 }
65cf9fc3 66 }
67 } else {
6c8e8b5e 68 echo "<p>";
65cf9fc3 69 echo $text;
6c8e8b5e 70 echo "</p>";
aa635c47 71 $helpfound = true;
72 }
73
74 if (!$helpfound) {
75 notify("Help file '$file' could not be found!");
65cf9fc3 76 }
e5dfd0f3 77
78 close_window_button();
95b50076 79
80 echo "<center><p><a href=\"help.php?file=index.html\">".get_string("helpindex")."</a><p></center>";
ed5ab9f7 81?>
6c8e8b5e 82</body>
83</html>
229b6580 84