This segment of code should be left in until at least Squirrelmail 1.7.x, to give...
[squirrelmail.git] / src / help.php
... / ...
CommitLineData
1<?php
2
3/**
4 * help.php
5 *
6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Displays help for the user
10 *
11 * $Id$
12 * @package squirrelmail
13 */
14
15/** Path for SquirrelMail required files. */
16define('SM_PATH','../');
17
18/* SquirrelMail required files. */
19require_once(SM_PATH . 'include/validate.php');
20require_once(SM_PATH . 'functions/global.php');
21require_once(SM_PATH . 'functions/display_messages.php');
22
23displayPageHeader($color, 'None' );
24
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';
34
35/****************[ HELP FUNCTIONS ]********************/
36
37/**
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.
41 */
42
43function get_info($doc, $pos) {
44 $ary = array(0,0,0);
45
46 $cntdoc = count($doc);
47
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>') {
55 $n++;
56 $ary[0] = trim($doc[$n]);
57 }
58 if (trim(strtolower($doc[$n])) == '<description>') {
59 $ary[1] = '';
60 for ($n++;$n < $cntdoc
61 && (trim(strtolower($doc[$n])) != '</description>');
62 $n++) {
63 $ary[1] .= $doc[$n];
64 }
65 }
66 if (trim(strtolower($doc[$n])) == '<summary>') {
67 $ary[2] = '';
68 for ($n++; $n < $cntdoc
69 && (trim(strtolower($doc[$n])) != '</summary>');
70 $n++) {
71 $ary[2] .= $doc[$n];
72 }
73 }
74 }
75 if (isset($ary)) {
76 $ary[3] = $n;
77 } else {
78 $ary[0] = _("ERROR: Help files are not in the right format!");
79 $ary[1] = $ary[0];
80 $ary[2] = $ary[0];
81 }
82 return( $ary );
83 } else if (!trim(strtolower($doc[$n]))) {
84 $ary[0] = '';
85 $ary[1] = '';
86 $ary[2] = '';
87 $ary[3] = $n;
88 }
89 }
90 $ary[0] = _("ERROR: Help files are not in the right format!");
91 $ary[1] = $ary[0];
92 $ary[2] = $ary[0];
93 $ary[3] = $n;
94 return( $ary );
95}
96
97/**************[ END HELP FUNCTIONS ]******************/
98
99
100echo html_tag( 'table',
101 html_tag( 'tr',
102 html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] )
103 ) ,
104 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
105
106do_hook('help_top');
107
108echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
109 html_tag( 'tr' ) .
110 html_tag( 'td' );
111
112if (!isset($squirrelmail_language)) {
113 $squirrelmail_language = 'en_US';
114}
115
116if (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';
123} else {
124 error_box( _("Some or all of the help documents are not present!"), $color );
125 exit;
126}
127
128
129/* take the chapternumber from the GET-vars,
130 * else see if we can get a relevant chapter from the referer */
131$chapter = 0;
132
133if ( sqgetGlobalVar('chapter', $temp, SQ_GET) ) {
134 $chapter = (int) $temp;
135} elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER) ) {
136 $ref = strtolower($temp);
137
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 );
141
142 foreach($contexts as $path => $chap) {
143 if(strpos($ref, $path)) {
144 $chapter = $chap;
145 break;
146 }
147 }
148}
149
150if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) {
151 echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' );
152 html_tag( 'tr' ) .
153 html_tag( 'td' ) .
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] );
162 }
163 do_hook('help_chapter');
164 echo '</ol></td></tr></table>';
165} else {
166 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
167 $help_info = get_info($doc, 0);
168 echo '<small><center>';
169 if ($chapter <= 1){
170 echo '<font color="' . $color[9] . '">' . _("Previous")
171 . '</font> | ';
172 } else {
173 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
174 . '">' . _("Previous") . '</a> | ';
175 }
176 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
177 if ($chapter >= count($helpdir)){
178 echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>';
179 } else {
180 echo ' | <a href="../src/help.php?chapter=' . ($chapter+1)
181 . '">' . _("Next") . '</a>';
182 }
183 echo '</center></small><br>';
184
185 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
186 . '</b></font><br><br>';
187
188 if (isset($help_info[1]) && $help_info[1]) {
189 echo $help_info[1];
190 } else {
191 echo html_tag( 'p', $help_info[2], 'left' );
192 }
193
194 $section = 0;
195 for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++) {
196 $section++;
197 $help_info = get_info($doc, $n);
198 echo "<b>$chapter.$section - $help_info[0]</b>" .
199 html_tag( 'ul', $help_info[1] );
200 $n = $help_info[3];
201 }
202
203 echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
204}
205
206do_hook('help_bottom');
207
208echo html_tag( 'tr',
209 html_tag( 'td', '&nbsp;', 'left', $color[0] )
210 ).
211 '</table></body></html>';
212?>