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 | |
15 | if (!isset($config_php)) |
e222c290 |
16 | include("../config/config.php"); |
390372b4 |
17 | if (!isset($strings_php)) |
18 | include("../functions/strings.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 | |
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>") { |
60 | for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</description>"); $n++) { |
61 | $ary[1] .= $doc[$n]; |
62 | } |
63 | } |
64 | if (trim(strtolower($doc[$n])) == "<summary>") { |
65 | for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) { |
66 | $ary[2] .= $doc[$n]; |
67 | } |
68 | } |
69 | } |
70 | if ($ary) { |
71 | $ary[3] = $n; |
72 | return $ary; |
73 | } else { |
74 | $ary[0] = "ERROR: Help files are not in the right format!"; |
75 | $ary[1] = "ERROR: Help files are not in the right format!"; |
76 | $ary[2] = "ERROR: Help files are not in the right format!"; |
77 | return $ary; |
78 | } |
79 | } |
80 | } |
81 | $ary[0] = "ERROR: Help files are not in the right format!"; |
82 | $ary[1] = "ERROR: Help files are not in the right format!"; |
83 | return $ary; |
e222c290 |
84 | } |
390372b4 |
85 | |
86 | /**************[ END HELP FUNCTIONS ]******************/ |
87 | |
88 | ?> |
89 | |
90 | <br> |
91 | <table width=95% align=center cellpadding=2 cellspacing=2 border=0> |
8442ac08 |
92 | <tr><td bgcolor="<?php echo $color[0] ?>"> |
93 | <center><b><?php echo _("Help") ?></b></center> |
390372b4 |
94 | </td></tr></table> |
95 | |
d7d3c4d4 |
96 | <?php do_hook("help_top") ?> |
390372b4 |
97 | |
98 | <table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><td> |
99 | <?php |
100 | if ($HTTP_REFERER) { |
101 | $ref = strtolower($HTTP_REFERER); |
102 | if (strpos($ref, "src/compose")) |
103 | $context = "compose"; |
104 | else if (strpos($ref, "src/addr")) |
105 | $context = "address"; |
106 | else if (strpos($ref, "src/folders")) |
107 | $context = "folders"; |
108 | else if (strpos($ref, "src/options")) |
109 | $context = "options"; |
110 | else if (strpos($ref, "src/right_main")) |
111 | $context = "index"; |
112 | else if (strpos($ref, "src/read_body")) |
113 | $context = "read"; |
d7d3c4d4 |
114 | else if (strpos($ref, "src/search")) |
115 | $context = "search"; |
e222c290 |
116 | } |
390372b4 |
117 | |
0493a8d9 |
118 | if (!$squirrelmail_language) |
119 | $squirrelmail_language = "en"; |
120 | |
99fa2b21 |
121 | if (file_exists("../help/$squirrelmail_language")) { |
390372b4 |
122 | $help_exists = true; |
61afa89e |
123 | $user_language = $squirrelmail_language; |
390372b4 |
124 | } else if (file_exists("../help/en")) { |
125 | $help_exists = true; |
126 | echo "<center><font color=\"$color[2]\">"; |
99fa2b21 |
127 | printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]); |
390372b4 |
128 | echo "</font></center><br>"; |
129 | $user_language = "en"; |
f7942326 |
130 | } else { |
390372b4 |
131 | $help_exists = false; |
132 | echo "<br><center><font color=\"$color[2]\">"; |
133 | echo _("Some or all of the help documents are not present!"); |
134 | echo "</font></center>"; |
61afa89e |
135 | echo "</td></tr></table>"; |
136 | exit; |
f7942326 |
137 | } |
390372b4 |
138 | |
139 | if ($help_exists) { |
140 | if ($context == "compose") |
141 | $chapter = 4; |
142 | else if ($context == "address") |
143 | $chapter = 5; |
144 | else if ($context == "folders") |
145 | $chapter = 6; |
146 | else if ($context == "options") |
147 | $chapter = 7; |
148 | else if ($context == "index") |
149 | $chapter = 2; |
150 | else if ($context == "read") |
151 | $chapter = 3; |
d7d3c4d4 |
152 | else if ($context == "search") |
153 | $chapter = 8; |
f7942326 |
154 | |
390372b4 |
155 | if (!$chapter) { |
156 | echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n"; |
157 | echo "<b><center>" . _("Table of Contents") . "</center></b><br>"; |
06ad27a2 |
158 | do_hook("help_chapter"); |
390372b4 |
159 | echo "<ol>\n"; |
160 | for ($i=0; $i < count($helpdir); $i++) { |
161 | $doc = file("../help/$user_language/$helpdir[$i]"); |
162 | $help_info = get_info($doc, 0); |
163 | echo "<li><a href=\"../src/help.php?chapter=". ($i+1) ."\">$help_info[0]</a>\n"; |
164 | echo "<ul>$help_info[2]</ul>"; |
165 | } |
166 | echo "</ol>\n"; |
167 | echo "</td></tr></table>\n"; |
168 | } else { |
169 | $doc = file("../help/$user_language/".$helpdir[$chapter-1]); |
170 | $help_info = get_info($doc, 0); |
171 | |
172 | echo "<small><center>"; |
173 | |
32f4685b |
174 | if ($chapter <= 1) echo "<font color=\"$color[9]\">"._("Previous")."</font> | "; |
175 | else echo "<a href=\"../src/help.php?chapter=".($chapter-1)."\">"._("Previous")."</a> | "; |
176 | echo "<a href=\"../src/help.php\">"._("Table of Contents")."</a>"; |
177 | if ($chapter >= count($helpdir)) echo " | <font color=\"$color[9]\">"._("Next")."</font>"; |
178 | else echo " | <a href=\"../src/help.php?chapter=".($chapter+1)."\">"._("Next")."</a>\n"; |
390372b4 |
179 | echo "</center></small><br>\n"; |
e222c290 |
180 | |
390372b4 |
181 | echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n"; |
182 | if ($help_info[1]) |
04632dbc |
183 | echo "$help_info[1]\n"; |
390372b4 |
184 | else |
04632dbc |
185 | echo "<p>$help_info[2]</p>\n"; |
390372b4 |
186 | |
187 | for ($n = $help_info[3]; $n < count($doc); $n++) { |
188 | $section++; |
189 | $help_info = get_info($doc, $n); |
190 | echo "<b>$chapter.$section - $help_info[0]</b>"; |
191 | echo "<ul>"; |
192 | echo "$help_info[1]"; |
193 | echo "</ul>"; |
194 | $n = $help_info[3]; |
195 | } |
196 | |
04632dbc |
197 | echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>\n"; |
390372b4 |
198 | } |
199 | } |
06ad27a2 |
200 | do_hook("help_bottom"); |
e222c290 |
201 | ?> |
8442ac08 |
202 | <tr><td bgcolor="<?php echo $color[0] ?>"> </td></tr></table> |
390372b4 |
203 | <td></tr></table> |
204 | </body></html> |