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