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