second try to fix sendMail. Return true after finalizeStream.
[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
86725763 14/* Path for SquirrelMail required files. */
15define('SM_PATH','../');
16
17/* SquirrelMail required files. */
08185f2a 18require_once(SM_PATH . 'include/validate.php');
86725763 19require_once(SM_PATH . 'functions/display_messages.php');
20require_once(SM_PATH . 'functions/imap.php');
21require_once(SM_PATH . 'functions/array.php');
390372b4 22
cd08020d 23displayPageHeader($color, 'None' );
24
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';
34
35/****************[ HELP FUNCTIONS ]********************/
390372b4 36
cd08020d 37/**
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.
41 */
42
43function 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>') {
51 $n++;
52 $ary[0] = trim($doc[$n]);
53 }
54 if (trim(strtolower($doc[$n])) == '<description>') {
55 $ary[1] = '';
56 for ($n++;$n < count($doc)
57 && (trim(strtolower($doc[$n])) != '</description>');
58 $n++) {
59 $ary[1] .= $doc[$n];
60 }
61 }
62 if (trim(strtolower($doc[$n])) == '<summary>') {
63 $ary[2] = '';
64 for ($n++; $n < count($doc)
65 && (trim(strtolower($doc[$n])) != '</summary>');
66 $n++) {
67 $ary[2] .= $doc[$n];
68 }
69 }
2d367c68 70 }
1863670d 71 if (isset($ary)) {
cd08020d 72 $ary[3] = $n;
73 return $ary;
390372b4 74 } else {
cd08020d 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!';
78 return $ary;
2d367c68 79 }
cd08020d 80 }
81 }
82 $ary[0] = 'ERROR: Help files are not in the right format!';
83 $ary[1] = 'ERROR: Help files are not in the right format!';
84 return $ary;
85}
2d367c68 86
cd08020d 87/**************[ END HELP FUNCTIONS ]******************/
390372b4 88
390372b4 89
3530b83b 90
6206f6c4 91echo html_tag( 'table',
3530b83b 92 html_tag( 'tr',
93 html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] )
94 ) ,
6206f6c4 95 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
3530b83b 96
97do_hook("help_top");
98
99echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
100 html_tag( 'tr' ) .
101 html_tag( 'td' );
102
cd08020d 103if (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')){
114 $context = 'index';
115 } else if (strpos($ref, 'src/read_body')){
116 $context = 'read';
117 } else if (strpos($ref, 'src/search')){
118 $context = 'search';
119 }
120}
121
122if (!isset($squirrelmail_language)) {
e5916f84 123 $squirrelmail_language = 'en_US';
cd08020d 124}
125
cd08020d 126if (file_exists("../help/$squirrelmail_language")) {
127 $help_exists = true;
128 $user_language = $squirrelmail_language;
e5916f84 129} else if (file_exists('../help/en_US')) {
cd08020d 130 $help_exists = true;
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>';
e5916f84 134 $user_language = 'en_US';
cd08020d 135} else {
136 $help_exists = false;
353616c4 137 echo "<br><center><font color=\"$color[2]\">" .
138 _("Some or all of the help documents are not present!").
139 '</font></center>'.
140 '</td></tr></table>';
cd08020d 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".
144 */
145 exit;
146}
147
148if ($help_exists == true) {
149 if (!isset($context)){
150 $context = '';
151 }
152 if ($context == 'compose'){
153 $chapter = 4;
154 } else if ($context == 'address'){
155 $chapter = 5;
156 } else if ($context == 'folders'){
157 $chapter = 6;
158 } else if ($context == 'options'){
159 $chapter = 7;
160 } else if ($context == 'index'){
161 $chapter = 2;
162 } else if ($context == 'read'){
163 $chapter = 3;
164 } else if ($context == 'search'){
165 $chapter = 8;
166 }
167
168 if (!isset($chapter)) {
3530b83b 169 echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' );
170 html_tag( 'tr' ) .
171 html_tag( 'td' ) .
172 '<b><center>' . _("Table of Contents") . '</center></b><br>';
cd08020d 173 do_hook('help_chapter');
3530b83b 174 echo html_tag( 'ol' );
cd08020d 175 for ($i=0; $i < count($helpdir); $i++) {
390372b4 176 $doc = file("../help/$user_language/$helpdir[$i]");
177 $help_info = get_info($doc, 0);
353616c4 178 echo '<li><a href="../src/help.php?chapter=' . ($i+1)
3530b83b 179 . '">' . $help_info[0] . '</a>' .
180 html_tag( 'ul', $help_info[2] );
cd08020d 181 }
353616c4 182 echo '</ol></td></tr></table>';
cd08020d 183 } else {
184 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
185 $help_info = get_info($doc, 0);
186 echo '<small><center>';
187 if ($chapter <= 1){
353616c4 188 echo '<font color="' . $color[9] . '">' . _("Previous")
cd08020d 189 . '</font> | ';
190 } else {
353616c4 191 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
cd08020d 192 . '">' . _("Previous") . '</a> | ';
193 }
194 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
195 if ($chapter >= count($helpdir)){
196 echo ' | <font color="$color[9]">' . _("Next") . '</font>';
353616c4 197 } else {
cd08020d 198 echo ' | <a href="../src/help.php?chapter=' . ($chapter+1)
199 . '">' . _("Next") . '</a>';
200 }
201 echo '</center></small><br>';
202
203 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
204 . '</b></font><br><br>';
205 if (isset($help_info[1])){
206 echo $help_info[1];
207 } else {
3530b83b 208 echo html_tag( 'p', $help_info[2], 'left' );
cd08020d 209 }
210
211 $section = 0;
212 for ($n = $help_info[3]; $n < count($doc); $n++) {
390372b4 213 $section++;
214 $help_info = get_info($doc, $n);
3530b83b 215 echo "<b>$chapter.$section - $help_info[0]</b>" .
216 html_tag( 'ul', $help_info[1] );
390372b4 217 $n = $help_info[3];
cd08020d 218 }
390372b4 219
cd08020d 220 echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
221 }
222}
223do_hook('help_bottom');
3530b83b 224
225echo html_tag( 'tr',
226 html_tag( 'td', '&nbsp;', 'left', $color[0] )
227 ).
228 '</table></body></html>';
e222c290 229?>