Some blank index.html files to prevent browsing
[moodle.git] / help.php
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!");
17     }
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;
28             }
29             if ($module == "moodle") {
30                 $filepath = "$CFG->dirroot/lang/$lang/help/$file";
31             } else {
32                 $filepath = "$CFG->dirroot/lang/$lang/help/$module/$file";
33             }
34   
35             if (file_exists("$filepath")) {
36                 $helpfound = true;
37                 include("$filepath");   // The actual helpfile
39                 if ($module == "moodle" && ($file == "index.html" || $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
44                     }
46                     foreach ($modules as $mod) {
47                         $strmodulename = get_string("modulename", "$mod->name");
48                         $modulebyname[$strmodulename] = $mod;
49                     }
50                     ksort($modulebyname);
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";
59                             if (file_exists("$filepath")) {
60                                 include("$filepath");   // The actual helpfile
61                                 break;
62                             }
63                         }
64                     }
65                 }
66                 break;
67             }
68         }
69     } else {
70         echo "<p>";
71         echo $text;
72         echo "</p>";
73         $helpfound = true;
74     }
76     print_simple_box_end();
78     if (!$helpfound) {
79         notify("Help file '$file' could not be found!");
80     }
82     close_window_button();
84     echo "<center><p><a href=\"help.php?file=index.html\">".get_string("helpindex")."</a><p></center>";
85 ?>
86 </body>
87 </html>