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