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