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