* To reduce on errors, I moved the includes for config.php and strings.php
[squirrelmail.git] / src / help.php
CommitLineData
e222c290 1<?php
ef870322 2 /**
390372b4 3 ** help.php
ef870322 4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
390372b4 8 ** Displays help for the user
ef870322 9 **
245a6892 10 ** $Id$
ef870322 11 **/
e222c290 12
f740c049 13 include('../src/validate.php');
f740c049 14 include("../functions/page_header.php");
15 include("../functions/display_messages.php");
16 include("../functions/imap.php");
17 include("../functions/array.php");
f740c049 18 include("../src/load_prefs.php");
390372b4 19
390372b4 20
390372b4 21 displayPageHeader($color, "None");
390372b4 22
23 $helpdir[0] = "basic.hlp";
24 $helpdir[1] = "main_folder.hlp";
25 $helpdir[2] = "read_mail.hlp";
26 $helpdir[3] = "compose.hlp";
27 $helpdir[4] = "addresses.hlp";
28 $helpdir[5] = "folders.hlp";
29 $helpdir[6] = "options.hlp";
d7d3c4d4 30 $helpdir[7] = "search.hlp";
31 $helpdir[8] = "FAQ.hlp";
390372b4 32
33 /****************[ HELP FUNCTIONS ]********************/
99fa2b21 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
390372b4 38 function get_info($doc, $pos) {
39 for ($n=$pos; $n < count($doc); $n++) {
40 if (trim(strtolower($doc[$n])) == "<chapter>" || trim(strtolower($doc[$n])) == "<section>") {
41 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</section>") && (trim(strtolower($doc[$n])) != "</chapter>"); $n++) {
42 if (trim(strtolower($doc[$n])) == "<title>") {
43 $n++;
44 $ary[0] = trim($doc[$n]);
45 }
46 if (trim(strtolower($doc[$n])) == "<description>") {
1863670d 47 $ary[1] = "";
390372b4 48 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</description>"); $n++) {
49 $ary[1] .= $doc[$n];
50 }
51 }
52 if (trim(strtolower($doc[$n])) == "<summary>") {
1863670d 53 $ary[2] = "";
390372b4 54 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) {
55 $ary[2] .= $doc[$n];
56 }
57 }
58 }
1863670d 59 if (isset($ary)) {
390372b4 60 $ary[3] = $n;
61 return $ary;
62 } else {
63 $ary[0] = "ERROR: Help files are not in the right format!";
64 $ary[1] = "ERROR: Help files are not in the right format!";
65 $ary[2] = "ERROR: Help files are not in the right format!";
66 return $ary;
67 }
68 }
69 }
70 $ary[0] = "ERROR: Help files are not in the right format!";
71 $ary[1] = "ERROR: Help files are not in the right format!";
72 return $ary;
e222c290 73 }
390372b4 74
75 /**************[ END HELP FUNCTIONS ]******************/
76
77?>
78
79<br>
80<table width=95% align=center cellpadding=2 cellspacing=2 border=0>
8442ac08 81<tr><td bgcolor="<?php echo $color[0] ?>">
82 <center><b><?php echo _("Help") ?></b></center>
390372b4 83</td></tr></table>
84
d7d3c4d4 85<?php do_hook("help_top") ?>
390372b4 86
87<table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><td>
88<?php
89 if ($HTTP_REFERER) {
90 $ref = strtolower($HTTP_REFERER);
91 if (strpos($ref, "src/compose"))
92 $context = "compose";
93 else if (strpos($ref, "src/addr"))
94 $context = "address";
95 else if (strpos($ref, "src/folders"))
96 $context = "folders";
97 else if (strpos($ref, "src/options"))
98 $context = "options";
99 else if (strpos($ref, "src/right_main"))
100 $context = "index";
101 else if (strpos($ref, "src/read_body"))
102 $context = "read";
d7d3c4d4 103 else if (strpos($ref, "src/search"))
104 $context = "search";
e222c290 105 }
390372b4 106
0493a8d9 107 if (!$squirrelmail_language)
108 $squirrelmail_language = "en";
109
99fa2b21 110 if (file_exists("../help/$squirrelmail_language")) {
390372b4 111 $help_exists = true;
61afa89e 112 $user_language = $squirrelmail_language;
390372b4 113 } else if (file_exists("../help/en")) {
114 $help_exists = true;
115 echo "<center><font color=\"$color[2]\">";
99fa2b21 116 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
390372b4 117 echo "</font></center><br>";
118 $user_language = "en";
f7942326 119 } else {
390372b4 120 $help_exists = false;
121 echo "<br><center><font color=\"$color[2]\">";
122 echo _("Some or all of the help documents are not present!");
123 echo "</font></center>";
61afa89e 124 echo "</td></tr></table>";
125 exit;
f7942326 126 }
390372b4 127
128 if ($help_exists) {
1863670d 129 if (! isset($context))
130 $context = '';
390372b4 131 if ($context == "compose")
132 $chapter = 4;
133 else if ($context == "address")
134 $chapter = 5;
135 else if ($context == "folders")
136 $chapter = 6;
137 else if ($context == "options")
138 $chapter = 7;
139 else if ($context == "index")
140 $chapter = 2;
141 else if ($context == "read")
142 $chapter = 3;
d7d3c4d4 143 else if ($context == "search")
144 $chapter = 8;
f7942326 145
1863670d 146 if (!isset($chapter)) {
390372b4 147 echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n";
148 echo "<b><center>" . _("Table of Contents") . "</center></b><br>";
06ad27a2 149 do_hook("help_chapter");
390372b4 150 echo "<ol>\n";
151 for ($i=0; $i < count($helpdir); $i++) {
152 $doc = file("../help/$user_language/$helpdir[$i]");
153 $help_info = get_info($doc, 0);
154 echo "<li><a href=\"../src/help.php?chapter=". ($i+1) ."\">$help_info[0]</a>\n";
155 echo "<ul>$help_info[2]</ul>";
156 }
157 echo "</ol>\n";
158 echo "</td></tr></table>\n";
159 } else {
160 $doc = file("../help/$user_language/".$helpdir[$chapter-1]);
161 $help_info = get_info($doc, 0);
162
163 echo "<small><center>";
164
32f4685b 165 if ($chapter <= 1) echo "<font color=\"$color[9]\">"._("Previous")."</font> | ";
166 else echo "<a href=\"../src/help.php?chapter=".($chapter-1)."\">"._("Previous")."</a> | ";
167 echo "<a href=\"../src/help.php\">"._("Table of Contents")."</a>";
168 if ($chapter >= count($helpdir)) echo " | <font color=\"$color[9]\">"._("Next")."</font>";
169 else echo " | <a href=\"../src/help.php?chapter=".($chapter+1)."\">"._("Next")."</a>\n";
390372b4 170 echo "</center></small><br>\n";
e222c290 171
390372b4 172 echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n";
1863670d 173 if (isset($help_info[1]))
04632dbc 174 echo "$help_info[1]\n";
390372b4 175 else
04632dbc 176 echo "<p>$help_info[2]</p>\n";
390372b4 177
1863670d 178 $section = 0;
390372b4 179 for ($n = $help_info[3]; $n < count($doc); $n++) {
180 $section++;
181 $help_info = get_info($doc, $n);
182 echo "<b>$chapter.$section - $help_info[0]</b>";
183 echo "<ul>";
184 echo "$help_info[1]";
185 echo "</ul>";
186 $n = $help_info[3];
187 }
188
04632dbc 189 echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>\n";
390372b4 190 }
191 }
06ad27a2 192 do_hook("help_bottom");
e222c290 193?>
8442ac08 194<tr><td bgcolor="<?php echo $color[0] ?>">&nbsp;</td></tr></table>
390372b4 195<td></tr></table>
196</body></html>