42b236c48310fe702bcffafc7d1bd9836e77c142
6 * Displays help for the user
8 * @copyright © 1999-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
15 * Path for SquirrelMail required files.
18 define('SM_PATH','../');
20 /* SquirrelMail required files. */
21 include_once(SM_PATH
. 'include/validate.php');
22 require_once(SM_PATH
. 'functions/global.php');
23 require_once(SM_PATH
. 'functions/display_messages.php');
25 displayPageHeader($color, 'None' );
27 $helpdir[0] = 'basic.hlp';
28 $helpdir[1] = 'main_folder.hlp';
29 $helpdir[2] = 'read_mail.hlp';
30 $helpdir[3] = 'compose.hlp';
31 $helpdir[4] = 'addresses.hlp';
32 $helpdir[5] = 'folders.hlp';
33 $helpdir[6] = 'options.hlp';
34 $helpdir[7] = 'search.hlp';
35 $helpdir[8] = 'FAQ.hlp';
37 /****************[ HELP FUNCTIONS ]********************/
40 * parses through and gets the information from the different documents.
41 * this returns one section at a time. You must keep track of the position
42 * so that it knows where to start to look for the next section.
45 function get_info($doc, $pos) {
48 $cntdoc = count($doc);
50 for ($n=$pos; $n < $cntdoc; $n++
) {
51 if (trim(strtolower($doc[$n])) == '<chapter>'
52 ||
trim(strtolower($doc[$n])) == '<section>') {
53 for ($n++
; $n < $cntdoc
54 && (trim(strtolower($doc[$n])) != '</section>')
55 && (trim(strtolower($doc[$n])) != '</chapter>'); $n++
) {
56 if (trim(strtolower($doc[$n])) == '<title>') {
58 $ary[0] = trim($doc[$n]);
60 if (trim(strtolower($doc[$n])) == '<description>') {
62 for ($n++
;$n < $cntdoc
63 && (trim(strtolower($doc[$n])) != '</description>');
68 if (trim(strtolower($doc[$n])) == '<summary>') {
70 for ($n++
; $n < $cntdoc
71 && (trim(strtolower($doc[$n])) != '</summary>');
80 $ary[0] = _("ERROR: Help files are not in the right format!");
85 } else if (!trim(strtolower($doc[$n]))) {
92 $ary[0] = _("ERROR: Help files are not in the right format!");
99 /**************[ END HELP FUNCTIONS ]******************/
102 echo html_tag( 'table',
104 html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] )
106 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
110 echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
114 if (!isset($squirrelmail_language)) {
115 $squirrelmail_language = 'en_US';
118 if (file_exists("../help/$squirrelmail_language")) {
119 $user_language = $squirrelmail_language;
120 } else if (file_exists('../help/en_US')) {
121 echo "<center><font color=\"$color[2]\">"
122 ._("The help has not been translated to the selected language. It will be displayed in English instead.");
123 echo '</font></center><br />';
124 $user_language = 'en_US';
126 error_box( _("Some or all of the help documents are not present!"), $color );
131 /* take the chapternumber from the GET-vars,
132 * else see if we can get a relevant chapter from the referer */
135 if ( sqgetGlobalVar('chapter', $temp, SQ_GET
) ) {
136 $chapter = (int) $temp;
137 } elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER
) ) {
138 $ref = strtolower($temp);
140 $contexts = array ( 'src/compose' => 4, 'src/addr' => 5,
141 'src/folders' => 6, 'src/options' => 7, 'src/right_main' => 2,
142 'src/read_body' => 3, 'src/search' => 8 );
144 foreach($contexts as $path => $chap) {
145 if(strpos($ref, $path)) {
152 if ( $chapter == 0 ||
!isset( $helpdir[$chapter-1] ) ) {
153 echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' ) .
156 '<center><b>' . _("Table of Contents") . '</b></center><br />';
157 echo html_tag( 'ol' );
158 for ($i=0, $cnt = count($helpdir); $i < $cnt; $i++
) {
159 $doc = file("../help/$user_language/$helpdir[$i]");
160 $help_info = get_info($doc, 0);
161 echo '<li><a href="../src/help.php?chapter=' . ($i+
1)
162 . '">' . $help_info[0] . '</a>' .
163 html_tag( 'ul', $help_info[2] );
165 do_hook('help_chapter');
166 echo '</ol></td></tr></table>';
168 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
169 $help_info = get_info($doc, 0);
170 echo '<center><small>';
172 echo '<font color="' . $color[9] . '">' . _("Previous")
175 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
176 . '">' . _("Previous") . '</a> | ';
178 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
179 if ($chapter >= count($helpdir)){
180 echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>';
182 echo ' | <a href="../src/help.php?chapter=' . ($chapter+
1)
183 . '">' . _("Next") . '</a>';
185 echo '</small></center><br />';
187 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
188 . '</b></font><br /><br />';
190 if (isset($help_info[1]) && $help_info[1]) {
193 echo html_tag( 'p', $help_info[2], 'left' );
197 for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++
) {
199 $help_info = get_info($doc, $n);
200 echo "<b>$chapter.$section - $help_info[0]</b>" .
201 html_tag( 'ul', $help_info[1] );
205 echo '<br /><center><a href="#pagetop">' . _("Top") . '</a></center>';
208 do_hook('help_bottom');
211 html_tag( 'td', ' ', 'left', $color[0] )
217 $oTemplate->display('footer.tpl');