Workaround for the "catalan" bug. This leaves blank language
[squirrelmail.git] / src / help.php
1 <?php
2
3 /**
4 * help.php
5 *
6 * Copyright (c) 1999-2001 The Squirrelmail Development Team
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
14 /*****************************************************************/
15 /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
16 /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
17 /*** + Base level indent should begin at left margin, as ***/
18 /*** the require_once below looks. ***/
19 /*** + All identation should consist of four space blocks ***/
20 /*** + Tab characters are evil. ***/
21 /*** + all comments should use "slash-star ... star-slash" ***/
22 /*** style -- no pound characters, no slash-slash style ***/
23 /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
24 /*** ALWAYS USE { AND } CHARACTERS!!! ***/
25 /*** + Please use ' instead of ", when possible. Note " ***/
26 /*** should always be used in _( ) function calls. ***/
27 /*** Thank you for your help making the SM code more readable. ***/
28 /*****************************************************************/
29
30 require_once('../src/validate.php');
31 require_once('../functions/display_messages.php');
32 require_once('../functions/imap.php');
33 require_once('../functions/array.php');
34
35
36 displayPageHeader($color, 'None' );
37
38 $helpdir[0] = 'basic.hlp';
39 $helpdir[1] = 'main_folder.hlp';
40 $helpdir[2] = 'read_mail.hlp';
41 $helpdir[3] = 'compose.hlp';
42 $helpdir[4] = 'addresses.hlp';
43 $helpdir[5] = 'folders.hlp';
44 $helpdir[6] = 'options.hlp';
45 $helpdir[7] = 'search.hlp';
46 $helpdir[8] = 'FAQ.hlp';
47
48 /****************[ HELP FUNCTIONS ]********************/
49 // parses through and gets the information from the different documents.
50 // this returns one section at a time. You must keep track of the position
51 // so that it knows where to start to look for the next section.
52
53 function get_info($doc, $pos) {
54 for ($n=$pos; $n < count($doc); $n++) {
55 if (trim(strtolower($doc[$n])) == "<chapter>" || trim(strtolower($doc[$n])) == "<section>") {
56 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</section>") && (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] = "";
63 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</description>"); $n++) {
64 $ary[1] .= $doc[$n];
65 }
66 }
67 if (trim(strtolower($doc[$n])) == "<summary>") {
68 $ary[2] = "";
69 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) {
70 $ary[2] .= $doc[$n];
71 }
72 }
73 }
74 if (isset($ary)) {
75 $ary[3] = $n;
76 return $ary;
77 } else {
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 $ary[2] = "ERROR: Help files are not in the right format!";
81 return $ary;
82 }
83 }
84 }
85 $ary[0] = "ERROR: Help files are not in the right format!";
86 $ary[1] = "ERROR: Help files are not in the right format!";
87 return $ary;
88 }
89
90 /**************[ END HELP FUNCTIONS ]******************/
91
92 ?>
93
94 <br>
95 <table width=95% align=center cellpadding=2 cellspacing=2 border=0>
96 <tr><td bgcolor="<?php echo $color[0] ?>">
97 <center><b><?php echo _("Help") ?></b></center>
98 </td></tr></table>
99
100 <?php do_hook("help_top") ?>
101
102 <table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><td>
103 <?php
104 if ($HTTP_REFERER) {
105 $ref = strtolower($HTTP_REFERER);
106 if (strpos($ref, "src/compose"))
107 $context = "compose";
108 else if (strpos($ref, "src/addr"))
109 $context = "address";
110 else if (strpos($ref, "src/folders"))
111 $context = "folders";
112 else if (strpos($ref, "src/options"))
113 $context = "options";
114 else if (strpos($ref, "src/right_main"))
115 $context = "index";
116 else if (strpos($ref, "src/read_body"))
117 $context = "read";
118 else if (strpos($ref, "src/search"))
119 $context = "search";
120 }
121
122 if (!$squirrelmail_language)
123 $squirrelmail_language = "en";
124
125 if (file_exists("../help/$squirrelmail_language")) {
126 $help_exists = true;
127 $user_language = $squirrelmail_language;
128 } else if (file_exists("../help/en")) {
129 $help_exists = true;
130 echo "<center><font color=\"$color[2]\">";
131 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
132 echo "</font></center><br>";
133 $user_language = "en";
134 } else {
135 $help_exists = false;
136 echo "<br><center><font color=\"$color[2]\">";
137 echo _("Some or all of the help documents are not present!");
138 echo "</font></center>";
139 echo "</td></tr></table>";
140 exit;
141 }
142
143 if ($help_exists) {
144 if (! isset($context))
145 $context = '';
146 if ($context == "compose")
147 $chapter = 4;
148 else if ($context == "address")
149 $chapter = 5;
150 else if ($context == "folders")
151 $chapter = 6;
152 else if ($context == "options")
153 $chapter = 7;
154 else if ($context == "index")
155 $chapter = 2;
156 else if ($context == "read")
157 $chapter = 3;
158 else if ($context == "search")
159 $chapter = 8;
160
161 if (!isset($chapter)) {
162 echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n";
163 echo "<b><center>" . _("Table of Contents") . "</center></b><br>";
164 do_hook("help_chapter");
165 echo "<ol>\n";
166 for ($i=0; $i < count($helpdir); $i++) {
167 $doc = file("../help/$user_language/$helpdir[$i]");
168 $help_info = get_info($doc, 0);
169 echo "<li><a href=\"../src/help.php?chapter=". ($i+1) ."\">$help_info[0]</a>\n";
170 echo "<ul>$help_info[2]</ul>";
171 }
172 echo "</ol>\n";
173 echo "</td></tr></table>\n";
174 } else {
175 $doc = file("../help/$user_language/".$helpdir[$chapter-1]);
176 $help_info = get_info($doc, 0);
177
178 echo "<small><center>";
179
180 if ($chapter <= 1) echo "<font color=\"$color[9]\">"._("Previous")."</font> | ";
181 else echo "<a href=\"../src/help.php?chapter=".($chapter-1)."\">"._("Previous")."</a> | ";
182 echo "<a href=\"../src/help.php\">"._("Table of Contents")."</a>";
183 if ($chapter >= count($helpdir)) echo " | <font color=\"$color[9]\">"._("Next")."</font>";
184 else echo " | <a href=\"../src/help.php?chapter=".($chapter+1)."\">"._("Next")."</a>\n";
185 echo "</center></small><br>\n";
186
187 echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n";
188 if (isset($help_info[1]))
189 echo "$help_info[1]\n";
190 else
191 echo "<p>$help_info[2]</p>\n";
192
193 $section = 0;
194 for ($n = $help_info[3]; $n < count($doc); $n++) {
195 $section++;
196 $help_info = get_info($doc, $n);
197 echo "<b>$chapter.$section - $help_info[0]</b>";
198 echo "<ul>";
199 echo "$help_info[1]";
200 echo "</ul>";
201 $n = $help_info[3];
202 }
203
204 echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>\n";
205 }
206 }
207 do_hook("help_bottom");
208 ?>
209 <tr><td bgcolor="<?php echo $color[0] ?>">&nbsp;</td></tr></table>
210 <td></tr></table>
211 </body></html>