This *may* fix a problem with Outlook brain damage, reported by myself
[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
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
30require_once('../src/validate.php');
31require_once('../functions/display_messages.php');
32require_once('../functions/imap.php');
33require_once('../functions/array.php');
390372b4 34
390372b4 35
2d367c68 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';
390372b4 47
48 /****************[ HELP FUNCTIONS ]********************/
2d367c68 49 // parses through and gets the information from the different documents.
99fa2b21 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
390372b4 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>") {
2d367c68 62 $ary[1] = "";
390372b4 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>") {
2d367c68 68 $ary[2] = "";
390372b4 69 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) {
70 $ary[2] .= $doc[$n];
71 }
72 }
2d367c68 73 }
1863670d 74 if (isset($ary)) {
390372b4 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;
2d367c68 82 }
390372b4 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;
e222c290 88 }
2d367c68 89
390372b4 90 /**************[ END HELP FUNCTIONS ]******************/
91
92?>
93
94<br>
95<table width=95% align=center cellpadding=2 cellspacing=2 border=0>
8442ac08 96<tr><td bgcolor="<?php echo $color[0] ?>">
97 <center><b><?php echo _("Help") ?></b></center>
390372b4 98</td></tr></table>
99
d7d3c4d4 100<?php do_hook("help_top") ?>
390372b4 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"))
2d367c68 107 $context = "compose";
390372b4 108 else if (strpos($ref, "src/addr"))
2d367c68 109 $context = "address";
390372b4 110 else if (strpos($ref, "src/folders"))
2d367c68 111 $context = "folders";
390372b4 112 else if (strpos($ref, "src/options"))
2d367c68 113 $context = "options";
390372b4 114 else if (strpos($ref, "src/right_main"))
2d367c68 115 $context = "index";
390372b4 116 else if (strpos($ref, "src/read_body"))
2d367c68 117 $context = "read";
d7d3c4d4 118 else if (strpos($ref, "src/search"))
2d367c68 119 $context = "search";
e222c290 120 }
2d367c68 121
0493a8d9 122 if (!$squirrelmail_language)
123 $squirrelmail_language = "en";
522419be 124 /**
125 * This harebrained solution is here because it produces the
126 * smallest patchfile.
127 * The real solution would be to either:
128 * a) move all locales into full-name locale names, like they
129 * really should be according to the ISO docs (e.g. en -> en_US,
130 * es -> es_ES, ru -> ru_RU), since it's standard to have a language
131 * name + undescore + country name.
132 * b) Provide a $languages['ru_RU']['HELPALIAS'] = 'ru';
133 *
134 * Konstantin Riabitsev
135 */
136 global $languages;
137 while (list($key, $val) = each($languages)){
138 if ($val['ALIAS'] == $squirrelmail_language){
139 $squirrelmail_language = $key;
140 break;
141 }
142 }
143
0493a8d9 144
99fa2b21 145 if (file_exists("../help/$squirrelmail_language")) {
390372b4 146 $help_exists = true;
61afa89e 147 $user_language = $squirrelmail_language;
390372b4 148 } else if (file_exists("../help/en")) {
149 $help_exists = true;
150 echo "<center><font color=\"$color[2]\">";
99fa2b21 151 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
390372b4 152 echo "</font></center><br>";
153 $user_language = "en";
f7942326 154 } else {
390372b4 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>";
61afa89e 159 echo "</td></tr></table>";
160 exit;
f7942326 161 }
2d367c68 162
390372b4 163 if ($help_exists) {
1863670d 164 if (! isset($context))
165 $context = '';
390372b4 166 if ($context == "compose")
167 $chapter = 4;
168 else if ($context == "address")
169 $chapter = 5;
170 else if ($context == "folders")
171 $chapter = 6;
172 else if ($context == "options")
173 $chapter = 7;
174 else if ($context == "index")
175 $chapter = 2;
176 else if ($context == "read")
177 $chapter = 3;
d7d3c4d4 178 else if ($context == "search")
179 $chapter = 8;
f7942326 180
1863670d 181 if (!isset($chapter)) {
390372b4 182 echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n";
183 echo "<b><center>" . _("Table of Contents") . "</center></b><br>";
06ad27a2 184 do_hook("help_chapter");
390372b4 185 echo "<ol>\n";
186 for ($i=0; $i < count($helpdir); $i++) {
187 $doc = file("../help/$user_language/$helpdir[$i]");
188 $help_info = get_info($doc, 0);
189 echo "<li><a href=\"../src/help.php?chapter=". ($i+1) ."\">$help_info[0]</a>\n";
190 echo "<ul>$help_info[2]</ul>";
191 }
192 echo "</ol>\n";
193 echo "</td></tr></table>\n";
194 } else {
195 $doc = file("../help/$user_language/".$helpdir[$chapter-1]);
196 $help_info = get_info($doc, 0);
197
198 echo "<small><center>";
199
32f4685b 200 if ($chapter <= 1) echo "<font color=\"$color[9]\">"._("Previous")."</font> | ";
201 else echo "<a href=\"../src/help.php?chapter=".($chapter-1)."\">"._("Previous")."</a> | ";
202 echo "<a href=\"../src/help.php\">"._("Table of Contents")."</a>";
203 if ($chapter >= count($helpdir)) echo " | <font color=\"$color[9]\">"._("Next")."</font>";
204 else echo " | <a href=\"../src/help.php?chapter=".($chapter+1)."\">"._("Next")."</a>\n";
390372b4 205 echo "</center></small><br>\n";
e222c290 206
390372b4 207 echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n";
1863670d 208 if (isset($help_info[1]))
04632dbc 209 echo "$help_info[1]\n";
2d367c68 210 else
04632dbc 211 echo "<p>$help_info[2]</p>\n";
390372b4 212
1863670d 213 $section = 0;
390372b4 214 for ($n = $help_info[3]; $n < count($doc); $n++) {
215 $section++;
216 $help_info = get_info($doc, $n);
217 echo "<b>$chapter.$section - $help_info[0]</b>";
218 echo "<ul>";
219 echo "$help_info[1]";
220 echo "</ul>";
221 $n = $help_info[3];
222 }
223
04632dbc 224 echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>\n";
390372b4 225 }
226 }
2d367c68 227 do_hook("help_bottom");
e222c290 228?>
8442ac08 229<tr><td bgcolor="<?php echo $color[0] ?>">&nbsp;</td></tr></table>
390372b4 230<td></tr></table>
522419be 231</body></html>