e222c290 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * help.php |
5 | * |
82d304a0 |
6 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Displays help for the user |
10 | * |
11 | * $Id$ |
8f6f9ba5 |
12 | * @package squirrelmail |
35586184 |
13 | */ |
14 | |
8f6f9ba5 |
15 | /** Path for SquirrelMail required files. */ |
86725763 |
16 | define('SM_PATH','../'); |
17 | |
18 | /* SquirrelMail required files. */ |
08185f2a |
19 | require_once(SM_PATH . 'include/validate.php'); |
8650e9e1 |
20 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
21 | require_once(SM_PATH . 'functions/display_messages.php'); |
390372b4 |
22 | |
cd08020d |
23 | displayPageHeader($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 ]********************/ |
390372b4 |
36 | |
cd08020d |
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 | |
43 | function get_info($doc, $pos) { |
143c7a82 |
44 | $ary = array(0,0,0); |
7ea33e5b |
45 | |
46 | $cntdoc = count($doc); |
47 | |
48 | for ($n=$pos; $n < $cntdoc; $n++) { |
cd08020d |
49 | if (trim(strtolower($doc[$n])) == '<chapter>' |
50 | || trim(strtolower($doc[$n])) == '<section>') { |
7ea33e5b |
51 | for ($n++; $n < $cntdoc |
cd08020d |
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] = ''; |
7ea33e5b |
60 | for ($n++;$n < $cntdoc |
cd08020d |
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] = ''; |
7ea33e5b |
68 | for ($n++; $n < $cntdoc |
cd08020d |
69 | && (trim(strtolower($doc[$n])) != '</summary>'); |
70 | $n++) { |
71 | $ary[2] .= $doc[$n]; |
72 | } |
73 | } |
2d367c68 |
74 | } |
1863670d |
75 | if (isset($ary)) { |
cd08020d |
76 | $ary[3] = $n; |
390372b4 |
77 | } else { |
0120b304 |
78 | $ary[0] = _("ERROR: Help files are not in the right format!"); |
79 | $ary[1] = $ary[0]; |
80 | $ary[2] = $ary[0]; |
2d367c68 |
81 | } |
0120b304 |
82 | return( $ary ); |
143c7a82 |
83 | } else if (!trim(strtolower($doc[$n]))) { |
84 | $ary[0] = ''; |
85 | $ary[1] = ''; |
86 | $ary[2] = ''; |
87 | $ary[3] = $n; |
88 | } |
cd08020d |
89 | } |
0120b304 |
90 | $ary[0] = _("ERROR: Help files are not in the right format!"); |
91 | $ary[1] = $ary[0]; |
143c7a82 |
92 | $ary[2] = $ary[0]; |
93 | $ary[3] = $n; |
0120b304 |
94 | return( $ary ); |
cd08020d |
95 | } |
2d367c68 |
96 | |
cd08020d |
97 | /**************[ END HELP FUNCTIONS ]******************/ |
390372b4 |
98 | |
390372b4 |
99 | |
6206f6c4 |
100 | echo html_tag( 'table', |
3530b83b |
101 | html_tag( 'tr', |
102 | html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] ) |
103 | ) , |
6206f6c4 |
104 | 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' ); |
3530b83b |
105 | |
7ea33e5b |
106 | do_hook('help_top'); |
3530b83b |
107 | |
108 | echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) . |
109 | html_tag( 'tr' ) . |
110 | html_tag( 'td' ); |
111 | |
cd08020d |
112 | if (!isset($squirrelmail_language)) { |
e5916f84 |
113 | $squirrelmail_language = 'en_US'; |
cd08020d |
114 | } |
115 | |
cd08020d |
116 | if (file_exists("../help/$squirrelmail_language")) { |
cd08020d |
117 | $user_language = $squirrelmail_language; |
e5916f84 |
118 | } else if (file_exists('../help/en_US')) { |
cd08020d |
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>'; |
e5916f84 |
122 | $user_language = 'en_US'; |
cd08020d |
123 | } else { |
7ea33e5b |
124 | error_box( _("Some or all of the help documents are not present!"), $color ); |
cd08020d |
125 | exit; |
126 | } |
127 | |
7ea33e5b |
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 | |
1e12d1ff |
133 | if ( sqgetGlobalVar('chapter', $temp, SQ_GET) ) { |
134 | $chapter = (int) $temp; |
135 | } elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER) ) { |
136 | $ref = strtolower($temp); |
7ea33e5b |
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 | } |
cd08020d |
147 | } |
7ea33e5b |
148 | } |
149 | |
150 | if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) { |
81c064ac |
151 | echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' ) . |
7ea33e5b |
152 | html_tag( 'tr' ) . |
153 | html_tag( 'td' ) . |
154 | '<b><center>' . _("Table of Contents") . '</center></b><br>'; |
7ea33e5b |
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 | } |
6575fe45 |
163 | do_hook('help_chapter'); |
7ea33e5b |
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>'; |
0120b304 |
179 | } else { |
7ea33e5b |
180 | echo ' | <a href="../src/help.php?chapter=' . ($chapter+1) |
181 | . '">' . _("Next") . '</a>'; |
cd08020d |
182 | } |
7ea33e5b |
183 | echo '</center></small><br>'; |
cd08020d |
184 | |
7ea33e5b |
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]; |
cd08020d |
190 | } else { |
7ea33e5b |
191 | echo html_tag( 'p', $help_info[2], 'left' ); |
192 | } |
cd08020d |
193 | |
7ea33e5b |
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]; |
cd08020d |
201 | } |
7ea33e5b |
202 | |
203 | echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>'; |
cd08020d |
204 | } |
7ea33e5b |
205 | |
cd08020d |
206 | do_hook('help_bottom'); |
3530b83b |
207 | |
208 | echo html_tag( 'tr', |
209 | html_tag( 'td', ' ', 'left', $color[0] ) |
210 | ). |
dcc1cc82 |
211 | '</table></body></html>'; |
212 | ?> |