Not quite ready, but anyone trying the Beta at this stage will probably
[moodle.git] / help.php
blob67643602afcdf2113111924387ca3fb79d85a299
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 $helpfound = false;
20 $langs = array(current_language(), get_string("parentlanguage"), "en"); // Fallback
22 if (!empty($file)) {
23 foreach ($langs as $lang) {
24 if (empty($lang)) {
25 continue;
27 if ($module == "moodle") {
28 $filepath = "$CFG->dirroot/lang/$lang/help/$file";
29 } else {
30 $filepath = "$CFG->dirroot/lang/$lang/help/$module/$file";
33 if (file_exists("$filepath")) {
34 $helpfound = true;
35 include("$filepath"); // The actual helpfile
37 if ($module == "moodle" && ($file == "index.html" || $file == "mods.html")) {
38 // include file for each module
40 if (!$modules = get_records("modules")) {
41 error("No modules found!!"); // Should never happen
44 foreach ($modules as $mod) {
45 $strmodulename = get_string("modulename", "$mod->name");
46 $modulebyname[$strmodulename] = $mod;
48 ksort($modulebyname);
50 foreach ($modulebyname as $mod) {
51 foreach ($langs as $lang) {
52 if (empty($lang)) {
53 continue;
55 $filepath = "$CFG->dirroot/lang/$lang/help/$mod->name/$file";
57 if (file_exists("$filepath")) {
58 include("$filepath"); // The actual helpfile
59 break;
64 break;
67 } else {
68 echo "<p>";
69 echo $text;
70 echo "</p>";
71 $helpfound = true;
74 if (!$helpfound) {
75 notify("Help file '$file' could not be found!");
78 close_window_button();
80 echo "<center><p><a href=\"help.php?file=index.html\">".get_string("helpindex")."</a><p></center>";
82 </body>
83 </html>