e222c290 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * help.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Displays help for the user |
10 | * |
11 | * $Id$ |
12 | */ |
13 | |
14 | /*****************************************************************/ |
15 | /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/ |
16 | /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/ |
17 | /*** + Base level indent should begin at left margin, as ***/ |
18 | /*** the require_once below looks. ***/ |
19 | /*** + All identation should consist of four space blocks ***/ |
20 | /*** + Tab characters are evil. ***/ |
21 | /*** + all comments should use "slash-star ... star-slash" ***/ |
22 | /*** style -- no pound characters, no slash-slash style ***/ |
23 | /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/ |
24 | /*** ALWAYS USE { AND } CHARACTERS!!! ***/ |
25 | /*** + Please use ' instead of ", when possible. Note " ***/ |
26 | /*** should always be used in _( ) function calls. ***/ |
27 | /*** Thank you for your help making the SM code more readable. ***/ |
28 | /*****************************************************************/ |
29 | |
30 | require_once('../src/validate.php'); |
31 | require_once('../functions/display_messages.php'); |
32 | require_once('../functions/imap.php'); |
33 | require_once('../functions/array.php'); |
390372b4 |
34 | |
390372b4 |
35 | |
2d367c68 |
36 | displayPageHeader($color, 'None' ); |
37 | |
38 | $helpdir[0] = 'basic.hlp'; |
39 | $helpdir[1] = 'main_folder.hlp'; |
40 | $helpdir[2] = 'read_mail.hlp'; |
41 | $helpdir[3] = 'compose.hlp'; |
42 | $helpdir[4] = 'addresses.hlp'; |
43 | $helpdir[5] = 'folders.hlp'; |
44 | $helpdir[6] = 'options.hlp'; |
45 | $helpdir[7] = 'search.hlp'; |
46 | $helpdir[8] = 'FAQ.hlp'; |
390372b4 |
47 | |
48 | /****************[ HELP FUNCTIONS ]********************/ |
2d367c68 |
49 | // parses through and gets the information from the different documents. |
99fa2b21 |
50 | // this returns one section at a time. You must keep track of the position |
51 | // so that it knows where to start to look for the next section. |
52 | |
390372b4 |
53 | function get_info($doc, $pos) { |
54 | for ($n=$pos; $n < count($doc); $n++) { |
55 | if (trim(strtolower($doc[$n])) == "<chapter>" || trim(strtolower($doc[$n])) == "<section>") { |
56 | for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</section>") && (trim(strtolower($doc[$n])) != "</chapter>"); $n++) { |
57 | if (trim(strtolower($doc[$n])) == "<title>") { |
58 | $n++; |
59 | $ary[0] = trim($doc[$n]); |
60 | } |
61 | if (trim(strtolower($doc[$n])) == "<description>") { |
2d367c68 |
62 | $ary[1] = ""; |
390372b4 |
63 | for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</description>"); $n++) { |
64 | $ary[1] .= $doc[$n]; |
65 | } |
66 | } |
67 | if (trim(strtolower($doc[$n])) == "<summary>") { |
2d367c68 |
68 | $ary[2] = ""; |
390372b4 |
69 | for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) { |
70 | $ary[2] .= $doc[$n]; |
71 | } |
72 | } |
2d367c68 |
73 | } |
1863670d |
74 | if (isset($ary)) { |
390372b4 |
75 | $ary[3] = $n; |
76 | return $ary; |
77 | } else { |
78 | $ary[0] = "ERROR: Help files are not in the right format!"; |
79 | $ary[1] = "ERROR: Help files are not in the right format!"; |
80 | $ary[2] = "ERROR: Help files are not in the right format!"; |
81 | return $ary; |
2d367c68 |
82 | } |
390372b4 |
83 | } |
84 | } |
85 | $ary[0] = "ERROR: Help files are not in the right format!"; |
86 | $ary[1] = "ERROR: Help files are not in the right format!"; |
87 | return $ary; |
e222c290 |
88 | } |
2d367c68 |
89 | |
390372b4 |
90 | /**************[ END HELP FUNCTIONS ]******************/ |
91 | |
92 | ?> |
93 | |
94 | <br> |
95 | <table width=95% align=center cellpadding=2 cellspacing=2 border=0> |
8442ac08 |
96 | <tr><td bgcolor="<?php echo $color[0] ?>"> |
97 | <center><b><?php echo _("Help") ?></b></center> |
390372b4 |
98 | </td></tr></table> |
99 | |
d7d3c4d4 |
100 | <?php do_hook("help_top") ?> |
390372b4 |
101 | |
102 | <table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><td> |
103 | <?php |
104 | if ($HTTP_REFERER) { |
105 | $ref = strtolower($HTTP_REFERER); |
106 | if (strpos($ref, "src/compose")) |
2d367c68 |
107 | $context = "compose"; |
390372b4 |
108 | else if (strpos($ref, "src/addr")) |
2d367c68 |
109 | $context = "address"; |
390372b4 |
110 | else if (strpos($ref, "src/folders")) |
2d367c68 |
111 | $context = "folders"; |
390372b4 |
112 | else if (strpos($ref, "src/options")) |
2d367c68 |
113 | $context = "options"; |
390372b4 |
114 | else if (strpos($ref, "src/right_main")) |
2d367c68 |
115 | $context = "index"; |
390372b4 |
116 | else if (strpos($ref, "src/read_body")) |
2d367c68 |
117 | $context = "read"; |
d7d3c4d4 |
118 | else if (strpos($ref, "src/search")) |
2d367c68 |
119 | $context = "search"; |
e222c290 |
120 | } |
2d367c68 |
121 | |
0493a8d9 |
122 | if (!$squirrelmail_language) |
123 | $squirrelmail_language = "en"; |
124 | |
99fa2b21 |
125 | if (file_exists("../help/$squirrelmail_language")) { |
390372b4 |
126 | $help_exists = true; |
61afa89e |
127 | $user_language = $squirrelmail_language; |
390372b4 |
128 | } else if (file_exists("../help/en")) { |
129 | $help_exists = true; |
130 | echo "<center><font color=\"$color[2]\">"; |
99fa2b21 |
131 | printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]); |
390372b4 |
132 | echo "</font></center><br>"; |
133 | $user_language = "en"; |
f7942326 |
134 | } else { |
390372b4 |
135 | $help_exists = false; |
136 | echo "<br><center><font color=\"$color[2]\">"; |
137 | echo _("Some or all of the help documents are not present!"); |
138 | echo "</font></center>"; |
61afa89e |
139 | echo "</td></tr></table>"; |
140 | exit; |
f7942326 |
141 | } |
2d367c68 |
142 | |
390372b4 |
143 | if ($help_exists) { |
1863670d |
144 | if (! isset($context)) |
145 | $context = ''; |
390372b4 |
146 | if ($context == "compose") |
147 | $chapter = 4; |
148 | else if ($context == "address") |
149 | $chapter = 5; |
150 | else if ($context == "folders") |
151 | $chapter = 6; |
152 | else if ($context == "options") |
153 | $chapter = 7; |
154 | else if ($context == "index") |
155 | $chapter = 2; |
156 | else if ($context == "read") |
157 | $chapter = 3; |
d7d3c4d4 |
158 | else if ($context == "search") |
159 | $chapter = 8; |
f7942326 |
160 | |
1863670d |
161 | if (!isset($chapter)) { |
390372b4 |
162 | echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n"; |
163 | echo "<b><center>" . _("Table of Contents") . "</center></b><br>"; |
06ad27a2 |
164 | do_hook("help_chapter"); |
390372b4 |
165 | echo "<ol>\n"; |
166 | for ($i=0; $i < count($helpdir); $i++) { |
167 | $doc = file("../help/$user_language/$helpdir[$i]"); |
168 | $help_info = get_info($doc, 0); |
169 | echo "<li><a href=\"../src/help.php?chapter=". ($i+1) ."\">$help_info[0]</a>\n"; |
170 | echo "<ul>$help_info[2]</ul>"; |
171 | } |
172 | echo "</ol>\n"; |
173 | echo "</td></tr></table>\n"; |
174 | } else { |
175 | $doc = file("../help/$user_language/".$helpdir[$chapter-1]); |
176 | $help_info = get_info($doc, 0); |
177 | |
178 | echo "<small><center>"; |
179 | |
32f4685b |
180 | if ($chapter <= 1) echo "<font color=\"$color[9]\">"._("Previous")."</font> | "; |
181 | else echo "<a href=\"../src/help.php?chapter=".($chapter-1)."\">"._("Previous")."</a> | "; |
182 | echo "<a href=\"../src/help.php\">"._("Table of Contents")."</a>"; |
183 | if ($chapter >= count($helpdir)) echo " | <font color=\"$color[9]\">"._("Next")."</font>"; |
184 | else echo " | <a href=\"../src/help.php?chapter=".($chapter+1)."\">"._("Next")."</a>\n"; |
390372b4 |
185 | echo "</center></small><br>\n"; |
e222c290 |
186 | |
390372b4 |
187 | echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n"; |
1863670d |
188 | if (isset($help_info[1])) |
04632dbc |
189 | echo "$help_info[1]\n"; |
2d367c68 |
190 | else |
04632dbc |
191 | echo "<p>$help_info[2]</p>\n"; |
390372b4 |
192 | |
1863670d |
193 | $section = 0; |
390372b4 |
194 | for ($n = $help_info[3]; $n < count($doc); $n++) { |
195 | $section++; |
196 | $help_info = get_info($doc, $n); |
197 | echo "<b>$chapter.$section - $help_info[0]</b>"; |
198 | echo "<ul>"; |
199 | echo "$help_info[1]"; |
200 | echo "</ul>"; |
201 | $n = $help_info[3]; |
202 | } |
203 | |
04632dbc |
204 | echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>\n"; |
390372b4 |
205 | } |
206 | } |
2d367c68 |
207 | do_hook("help_bottom"); |
e222c290 |
208 | ?> |
8442ac08 |
209 | <tr><td bgcolor="<?php echo $color[0] ?>"> </td></tr></table> |
390372b4 |
210 | <td></tr></table> |
35586184 |
211 | </body></html> |