6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays help for the user
14 /* Path for SquirrelMail required files. */
15 define('SM_PATH','../');
17 /* SquirrelMail required files. */
18 require_once(SM_PATH
. 'include/validate.php');
19 require_once(SM_PATH
. 'functions/display_messages.php');
20 require_once(SM_PATH
. 'functions/imap.php');
21 require_once(SM_PATH
. 'functions/array.php');
23 displayPageHeader($color, 'None' );
25 $helpdir[0] = 'basic.hlp';
26 $helpdir[1] = 'main_folder.hlp';
27 $helpdir[2] = 'read_mail.hlp';
28 $helpdir[3] = 'compose.hlp';
29 $helpdir[4] = 'addresses.hlp';
30 $helpdir[5] = 'folders.hlp';
31 $helpdir[6] = 'options.hlp';
32 $helpdir[7] = 'search.hlp';
33 $helpdir[8] = 'FAQ.hlp';
35 /****************[ HELP FUNCTIONS ]********************/
38 * parses through and gets the information from the different documents.
39 * this returns one section at a time. You must keep track of the position
40 * so that it knows where to start to look for the next section.
43 function get_info($doc, $pos) {
44 for ($n=$pos; $n < count($doc); $n++
) {
45 if (trim(strtolower($doc[$n])) == '<chapter>'
46 ||
trim(strtolower($doc[$n])) == '<section>') {
47 for ($n++
;$n < count($doc)
48 && (trim(strtolower($doc[$n])) != '</section>')
49 && (trim(strtolower($doc[$n])) != '</chapter>'); $n++
) {
50 if (trim(strtolower($doc[$n])) == '<title>') {
52 $ary[0] = trim($doc[$n]);
54 if (trim(strtolower($doc[$n])) == '<description>') {
56 for ($n++
;$n < count($doc)
57 && (trim(strtolower($doc[$n])) != '</description>');
62 if (trim(strtolower($doc[$n])) == '<summary>') {
64 for ($n++
; $n < count($doc)
65 && (trim(strtolower($doc[$n])) != '</summary>');
75 $ary[0] = 'ERROR: Help files are not in the right format!';
76 $ary[1] = 'ERROR: Help files are not in the right format!';
77 $ary[2] = 'ERROR: Help files are not in the right format!';
82 $ary[0] = 'ERROR: Help files are not in the right format!';
83 $ary[1] = 'ERROR: Help files are not in the right format!';
87 /**************[ END HELP FUNCTIONS ]******************/
91 echo html_tag( 'table',
93 html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] )
95 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
99 echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
103 if (isset($HTTP_REFERER)) {
104 $ref = strtolower($HTTP_REFERER);
105 if (strpos($ref, 'src/compose')){
106 $context = 'compose';
107 } else if (strpos($ref, 'src/addr')){
108 $context = 'address';
109 } else if (strpos($ref, 'src/folders')){
110 $context = 'folders';
111 } else if (strpos($ref, 'src/options')){
112 $context = 'options';
113 } else if (strpos($ref, 'src/right_main')){
115 } else if (strpos($ref, 'src/read_body')){
117 } else if (strpos($ref, 'src/search')){
122 if (!isset($squirrelmail_language)) {
123 $squirrelmail_language = 'en_US';
126 if (file_exists("../help/$squirrelmail_language")) {
128 $user_language = $squirrelmail_language;
129 } else if (file_exists('../help/en_US')) {
131 echo "<center><font color=\"$color[2]\">";
132 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']);
133 echo '</font></center><br>';
134 $user_language = 'en_US';
136 $help_exists = false;
137 echo "<br><center><font color=\"$color[2]\">" .
138 _("Some or all of the help documents are not present!").
140 '</td></tr></table>';
141 /* this is really silly, because there may be some
142 * footers. What about them.
143 * TODO: Fix this so it's not just "exit".
148 if ($help_exists == true) {
149 if (!isset($context)){
152 if ($context == 'compose'){
154 } else if ($context == 'address'){
156 } else if ($context == 'folders'){
158 } else if ($context == 'options'){
160 } else if ($context == 'index'){
162 } else if ($context == 'read'){
164 } else if ($context == 'search'){
168 if (!isset($chapter)) {
169 echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' );
172 '<b><center>' . _("Table of Contents") . '</center></b><br>';
173 do_hook('help_chapter');
174 echo html_tag( 'ol' );
175 for ($i=0; $i < count($helpdir); $i++
) {
176 $doc = file("../help/$user_language/$helpdir[$i]");
177 $help_info = get_info($doc, 0);
178 echo '<li><a href="../src/help.php?chapter=' . ($i+
1)
179 . '">' . $help_info[0] . '</a>' .
180 html_tag( 'ul', $help_info[2] );
182 echo '</ol></td></tr></table>';
184 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
185 $help_info = get_info($doc, 0);
186 echo '<small><center>';
188 echo '<font color="' . $color[9] . '">' . _("Previous")
191 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
192 . '">' . _("Previous") . '</a> | ';
194 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
195 if ($chapter >= count($helpdir)){
196 echo ' | <font color="$color[9]">' . _("Next") . '</font>';
198 echo ' | <a href="../src/help.php?chapter=' . ($chapter+
1)
199 . '">' . _("Next") . '</a>';
201 echo '</center></small><br>';
203 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
204 . '</b></font><br><br>';
205 if (isset($help_info[1])){
208 echo html_tag( 'p', $help_info[2], 'left' );
212 for ($n = $help_info[3]; $n < count($doc); $n++
) {
214 $help_info = get_info($doc, $n);
215 echo "<b>$chapter.$section - $help_info[0]</b>" .
216 html_tag( 'ul', $help_info[1] );
220 echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
223 do_hook('help_bottom');
226 html_tag( 'td', ' ', 'left', $color[0] )
228 '</table></body></html>';