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 | |
390372b4 |
13 | session_start(); |
14 | |
390372b4 |
15 | if (!isset($strings_php)) |
16 | include("../functions/strings.php"); |
1863670d |
17 | if (!isset($config_php)) |
18 | include("../config/config.php"); |
390372b4 |
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 | |
e222c290 |
32 | include("../src/load_prefs.php"); |
390372b4 |
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"; |
d7d3c4d4 |
43 | $helpdir[7] = "search.hlp"; |
44 | $helpdir[8] = "FAQ.hlp"; |
390372b4 |
45 | |
46 | /****************[ HELP FUNCTIONS ]********************/ |
99fa2b21 |
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 | |
390372b4 |
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>") { |
1863670d |
60 | $ary[1] = ""; |
390372b4 |
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>") { |
1863670d |
66 | $ary[2] = ""; |
390372b4 |
67 | for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) { |
68 | $ary[2] .= $doc[$n]; |
69 | } |
70 | } |
71 | } |
1863670d |
72 | if (isset($ary)) { |
390372b4 |
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; |
e222c290 |
86 | } |
390372b4 |
87 | |
88 | /**************[ END HELP FUNCTIONS ]******************/ |
89 | |
90 | ?> |
91 | |
92 | <br> |
93 | <table width=95% align=center cellpadding=2 cellspacing=2 border=0> |
8442ac08 |
94 | <tr><td bgcolor="<?php echo $color[0] ?>"> |
95 | <center><b><?php echo _("Help") ?></b></center> |
390372b4 |
96 | </td></tr></table> |
97 | |
d7d3c4d4 |
98 | <?php do_hook("help_top") ?> |
390372b4 |
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"; |
d7d3c4d4 |
116 | else if (strpos($ref, "src/search")) |
117 | $context = "search"; |
e222c290 |
118 | } |
390372b4 |
119 | |
0493a8d9 |
120 | if (!$squirrelmail_language) |
121 | $squirrelmail_language = "en"; |
122 | |
99fa2b21 |
123 | if (file_exists("../help/$squirrelmail_language")) { |
390372b4 |
124 | $help_exists = true; |
61afa89e |
125 | $user_language = $squirrelmail_language; |
390372b4 |
126 | } else if (file_exists("../help/en")) { |
127 | $help_exists = true; |
128 | echo "<center><font color=\"$color[2]\">"; |
99fa2b21 |
129 | printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]); |
390372b4 |
130 | echo "</font></center><br>"; |
131 | $user_language = "en"; |
f7942326 |
132 | } else { |
390372b4 |
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>"; |
61afa89e |
137 | echo "</td></tr></table>"; |
138 | exit; |
f7942326 |
139 | } |
390372b4 |
140 | |
141 | if ($help_exists) { |
1863670d |
142 | if (! isset($context)) |
143 | $context = ''; |
390372b4 |
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; |
d7d3c4d4 |
156 | else if ($context == "search") |
157 | $chapter = 8; |
f7942326 |
158 | |
1863670d |
159 | if (!isset($chapter)) { |
390372b4 |
160 | echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n"; |
161 | echo "<b><center>" . _("Table of Contents") . "</center></b><br>"; |
06ad27a2 |
162 | do_hook("help_chapter"); |
390372b4 |
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 | |
32f4685b |
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"; |
390372b4 |
183 | echo "</center></small><br>\n"; |
e222c290 |
184 | |
390372b4 |
185 | echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n"; |
1863670d |
186 | if (isset($help_info[1])) |
04632dbc |
187 | echo "$help_info[1]\n"; |
390372b4 |
188 | else |
04632dbc |
189 | echo "<p>$help_info[2]</p>\n"; |
390372b4 |
190 | |
1863670d |
191 | $section = 0; |
390372b4 |
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 | |
04632dbc |
202 | echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>\n"; |
390372b4 |
203 | } |
204 | } |
06ad27a2 |
205 | do_hook("help_bottom"); |
e222c290 |
206 | ?> |
8442ac08 |
207 | <tr><td bgcolor="<?php echo $color[0] ?>"> </td></tr></table> |
390372b4 |
208 | <td></tr></table> |
209 | </body></html> |