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