Only configure LDAP-addressbook(s) if PHP has LDAP support.
[squirrelmail.git] / src / help.php
CommitLineData
e222c290 1<?php
ef870322 2 /**
390372b4 3 ** help.php
ef870322 4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
390372b4 8 ** Displays help for the user
ef870322 9 **
10 **/
e222c290 11
390372b4 12 session_start();
13
14 if (!isset($config_php))
e222c290 15 include("../config/config.php");
390372b4 16 if (!isset($strings_php))
17 include("../functions/strings.php");
18 if (!isset($page_header_php))
19 include("../functions/page_header.php");
20 if (!isset($display_messages_php))
21 include("../functions/display_messages.php");
22 if (!isset($imap_php))
23 include("../functions/imap.php");
24 if (!isset($array_php))
25 include("../functions/array.php");
26 if (!isset($i18n_php))
27 include("../functions/i18n.php");
28 if (!isset($auth_php))
29 include ("../functions/auth.php");
30
e222c290 31 include("../src/load_prefs.php");
390372b4 32 displayPageHeader($color, "None");
33 is_logged_in();
34
35 $helpdir[0] = "basic.hlp";
36 $helpdir[1] = "main_folder.hlp";
37 $helpdir[2] = "read_mail.hlp";
38 $helpdir[3] = "compose.hlp";
39 $helpdir[4] = "addresses.hlp";
40 $helpdir[5] = "folders.hlp";
41 $helpdir[6] = "options.hlp";
d7d3c4d4 42 $helpdir[7] = "search.hlp";
43 $helpdir[8] = "FAQ.hlp";
390372b4 44
45 /****************[ HELP FUNCTIONS ]********************/
99fa2b21 46 // parses through and gets the information from the different documents.
47 // this returns one section at a time. You must keep track of the position
48 // so that it knows where to start to look for the next section.
49
390372b4 50 function get_info($doc, $pos) {
51 for ($n=$pos; $n < count($doc); $n++) {
52 if (trim(strtolower($doc[$n])) == "<chapter>" || trim(strtolower($doc[$n])) == "<section>") {
53 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</section>") && (trim(strtolower($doc[$n])) != "</chapter>"); $n++) {
54 if (trim(strtolower($doc[$n])) == "<title>") {
55 $n++;
56 $ary[0] = trim($doc[$n]);
57 }
58 if (trim(strtolower($doc[$n])) == "<description>") {
59 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</description>"); $n++) {
60 $ary[1] .= $doc[$n];
61 }
62 }
63 if (trim(strtolower($doc[$n])) == "<summary>") {
64 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) {
65 $ary[2] .= $doc[$n];
66 }
67 }
68 }
69 if ($ary) {
70 $ary[3] = $n;
71 return $ary;
72 } else {
73 $ary[0] = "ERROR: Help files are not in the right format!";
74 $ary[1] = "ERROR: Help files are not in the right format!";
75 $ary[2] = "ERROR: Help files are not in the right format!";
76 return $ary;
77 }
78 }
79 }
80 $ary[0] = "ERROR: Help files are not in the right format!";
81 $ary[1] = "ERROR: Help files are not in the right format!";
82 return $ary;
e222c290 83 }
390372b4 84
85 /**************[ END HELP FUNCTIONS ]******************/
86
87?>
88
89<br>
90<table width=95% align=center cellpadding=2 cellspacing=2 border=0>
8442ac08 91<tr><td bgcolor="<?php echo $color[0] ?>">
92 <center><b><?php echo _("Help") ?></b></center>
390372b4 93</td></tr></table>
94
d7d3c4d4 95<?php do_hook("help_top") ?>
390372b4 96
97<table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><td>
98<?php
99 if ($HTTP_REFERER) {
100 $ref = strtolower($HTTP_REFERER);
101 if (strpos($ref, "src/compose"))
102 $context = "compose";
103 else if (strpos($ref, "src/addr"))
104 $context = "address";
105 else if (strpos($ref, "src/folders"))
106 $context = "folders";
107 else if (strpos($ref, "src/options"))
108 $context = "options";
109 else if (strpos($ref, "src/right_main"))
110 $context = "index";
111 else if (strpos($ref, "src/read_body"))
112 $context = "read";
d7d3c4d4 113 else if (strpos($ref, "src/search"))
114 $context = "search";
e222c290 115 }
390372b4 116
99fa2b21 117 if (file_exists("../help/$squirrelmail_language")) {
390372b4 118 $help_exists = true;
61afa89e 119 $user_language = $squirrelmail_language;
390372b4 120 } else if (file_exists("../help/en")) {
121 $help_exists = true;
122 echo "<center><font color=\"$color[2]\">";
99fa2b21 123 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
390372b4 124 echo "</font></center><br>";
125 $user_language = "en";
f7942326 126 } else {
390372b4 127 $help_exists = false;
128 echo "<br><center><font color=\"$color[2]\">";
129 echo _("Some or all of the help documents are not present!");
130 echo "</font></center>";
61afa89e 131 echo "</td></tr></table>";
132 exit;
f7942326 133 }
390372b4 134
135 if ($help_exists) {
136 if ($context == "compose")
137 $chapter = 4;
138 else if ($context == "address")
139 $chapter = 5;
140 else if ($context == "folders")
141 $chapter = 6;
142 else if ($context == "options")
143 $chapter = 7;
144 else if ($context == "index")
145 $chapter = 2;
146 else if ($context == "read")
147 $chapter = 3;
d7d3c4d4 148 else if ($context == "search")
149 $chapter = 8;
f7942326 150
390372b4 151 if (!$chapter) {
152 echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n";
153 echo "<b><center>" . _("Table of Contents") . "</center></b><br>";
06ad27a2 154 do_hook("help_chapter");
390372b4 155 echo "<ol>\n";
156 for ($i=0; $i < count($helpdir); $i++) {
157 $doc = file("../help/$user_language/$helpdir[$i]");
158 $help_info = get_info($doc, 0);
159 echo "<li><a href=\"../src/help.php?chapter=". ($i+1) ."\">$help_info[0]</a>\n";
160 echo "<ul>$help_info[2]</ul>";
161 }
162 echo "</ol>\n";
163 echo "</td></tr></table>\n";
164 } else {
165 $doc = file("../help/$user_language/".$helpdir[$chapter-1]);
166 $help_info = get_info($doc, 0);
167
168 echo "<small><center>";
169
170 if ($chapter <= 1) echo "<font color=\"$color[9]\">Previous</font> | ";
171 else echo "<a href=\"../src/help.php?chapter=".($chapter-1)."\">Previous</a> | ";
172 echo "<a href=\"../src/help.php\">Table of Contents</a>";
173 if ($chapter >= count($helpdir)) echo " | <font color=\"$color[9]\">Next</font>";
174 else echo " | <a href=\"../src/help.php?chapter=".($chapter+1)."\">Next</a>";
175 echo "</center></small><br>\n";
e222c290 176
390372b4 177 echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n";
178 if ($help_info[1])
179 echo "$help_info[1]";
180 else
181 echo "<p>$help_info[2]</p>";
182
183 for ($n = $help_info[3]; $n < count($doc); $n++) {
184 $section++;
185 $help_info = get_info($doc, $n);
186 echo "<b>$chapter.$section - $help_info[0]</b>";
187 echo "<ul>";
188 echo "$help_info[1]";
189 echo "</ul>";
190 $n = $help_info[3];
191 }
192
193 echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>";
194 }
195 }
06ad27a2 196 do_hook("help_bottom");
e222c290 197?>
8442ac08 198<tr><td bgcolor="<?php echo $color[0] ?>">&nbsp;</td></tr></table>
390372b4 199<td></tr></table>
200</body></html>