c3e5835d0add638ea3c718185fc9522676119acc
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/display_messages.php');
21 displayPageHeader($color, 'None' );
23 $helpdir[0] = 'basic.hlp';
24 $helpdir[1] = 'main_folder.hlp';
25 $helpdir[2] = 'read_mail.hlp';
26 $helpdir[3] = 'compose.hlp';
27 $helpdir[4] = 'addresses.hlp';
28 $helpdir[5] = 'folders.hlp';
29 $helpdir[6] = 'options.hlp';
30 $helpdir[7] = 'search.hlp';
31 $helpdir[8] = 'FAQ.hlp';
33 /****************[ HELP FUNCTIONS ]********************/
36 * parses through and gets the information from the different documents.
37 * this returns one section at a time. You must keep track of the position
38 * so that it knows where to start to look for the next section.
41 function get_info($doc, $pos) {
44 $cntdoc = count($doc);
46 for ($n=$pos; $n < $cntdoc; $n++
) {
47 if (trim(strtolower($doc[$n])) == '<chapter>'
48 ||
trim(strtolower($doc[$n])) == '<section>') {
49 for ($n++
; $n < $cntdoc
50 && (trim(strtolower($doc[$n])) != '</section>')
51 && (trim(strtolower($doc[$n])) != '</chapter>'); $n++
) {
52 if (trim(strtolower($doc[$n])) == '<title>') {
54 $ary[0] = trim($doc[$n]);
56 if (trim(strtolower($doc[$n])) == '<description>') {
58 for ($n++
;$n < $cntdoc
59 && (trim(strtolower($doc[$n])) != '</description>');
64 if (trim(strtolower($doc[$n])) == '<summary>') {
66 for ($n++
; $n < $cntdoc
67 && (trim(strtolower($doc[$n])) != '</summary>');
76 $ary[0] = _("ERROR: Help files are not in the right format!");
81 } else if (!trim(strtolower($doc[$n]))) {
88 $ary[0] = _("ERROR: Help files are not in the right format!");
95 /**************[ END HELP FUNCTIONS ]******************/
98 echo html_tag( 'table',
100 html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] )
102 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
106 echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
110 if (!isset($squirrelmail_language)) {
111 $squirrelmail_language = 'en_US';
114 if (file_exists("../help/$squirrelmail_language")) {
115 $user_language = $squirrelmail_language;
116 } else if (file_exists('../help/en_US')) {
117 echo "<center><font color=\"$color[2]\">";
118 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']);
119 echo '</font></center><br>';
120 $user_language = 'en_US';
122 error_box( _("Some or all of the help documents are not present!"), $color );
127 /* take the chapternumber from the GET-vars,
128 * else see if we can get a relevant chapter from the referer */
131 if ( sqgetGlobalVar('chapter', $temp, SQ_GET
) ) {
132 $chapter = (int) $temp;
133 } elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER
) ) {
134 $ref = strtolower($temp);
136 $contexts = array ( 'src/compose' => 4, 'src/addr' => 5,
137 'src/folders' => 6, 'src/options' => 7, 'src/right_main' => 2,
138 'src/read_body' => 3, 'src/search' => 8 );
140 foreach($contexts as $path => $chap) {
141 if(strpos($ref, $path)) {
148 if ( $chapter == 0 ||
!isset( $helpdir[$chapter-1] ) ) {
149 echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' );
152 '<b><center>' . _("Table of Contents") . '</center></b><br>';
153 do_hook('help_chapter');
154 echo html_tag( 'ol' );
155 for ($i=0, $cnt = count($helpdir); $i < $cnt; $i++
) {
156 $doc = file("../help/$user_language/$helpdir[$i]");
157 $help_info = get_info($doc, 0);
158 echo '<li><a href="../src/help.php?chapter=' . ($i+
1)
159 . '">' . $help_info[0] . '</a>' .
160 html_tag( 'ul', $help_info[2] );
162 echo '</ol></td></tr></table>';
164 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
165 $help_info = get_info($doc, 0);
166 echo '<small><center>';
168 echo '<font color="' . $color[9] . '">' . _("Previous")
171 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
172 . '">' . _("Previous") . '</a> | ';
174 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
175 if ($chapter >= count($helpdir)){
176 echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>';
178 echo ' | <a href="../src/help.php?chapter=' . ($chapter+
1)
179 . '">' . _("Next") . '</a>';
181 echo '</center></small><br>';
183 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
184 . '</b></font><br><br>';
186 if (isset($help_info[1]) && $help_info[1]) {
189 echo html_tag( 'p', $help_info[2], 'left' );
193 for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++
) {
195 $help_info = get_info($doc, $n);
196 echo "<b>$chapter.$section - $help_info[0]</b>" .
197 html_tag( 'ul', $help_info[1] );
201 echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
204 do_hook('help_bottom');
207 html_tag( 'td', ' ', 'left', $color[0] )
209 '</table></body></html>';