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
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/global.php');
20 require_once(SM_PATH
. 'functions/display_messages.php');
22 displayPageHeader($color, 'None' );
24 $helpdir[0] = 'basic.hlp';
25 $helpdir[1] = 'main_folder.hlp';
26 $helpdir[2] = 'read_mail.hlp';
27 $helpdir[3] = 'compose.hlp';
28 $helpdir[4] = 'addresses.hlp';
29 $helpdir[5] = 'folders.hlp';
30 $helpdir[6] = 'options.hlp';
31 $helpdir[7] = 'search.hlp';
32 $helpdir[8] = 'FAQ.hlp';
34 /****************[ HELP FUNCTIONS ]********************/
37 * parses through and gets the information from the different documents.
38 * this returns one section at a time. You must keep track of the position
39 * so that it knows where to start to look for the next section.
42 function get_info($doc, $pos) {
45 $cntdoc = count($doc);
47 for ($n=$pos; $n < $cntdoc; $n++
) {
48 if (trim(strtolower($doc[$n])) == '<chapter>'
49 ||
trim(strtolower($doc[$n])) == '<section>') {
50 for ($n++
; $n < $cntdoc
51 && (trim(strtolower($doc[$n])) != '</section>')
52 && (trim(strtolower($doc[$n])) != '</chapter>'); $n++
) {
53 if (trim(strtolower($doc[$n])) == '<title>') {
55 $ary[0] = trim($doc[$n]);
57 if (trim(strtolower($doc[$n])) == '<description>') {
59 for ($n++
;$n < $cntdoc
60 && (trim(strtolower($doc[$n])) != '</description>');
65 if (trim(strtolower($doc[$n])) == '<summary>') {
67 for ($n++
; $n < $cntdoc
68 && (trim(strtolower($doc[$n])) != '</summary>');
77 $ary[0] = _("ERROR: Help files are not in the right format!");
82 } else if (!trim(strtolower($doc[$n]))) {
89 $ary[0] = _("ERROR: Help files are not in the right format!");
96 /**************[ END HELP FUNCTIONS ]******************/
99 echo html_tag( 'table',
101 html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] )
103 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
107 echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
111 if (!isset($squirrelmail_language)) {
112 $squirrelmail_language = 'en_US';
115 if (file_exists("../help/$squirrelmail_language")) {
116 $user_language = $squirrelmail_language;
117 } else if (file_exists('../help/en_US')) {
118 echo "<center><font color=\"$color[2]\">";
119 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']);
120 echo '</font></center><br>';
121 $user_language = 'en_US';
123 error_box( _("Some or all of the help documents are not present!"), $color );
128 /* take the chapternumber from the GET-vars,
129 * else see if we can get a relevant chapter from the referer */
132 if ( sqgetGlobalVar('chapter', $temp, SQ_GET
) ) {
133 $chapter = (int) $temp;
134 } elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER
) ) {
135 $ref = strtolower($temp);
137 $contexts = array ( 'src/compose' => 4, 'src/addr' => 5,
138 'src/folders' => 6, 'src/options' => 7, 'src/right_main' => 2,
139 'src/read_body' => 3, 'src/search' => 8 );
141 foreach($contexts as $path => $chap) {
142 if(strpos($ref, $path)) {
149 if ( $chapter == 0 ||
!isset( $helpdir[$chapter-1] ) ) {
150 echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' );
153 '<b><center>' . _("Table of Contents") . '</center></b><br>';
154 do_hook('help_chapter');
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 echo '</ol></td></tr></table>';
165 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
166 $help_info = get_info($doc, 0);
167 echo '<small><center>';
169 echo '<font color="' . $color[9] . '">' . _("Previous")
172 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
173 . '">' . _("Previous") . '</a> | ';
175 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
176 if ($chapter >= count($helpdir)){
177 echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>';
179 echo ' | <a href="../src/help.php?chapter=' . ($chapter+
1)
180 . '">' . _("Next") . '</a>';
182 echo '</center></small><br>';
184 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
185 . '</b></font><br><br>';
187 if (isset($help_info[1]) && $help_info[1]) {
190 echo html_tag( 'p', $help_info[2], 'left' );
194 for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++
) {
196 $help_info = get_info($doc, $n);
197 echo "<b>$chapter.$section - $help_info[0]</b>" .
198 html_tag( 'ul', $help_info[1] );
202 echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
205 do_hook('help_bottom');
208 html_tag( 'td', ' ', 'left', $color[0] )
210 '</table></body></html>';