Reworked subfolder message count and all. Open to suggestions for the
[squirrelmail.git] / src / help.php
CommitLineData
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
35586184 14require_once('../src/validate.php');
15require_once('../functions/display_messages.php');
16require_once('../functions/imap.php');
17require_once('../functions/array.php');
390372b4 18
cd08020d 19displayPageHeader($color, 'None' );
20
21$helpdir[0] = 'basic.hlp';
22$helpdir[1] = 'main_folder.hlp';
23$helpdir[2] = 'read_mail.hlp';
24$helpdir[3] = 'compose.hlp';
25$helpdir[4] = 'addresses.hlp';
26$helpdir[5] = 'folders.hlp';
27$helpdir[6] = 'options.hlp';
28$helpdir[7] = 'search.hlp';
29$helpdir[8] = 'FAQ.hlp';
30
31/****************[ HELP FUNCTIONS ]********************/
390372b4 32
cd08020d 33/**
34 * parses through and gets the information from the different documents.
35 * this returns one section at a time. You must keep track of the position
36 * so that it knows where to start to look for the next section.
37 */
38
39function get_info($doc, $pos) {
40 for ($n=$pos; $n < count($doc); $n++) {
41 if (trim(strtolower($doc[$n])) == '<chapter>'
42 || trim(strtolower($doc[$n])) == '<section>') {
43 for ($n++;$n < count($doc)
44 && (trim(strtolower($doc[$n])) != '</section>')
45 && (trim(strtolower($doc[$n])) != '</chapter>'); $n++) {
46 if (trim(strtolower($doc[$n])) == '<title>') {
47 $n++;
48 $ary[0] = trim($doc[$n]);
49 }
50 if (trim(strtolower($doc[$n])) == '<description>') {
51 $ary[1] = '';
52 for ($n++;$n < count($doc)
53 && (trim(strtolower($doc[$n])) != '</description>');
54 $n++) {
55 $ary[1] .= $doc[$n];
56 }
57 }
58 if (trim(strtolower($doc[$n])) == '<summary>') {
59 $ary[2] = '';
60 for ($n++; $n < count($doc)
61 && (trim(strtolower($doc[$n])) != '</summary>');
62 $n++) {
63 $ary[2] .= $doc[$n];
64 }
65 }
2d367c68 66 }
1863670d 67 if (isset($ary)) {
cd08020d 68 $ary[3] = $n;
69 return $ary;
390372b4 70 } else {
cd08020d 71 $ary[0] = 'ERROR: Help files are not in the right format!';
72 $ary[1] = 'ERROR: Help files are not in the right format!';
73 $ary[2] = 'ERROR: Help files are not in the right format!';
74 return $ary;
2d367c68 75 }
cd08020d 76 }
77 }
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 return $ary;
81}
2d367c68 82
cd08020d 83/**************[ END HELP FUNCTIONS ]******************/
390372b4 84
390372b4 85
3530b83b 86
6206f6c4 87echo html_tag( 'table',
3530b83b 88 html_tag( 'tr',
89 html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] )
90 ) ,
6206f6c4 91 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
3530b83b 92
93do_hook("help_top");
94
95echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
96 html_tag( 'tr' ) .
97 html_tag( 'td' );
98
cd08020d 99if (isset($HTTP_REFERER)) {
100 $ref = strtolower($HTTP_REFERER);
101 if (strpos($ref, 'src/compose')){
102 $context = 'compose';
103 } else if (strpos($ref, 'src/addr')){
104 $context = 'address';
105 } else if (strpos($ref, 'src/folders')){
106 $context = 'folders';
107 } else if (strpos($ref, 'src/options')){
108 $context = 'options';
109 } else if (strpos($ref, 'src/right_main')){
110 $context = 'index';
111 } else if (strpos($ref, 'src/read_body')){
112 $context = 'read';
113 } else if (strpos($ref, 'src/search')){
114 $context = 'search';
115 }
116}
117
118if (!isset($squirrelmail_language)) {
e5916f84 119 $squirrelmail_language = 'en_US';
cd08020d 120}
121
cd08020d 122if (file_exists("../help/$squirrelmail_language")) {
123 $help_exists = true;
124 $user_language = $squirrelmail_language;
e5916f84 125} else if (file_exists('../help/en_US')) {
cd08020d 126 $help_exists = true;
127 echo "<center><font color=\"$color[2]\">";
128 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']);
129 echo '</font></center><br>';
e5916f84 130 $user_language = 'en_US';
cd08020d 131} else {
132 $help_exists = false;
353616c4 133 echo "<br><center><font color=\"$color[2]\">" .
134 _("Some or all of the help documents are not present!").
135 '</font></center>'.
136 '</td></tr></table>';
cd08020d 137 /* this is really silly, because there may be some
138 * footers. What about them.
139 * TODO: Fix this so it's not just "exit".
140 */
141 exit;
142}
143
144if ($help_exists == true) {
145 if (!isset($context)){
146 $context = '';
147 }
148 if ($context == 'compose'){
149 $chapter = 4;
150 } else if ($context == 'address'){
151 $chapter = 5;
152 } else if ($context == 'folders'){
153 $chapter = 6;
154 } else if ($context == 'options'){
155 $chapter = 7;
156 } else if ($context == 'index'){
157 $chapter = 2;
158 } else if ($context == 'read'){
159 $chapter = 3;
160 } else if ($context == 'search'){
161 $chapter = 8;
162 }
163
164 if (!isset($chapter)) {
3530b83b 165 echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' );
166 html_tag( 'tr' ) .
167 html_tag( 'td' ) .
168 '<b><center>' . _("Table of Contents") . '</center></b><br>';
cd08020d 169 do_hook('help_chapter');
3530b83b 170 echo html_tag( 'ol' );
cd08020d 171 for ($i=0; $i < count($helpdir); $i++) {
390372b4 172 $doc = file("../help/$user_language/$helpdir[$i]");
173 $help_info = get_info($doc, 0);
353616c4 174 echo '<li><a href="../src/help.php?chapter=' . ($i+1)
3530b83b 175 . '">' . $help_info[0] . '</a>' .
176 html_tag( 'ul', $help_info[2] );
cd08020d 177 }
353616c4 178 echo '</ol></td></tr></table>';
cd08020d 179 } else {
180 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
181 $help_info = get_info($doc, 0);
182 echo '<small><center>';
183 if ($chapter <= 1){
353616c4 184 echo '<font color="' . $color[9] . '">' . _("Previous")
cd08020d 185 . '</font> | ';
186 } else {
353616c4 187 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
cd08020d 188 . '">' . _("Previous") . '</a> | ';
189 }
190 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
191 if ($chapter >= count($helpdir)){
192 echo ' | <font color="$color[9]">' . _("Next") . '</font>';
353616c4 193 } else {
cd08020d 194 echo ' | <a href="../src/help.php?chapter=' . ($chapter+1)
195 . '">' . _("Next") . '</a>';
196 }
197 echo '</center></small><br>';
198
199 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
200 . '</b></font><br><br>';
201 if (isset($help_info[1])){
202 echo $help_info[1];
203 } else {
3530b83b 204 echo html_tag( 'p', $help_info[2], 'left' );
cd08020d 205 }
206
207 $section = 0;
208 for ($n = $help_info[3]; $n < count($doc); $n++) {
390372b4 209 $section++;
210 $help_info = get_info($doc, $n);
3530b83b 211 echo "<b>$chapter.$section - $help_info[0]</b>" .
212 html_tag( 'ul', $help_info[1] );
390372b4 213 $n = $help_info[3];
cd08020d 214 }
390372b4 215
cd08020d 216 echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
217 }
218}
219do_hook('help_bottom');
3530b83b 220
221echo html_tag( 'tr',
222 html_tag( 'td', '&nbsp;', 'left', $color[0] )
223 ).
224 '</table></body></html>';
e222c290 225?>