6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays help for the user
14 require_once('../src/validate.php');
15 require_once('../functions/display_messages.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/array.php');
19 displayPageHeader($color, 'None' );
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';
31 /****************[ HELP FUNCTIONS ]********************/
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.
39 function 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>') {
48 $ary[0] = trim($doc[$n]);
50 if (trim(strtolower($doc[$n])) == '<description>') {
52 for ($n++
;$n < count($doc)
53 && (trim(strtolower($doc[$n])) != '</description>');
58 if (trim(strtolower($doc[$n])) == '<summary>') {
60 for ($n++
; $n < count($doc)
61 && (trim(strtolower($doc[$n])) != '</summary>');
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!';
78 $ary[0] = 'ERROR: Help files are not in the right format!';
79 $ary[1] = 'ERROR: Help files are not in the right format!';
83 /**************[ END HELP FUNCTIONS ]******************/
88 <table width
="95%" align
="center" cellpadding
="2" cellspacing
="2" border
="0">
90 <td bgcolor
="<?php echo $color[0] ?>">
91 <center
><b
><?php
echo _("Help") ?
></b
></center
>
96 <?php
do_hook("help_top") ?
>
98 <table width
="90%" cellpadding
="0" cellspacing
="10" border
="0" align
="center">
102 if (isset($HTTP_REFERER)) {
103 $ref = strtolower($HTTP_REFERER);
104 if (strpos($ref, 'src/compose')){
105 $context = 'compose';
106 } else if (strpos($ref, 'src/addr')){
107 $context = 'address';
108 } else if (strpos($ref, 'src/folders')){
109 $context = 'folders';
110 } else if (strpos($ref, 'src/options')){
111 $context = 'options';
112 } else if (strpos($ref, 'src/right_main')){
114 } else if (strpos($ref, 'src/read_body')){
116 } else if (strpos($ref, 'src/search')){
121 if (!isset($squirrelmail_language)) {
122 $squirrelmail_language = 'en_US';
125 if (file_exists("../help/$squirrelmail_language")) {
127 $user_language = $squirrelmail_language;
128 } else if (file_exists('../help/en_US')) {
130 echo "<center><font color=\"$color[2]\">";
131 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']);
132 echo '</font></center><br>';
133 $user_language = 'en_US';
135 $help_exists = false;
136 echo "<br><center><font color=\"$color[2]\">";
137 echo _("Some or all of the help documents are not present!");
138 echo '</font></center>';
139 echo '</td></tr></table>';
140 /* this is really silly, because there may be some
141 * footers. What about them.
142 * TODO: Fix this so it's not just "exit".
147 if ($help_exists == true) {
148 if (!isset($context)){
151 if ($context == 'compose'){
153 } else if ($context == 'address'){
155 } else if ($context == 'folders'){
157 } else if ($context == 'options'){
159 } else if ($context == 'index'){
161 } else if ($context == 'read'){
163 } else if ($context == 'search'){
167 if (!isset($chapter)) {
168 echo '<table cellpadding="0" cellspacing="0" border="0"
169 align="center"><tr><td>';
170 echo '<b><center>' . _("Table of Contents") . '</center></b><br>';
171 do_hook('help_chapter');
173 for ($i=0; $i < count($helpdir); $i++
) {
174 $doc = file("../help/$user_language/$helpdir[$i]");
175 $help_info = get_info($doc, 0);
176 echo '<li><a href="../src/help.php?chapter=' . ($i+
1)
177 . '">' . $help_info[0] . '</a>';
178 echo '<ul>' . $help_info[2] . '</ul>';
181 echo '</td></tr></table>';
183 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
184 $help_info = get_info($doc, 0);
185 echo '<small><center>';
187 echo '<font color="' . $color[9] . '">' . _("Previous")
190 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
191 . '">' . _("Previous") . '</a> | ';
193 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
194 if ($chapter >= count($helpdir)){
195 echo ' | <font color="$color[9]">' . _("Next") . '</font>';
197 echo ' | <a href="../src/help.php?chapter=' . ($chapter+
1)
198 . '">' . _("Next") . '</a>';
200 echo '</center></small><br>';
202 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
203 . '</b></font><br><br>';
204 if (isset($help_info[1])){
207 echo '<p>' . $help_info[2] . '</p>';
211 for ($n = $help_info[3]; $n < count($doc); $n++
) {
213 $help_info = get_info($doc, $n);
214 echo "<b>$chapter.$section - $help_info[0]</b>";
221 echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
224 do_hook('help_bottom');
226 <tr
><td bgcolor
="<?php echo $color[0] ?>"> 
;</td
></tr
></table
>