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 | * |
30967a1e |
11 | * @version $Id$ |
8f6f9ba5 |
12 | * @package squirrelmail |
35586184 |
13 | */ |
14 | |
30967a1e |
15 | /** |
16 | * Path for SquirrelMail required files. |
17 | * @ignore |
18 | */ |
86725763 |
19 | define('SM_PATH','../'); |
20 | |
21 | /* SquirrelMail required files. */ |
08185f2a |
22 | require_once(SM_PATH . 'include/validate.php'); |
8650e9e1 |
23 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
24 | require_once(SM_PATH . 'functions/display_messages.php'); |
390372b4 |
25 | |
cd08020d |
26 | displayPageHeader($color, 'None' ); |
27 | |
28 | $helpdir[0] = 'basic.hlp'; |
29 | $helpdir[1] = 'main_folder.hlp'; |
30 | $helpdir[2] = 'read_mail.hlp'; |
31 | $helpdir[3] = 'compose.hlp'; |
32 | $helpdir[4] = 'addresses.hlp'; |
33 | $helpdir[5] = 'folders.hlp'; |
34 | $helpdir[6] = 'options.hlp'; |
35 | $helpdir[7] = 'search.hlp'; |
36 | $helpdir[8] = 'FAQ.hlp'; |
37 | |
38 | /****************[ HELP FUNCTIONS ]********************/ |
390372b4 |
39 | |
cd08020d |
40 | /** |
41 | * parses through and gets the information from the different documents. |
42 | * this returns one section at a time. You must keep track of the position |
43 | * so that it knows where to start to look for the next section. |
44 | */ |
45 | |
46 | function get_info($doc, $pos) { |
143c7a82 |
47 | $ary = array(0,0,0); |
7ea33e5b |
48 | |
49 | $cntdoc = count($doc); |
50 | |
51 | for ($n=$pos; $n < $cntdoc; $n++) { |
cd08020d |
52 | if (trim(strtolower($doc[$n])) == '<chapter>' |
53 | || trim(strtolower($doc[$n])) == '<section>') { |
7ea33e5b |
54 | for ($n++; $n < $cntdoc |
cd08020d |
55 | && (trim(strtolower($doc[$n])) != '</section>') |
56 | && (trim(strtolower($doc[$n])) != '</chapter>'); $n++) { |
57 | if (trim(strtolower($doc[$n])) == '<title>') { |
58 | $n++; |
59 | $ary[0] = trim($doc[$n]); |
60 | } |
61 | if (trim(strtolower($doc[$n])) == '<description>') { |
62 | $ary[1] = ''; |
7ea33e5b |
63 | for ($n++;$n < $cntdoc |
cd08020d |
64 | && (trim(strtolower($doc[$n])) != '</description>'); |
65 | $n++) { |
66 | $ary[1] .= $doc[$n]; |
67 | } |
68 | } |
69 | if (trim(strtolower($doc[$n])) == '<summary>') { |
70 | $ary[2] = ''; |
7ea33e5b |
71 | for ($n++; $n < $cntdoc |
cd08020d |
72 | && (trim(strtolower($doc[$n])) != '</summary>'); |
73 | $n++) { |
74 | $ary[2] .= $doc[$n]; |
75 | } |
76 | } |
2d367c68 |
77 | } |
1863670d |
78 | if (isset($ary)) { |
cd08020d |
79 | $ary[3] = $n; |
390372b4 |
80 | } else { |
0120b304 |
81 | $ary[0] = _("ERROR: Help files are not in the right format!"); |
82 | $ary[1] = $ary[0]; |
83 | $ary[2] = $ary[0]; |
2d367c68 |
84 | } |
0120b304 |
85 | return( $ary ); |
143c7a82 |
86 | } else if (!trim(strtolower($doc[$n]))) { |
87 | $ary[0] = ''; |
88 | $ary[1] = ''; |
89 | $ary[2] = ''; |
90 | $ary[3] = $n; |
91 | } |
cd08020d |
92 | } |
0120b304 |
93 | $ary[0] = _("ERROR: Help files are not in the right format!"); |
94 | $ary[1] = $ary[0]; |
143c7a82 |
95 | $ary[2] = $ary[0]; |
96 | $ary[3] = $n; |
0120b304 |
97 | return( $ary ); |
cd08020d |
98 | } |
2d367c68 |
99 | |
cd08020d |
100 | /**************[ END HELP FUNCTIONS ]******************/ |
390372b4 |
101 | |
390372b4 |
102 | |
6206f6c4 |
103 | echo html_tag( 'table', |
3530b83b |
104 | html_tag( 'tr', |
105 | html_tag( 'td','<center><b>' . _("Help") .'</b></center>', 'center', $color[0] ) |
106 | ) , |
6206f6c4 |
107 | 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' ); |
3530b83b |
108 | |
7ea33e5b |
109 | do_hook('help_top'); |
3530b83b |
110 | |
111 | echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) . |
112 | html_tag( 'tr' ) . |
113 | html_tag( 'td' ); |
114 | |
cd08020d |
115 | if (!isset($squirrelmail_language)) { |
e5916f84 |
116 | $squirrelmail_language = 'en_US'; |
cd08020d |
117 | } |
118 | |
cd08020d |
119 | if (file_exists("../help/$squirrelmail_language")) { |
cd08020d |
120 | $user_language = $squirrelmail_language; |
e5916f84 |
121 | } else if (file_exists('../help/en_US')) { |
cd08020d |
122 | echo "<center><font color=\"$color[2]\">"; |
99aaff8b |
123 | printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']); |
cd08020d |
124 | echo '</font></center><br>'; |
e5916f84 |
125 | $user_language = 'en_US'; |
cd08020d |
126 | } else { |
7ea33e5b |
127 | error_box( _("Some or all of the help documents are not present!"), $color ); |
cd08020d |
128 | exit; |
129 | } |
130 | |
7ea33e5b |
131 | |
132 | /* take the chapternumber from the GET-vars, |
133 | * else see if we can get a relevant chapter from the referer */ |
134 | $chapter = 0; |
135 | |
1e12d1ff |
136 | if ( sqgetGlobalVar('chapter', $temp, SQ_GET) ) { |
137 | $chapter = (int) $temp; |
138 | } elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER) ) { |
139 | $ref = strtolower($temp); |
7ea33e5b |
140 | |
141 | $contexts = array ( 'src/compose' => 4, 'src/addr' => 5, |
142 | 'src/folders' => 6, 'src/options' => 7, 'src/right_main' => 2, |
143 | 'src/read_body' => 3, 'src/search' => 8 ); |
144 | |
145 | foreach($contexts as $path => $chap) { |
146 | if(strpos($ref, $path)) { |
147 | $chapter = $chap; |
148 | break; |
149 | } |
cd08020d |
150 | } |
7ea33e5b |
151 | } |
152 | |
153 | if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) { |
81c064ac |
154 | echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' ) . |
7ea33e5b |
155 | html_tag( 'tr' ) . |
156 | html_tag( 'td' ) . |
157 | '<b><center>' . _("Table of Contents") . '</center></b><br>'; |
7ea33e5b |
158 | echo html_tag( 'ol' ); |
159 | for ($i=0, $cnt = count($helpdir); $i < $cnt; $i++) { |
160 | $doc = file("../help/$user_language/$helpdir[$i]"); |
161 | $help_info = get_info($doc, 0); |
162 | echo '<li><a href="../src/help.php?chapter=' . ($i+1) |
163 | . '">' . $help_info[0] . '</a>' . |
164 | html_tag( 'ul', $help_info[2] ); |
165 | } |
6575fe45 |
166 | do_hook('help_chapter'); |
7ea33e5b |
167 | echo '</ol></td></tr></table>'; |
168 | } else { |
169 | $doc = file("../help/$user_language/" . $helpdir[$chapter-1]); |
170 | $help_info = get_info($doc, 0); |
171 | echo '<small><center>'; |
172 | if ($chapter <= 1){ |
173 | echo '<font color="' . $color[9] . '">' . _("Previous") |
174 | . '</font> | '; |
175 | } else { |
176 | echo '<a href="../src/help.php?chapter=' . ($chapter-1) |
177 | . '">' . _("Previous") . '</a> | '; |
178 | } |
179 | echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>'; |
180 | if ($chapter >= count($helpdir)){ |
181 | echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>'; |
0120b304 |
182 | } else { |
7ea33e5b |
183 | echo ' | <a href="../src/help.php?chapter=' . ($chapter+1) |
184 | . '">' . _("Next") . '</a>'; |
cd08020d |
185 | } |
7ea33e5b |
186 | echo '</center></small><br>'; |
cd08020d |
187 | |
7ea33e5b |
188 | echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0] |
189 | . '</b></font><br><br>'; |
190 | |
191 | if (isset($help_info[1]) && $help_info[1]) { |
192 | echo $help_info[1]; |
cd08020d |
193 | } else { |
7ea33e5b |
194 | echo html_tag( 'p', $help_info[2], 'left' ); |
195 | } |
cd08020d |
196 | |
7ea33e5b |
197 | $section = 0; |
198 | for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++) { |
199 | $section++; |
200 | $help_info = get_info($doc, $n); |
201 | echo "<b>$chapter.$section - $help_info[0]</b>" . |
202 | html_tag( 'ul', $help_info[1] ); |
203 | $n = $help_info[3]; |
cd08020d |
204 | } |
7ea33e5b |
205 | |
206 | echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>'; |
cd08020d |
207 | } |
7ea33e5b |
208 | |
cd08020d |
209 | do_hook('help_bottom'); |
3530b83b |
210 | |
211 | echo html_tag( 'tr', |
212 | html_tag( 'td', ' ', 'left', $color[0] ) |
213 | ). |
dcc1cc82 |
214 | '</table></body></html>'; |
215 | ?> |