Moving ro to ro_RO
[squirrelmail.git] / src / help.php
CommitLineData
e222c290 1<?php
895905c0 2
35586184 3/**
4 * help.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 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
35586184 14require_once('../src/validate.php');
15require_once('../functions/display_messages.php');
16require_once('../functions/imap.php');
17require_once('../functions/array.php');
390372b4 18
cd08020d 19displayPageHeader($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
39function get_info($doc, $pos) {
40 for ($n=$pos; $n < count($doc); $n++) {
41 if (trim(strtolower($doc[$n])) == '<chapter>'
42 || trim(strtolower($doc[$n])) == '<section>') {
43 for ($n++;$n < count($doc)
44 && (trim(strtolower($doc[$n])) != '</section>')
45 && (trim(strtolower($doc[$n])) != '</chapter>'); $n++) {
46 if (trim(strtolower($doc[$n])) == '<title>') {
47 $n++;
48 $ary[0] = trim($doc[$n]);
49 }
50 if (trim(strtolower($doc[$n])) == '<description>') {
51 $ary[1] = '';
52 for ($n++;$n < count($doc)
53 && (trim(strtolower($doc[$n])) != '</description>');
54 $n++) {
55 $ary[1] .= $doc[$n];
56 }
57 }
58 if (trim(strtolower($doc[$n])) == '<summary>') {
59 $ary[2] = '';
60 for ($n++; $n < count($doc)
61 && (trim(strtolower($doc[$n])) != '</summary>');
62 $n++) {
63 $ary[2] .= $doc[$n];
64 }
65 }
2d367c68 66 }
1863670d 67 if (isset($ary)) {
cd08020d 68 $ary[3] = $n;
69 return $ary;
390372b4 70 } else {
cd08020d 71 $ary[0] = 'ERROR: Help files are not in the right format!';
72 $ary[1] = 'ERROR: Help files are not in the right format!';
73 $ary[2] = 'ERROR: Help files are not in the right format!';
74 return $ary;
2d367c68 75 }
cd08020d 76 }
77 }
78 $ary[0] = 'ERROR: Help files are not in the right format!';
79 $ary[1] = 'ERROR: Help files are not in the right format!';
80 return $ary;
81}
2d367c68 82
cd08020d 83/**************[ END HELP FUNCTIONS ]******************/
390372b4 84
85?>
86
87<br>
cd08020d 88<table width="95%" align="center" cellpadding="2" cellspacing="2" border="0">
89 <tr>
90 <td bgcolor="<?php echo $color[0] ?>">
8442ac08 91 <center><b><?php echo _("Help") ?></b></center>
cd08020d 92 </td>
93 </tr>
94</table>
390372b4 95
d7d3c4d4 96<?php do_hook("help_top") ?>
390372b4 97
cd08020d 98<table width="90%" cellpadding="0" cellspacing="10" border="0" align="center">
99<tr>
100<td>
101<?php
102if (isset($HTTP_REFERER)) {
103 $ref = strtolower($HTTP_REFERER);
104 if (strpos($ref, 'src/compose')){
105 $context = 'compose';
106 } else if (strpos($ref, 'src/addr')){
107 $context = 'address';
108 } else if (strpos($ref, 'src/folders')){
109 $context = 'folders';
110 } else if (strpos($ref, 'src/options')){
111 $context = 'options';
112 } else if (strpos($ref, 'src/right_main')){
113 $context = 'index';
114 } else if (strpos($ref, 'src/read_body')){
115 $context = 'read';
116 } else if (strpos($ref, 'src/search')){
117 $context = 'search';
118 }
119}
120
121if (!isset($squirrelmail_language)) {
122 $squirrelmail_language = 'en';
123}
124
125/**
126 * This harebrained solution is here because it produces the
127 * smallest patchfile.
128 * The real solution would be to either:
129 * a) move all locales into full-name locale names, like they
130 * really should be according to the ISO docs (e.g. en -> en_US,
131 * es -> es_ES, ru -> ru_RU), since it's standard to have a language
132 * name + undescore + country name.
133 * b) Provide a $languages['ru_RU']['HELPALIAS'] = 'ru';
134 *
135 * Konstantin Riabitsev
136 */
137global $languages;
138while (list($key, $val) = each($languages)){
139 if ($val['ALIAS'] == $squirrelmail_language){
140 $squirrelmail_language = $key;
141 break;
142 }
143}
144
145if (file_exists("../help/$squirrelmail_language")) {
146 $help_exists = true;
147 $user_language = $squirrelmail_language;
148} else if (file_exists('../help/en')) {
149 $help_exists = true;
150 echo "<center><font color=\"$color[2]\">";
151 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']);
152 echo '</font></center><br>';
153 $user_language = 'en';
154} else {
155 $help_exists = false;
156 echo "<br><center><font color=\"$color[2]\">";
157 echo _("Some or all of the help documents are not present!");
158 echo '</font></center>';
159 echo '</td></tr></table>';
160 /* this is really silly, because there may be some
161 * footers. What about them.
162 * TODO: Fix this so it's not just "exit".
163 */
164 exit;
165}
166
167if ($help_exists == true) {
168 if (!isset($context)){
169 $context = '';
170 }
171 if ($context == 'compose'){
172 $chapter = 4;
173 } else if ($context == 'address'){
174 $chapter = 5;
175 } else if ($context == 'folders'){
176 $chapter = 6;
177 } else if ($context == 'options'){
178 $chapter = 7;
179 } else if ($context == 'index'){
180 $chapter = 2;
181 } else if ($context == 'read'){
182 $chapter = 3;
183 } else if ($context == 'search'){
184 $chapter = 8;
185 }
186
187 if (!isset($chapter)) {
188 echo '<table cellpadding="0" cellspacing="0" border="0"
189 align="center"><tr><td>';
190 echo '<b><center>' . _("Table of Contents") . '</center></b><br>';
191 do_hook('help_chapter');
192 echo '<ol>';
193 for ($i=0; $i < count($helpdir); $i++) {
390372b4 194 $doc = file("../help/$user_language/$helpdir[$i]");
195 $help_info = get_info($doc, 0);
cd08020d 196 echo '<li><a href="../src/help.php?chapter=' . ($i+1)
197 . '">' . $help_info[0] . '</a>';
198 echo '<ul>' . $help_info[2] . '</ul>';
199 }
200 echo '</ol>';
201 echo '</td></tr></table>';
202 } else {
203 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
204 $help_info = get_info($doc, 0);
205 echo '<small><center>';
206 if ($chapter <= 1){
207 echo '<font color="' . $color[9] . '">' . _("Previous")
208 . '</font> | ';
209 } else {
210 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
211 . '">' . _("Previous") . '</a> | ';
212 }
213 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
214 if ($chapter >= count($helpdir)){
215 echo ' | <font color="$color[9]">' . _("Next") . '</font>';
216 } else {
217 echo ' | <a href="../src/help.php?chapter=' . ($chapter+1)
218 . '">' . _("Next") . '</a>';
219 }
220 echo '</center></small><br>';
221
222 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
223 . '</b></font><br><br>';
224 if (isset($help_info[1])){
225 echo $help_info[1];
226 } else {
227 echo '<p>' . $help_info[2] . '</p>';
228 }
229
230 $section = 0;
231 for ($n = $help_info[3]; $n < count($doc); $n++) {
390372b4 232 $section++;
233 $help_info = get_info($doc, $n);
234 echo "<b>$chapter.$section - $help_info[0]</b>";
cd08020d 235 echo '<ul>';
236 echo $help_info[1];
237 echo '</ul>';
390372b4 238 $n = $help_info[3];
cd08020d 239 }
390372b4 240
cd08020d 241 echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
242 }
243}
244do_hook('help_bottom');
e222c290 245?>
8442ac08 246<tr><td bgcolor="<?php echo $color[0] ?>">&nbsp;</td></tr></table>
390372b4 247<td></tr></table>
cd08020d 248</body></html>