6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays help for the user
12 * @package squirrelmail
15 /** Path for SquirrelMail required files. */
16 define('SM_PATH','../');
18 /* SquirrelMail required files. */
19 require_once(SM_PATH
. 'include/validate.php');
20 require_once(SM_PATH
. 'functions/global.php');
21 require_once(SM_PATH
. 'functions/display_messages.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) {
46 $cntdoc = count($doc);
48 for ($n=$pos; $n < $cntdoc; $n++
) {
49 if (trim(strtolower($doc[$n])) == '<chapter>'
50 ||
trim(strtolower($doc[$n])) == '<section>') {
51 for ($n++
; $n < $cntdoc
52 && (trim(strtolower($doc[$n])) != '</section>')
53 && (trim(strtolower($doc[$n])) != '</chapter>'); $n++
) {
54 if (trim(strtolower($doc[$n])) == '<title>') {
56 $ary[0] = trim($doc[$n]);
58 if (trim(strtolower($doc[$n])) == '<description>') {
60 for ($n++
;$n < $cntdoc
61 && (trim(strtolower($doc[$n])) != '</description>');
66 if (trim(strtolower($doc[$n])) == '<summary>') {
68 for ($n++
; $n < $cntdoc
69 && (trim(strtolower($doc[$n])) != '</summary>');
78 $ary[0] = _("ERROR: Help files are not in the right format!");
83 } else if (!trim(strtolower($doc[$n]))) {
90 $ary[0] = _("ERROR: Help files are not in the right format!");
97 /**************[ END HELP FUNCTIONS ]******************/
100 echo html_tag( 'table',
102 html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] )
104 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
108 echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
112 if (!isset($squirrelmail_language)) {
113 $squirrelmail_language = 'en_US';
116 if (file_exists("../help/$squirrelmail_language")) {
117 $user_language = $squirrelmail_language;
118 } else if (file_exists('../help/en_US')) {
119 echo "<center><font color=\"$color[2]\">";
120 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']);
121 echo '</font></center><br>';
122 $user_language = 'en_US';
124 error_box( _("Some or all of the help documents are not present!"), $color );
129 /* take the chapternumber from the GET-vars,
130 * else see if we can get a relevant chapter from the referer */
133 if ( sqgetGlobalVar('chapter', $temp, SQ_GET
) ) {
134 $chapter = (int) $temp;
135 } elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER
) ) {
136 $ref = strtolower($temp);
138 $contexts = array ( 'src/compose' => 4, 'src/addr' => 5,
139 'src/folders' => 6, 'src/options' => 7, 'src/right_main' => 2,
140 'src/read_body' => 3, 'src/search' => 8 );
142 foreach($contexts as $path => $chap) {
143 if(strpos($ref, $path)) {
150 if ( $chapter == 0 ||
!isset( $helpdir[$chapter-1] ) ) {
151 echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' );
154 '<b><center>' . _("Table of Contents") . '</center></b><br>';
155 echo html_tag( 'ol' );
156 for ($i=0, $cnt = count($helpdir); $i < $cnt; $i++
) {
157 $doc = file("../help/$user_language/$helpdir[$i]");
158 $help_info = get_info($doc, 0);
159 echo '<li><a href="../src/help.php?chapter=' . ($i+
1)
160 . '">' . $help_info[0] . '</a>' .
161 html_tag( 'ul', $help_info[2] );
163 do_hook('help_chapter');
164 echo '</ol></td></tr></table>';
166 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
167 $help_info = get_info($doc, 0);
168 echo '<small><center>';
170 echo '<font color="' . $color[9] . '">' . _("Previous")
173 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
174 . '">' . _("Previous") . '</a> | ';
176 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
177 if ($chapter >= count($helpdir)){
178 echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>';
180 echo ' | <a href="../src/help.php?chapter=' . ($chapter+
1)
181 . '">' . _("Next") . '</a>';
183 echo '</center></small><br>';
185 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
186 . '</b></font><br><br>';
188 if (isset($help_info[1]) && $help_info[1]) {
191 echo html_tag( 'p', $help_info[2], 'left' );
195 for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++
) {
197 $help_info = get_info($doc, $n);
198 echo "<b>$chapter.$section - $help_info[0]</b>" .
199 html_tag( 'ul', $help_info[1] );
203 echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
206 do_hook('help_bottom');
209 html_tag( 'td', ' ', 'left', $color[0] )
211 '</table></body></html>';