fixed minor bug with user_languages in help documents
[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";
42 $helpdir[7] = "FAQ.hlp";
43
44 /****************[ HELP FUNCTIONS ]********************/
99fa2b21 45 // parses through and gets the information from the different documents.
46 // this returns one section at a time. You must keep track of the position
47 // so that it knows where to start to look for the next section.
48
390372b4 49 function get_info($doc, $pos) {
50 for ($n=$pos; $n < count($doc); $n++) {
51 if (trim(strtolower($doc[$n])) == "<chapter>" || trim(strtolower($doc[$n])) == "<section>") {
52 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</section>") && (trim(strtolower($doc[$n])) != "</chapter>"); $n++) {
53 if (trim(strtolower($doc[$n])) == "<title>") {
54 $n++;
55 $ary[0] = trim($doc[$n]);
56 }
57 if (trim(strtolower($doc[$n])) == "<description>") {
58 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</description>"); $n++) {
59 $ary[1] .= $doc[$n];
60 }
61 }
62 if (trim(strtolower($doc[$n])) == "<summary>") {
63 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) {
64 $ary[2] .= $doc[$n];
65 }
66 }
67 }
68 if ($ary) {
69 $ary[3] = $n;
70 return $ary;
71 } else {
72 $ary[0] = "ERROR: Help files are not in the right format!";
73 $ary[1] = "ERROR: Help files are not in the right format!";
74 $ary[2] = "ERROR: Help files are not in the right format!";
75 return $ary;
76 }
77 }
78 }
79 $ary[0] = "ERROR: Help files are not in the right format!";
80 $ary[1] = "ERROR: Help files are not in the right format!";
81 return $ary;
e222c290 82 }
390372b4 83
84 /**************[ END HELP FUNCTIONS ]******************/
85
86?>
87
88<br>
89<table width=95% align=center cellpadding=2 cellspacing=2 border=0>
8442ac08 90<tr><td bgcolor="<?php echo $color[0] ?>">
91 <center><b><?php echo _("Help") ?></b></center>
390372b4 92</td></tr></table>
93
94
95<table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><td>
96<?php
97 if ($HTTP_REFERER) {
98 $ref = strtolower($HTTP_REFERER);
99 if (strpos($ref, "src/compose"))
100 $context = "compose";
101 else if (strpos($ref, "src/addr"))
102 $context = "address";
103 else if (strpos($ref, "src/folders"))
104 $context = "folders";
105 else if (strpos($ref, "src/options"))
106 $context = "options";
107 else if (strpos($ref, "src/right_main"))
108 $context = "index";
109 else if (strpos($ref, "src/read_body"))
110 $context = "read";
e222c290 111 }
390372b4 112
99fa2b21 113 if (file_exists("../help/$squirrelmail_language")) {
390372b4 114 $help_exists = true;
61afa89e 115 $user_language = $squirrelmail_language;
390372b4 116 } else if (file_exists("../help/en")) {
117 $help_exists = true;
118 echo "<center><font color=\"$color[2]\">";
99fa2b21 119 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
390372b4 120 echo "</font></center><br>";
121 $user_language = "en";
f7942326 122 } else {
390372b4 123 $help_exists = false;
124 echo "<br><center><font color=\"$color[2]\">";
125 echo _("Some or all of the help documents are not present!");
126 echo "</font></center>";
61afa89e 127 echo "</td></tr></table>";
128 exit;
f7942326 129 }
390372b4 130
131 if ($help_exists) {
132 if ($context == "compose")
133 $chapter = 4;
134 else if ($context == "address")
135 $chapter = 5;
136 else if ($context == "folders")
137 $chapter = 6;
138 else if ($context == "options")
139 $chapter = 7;
140 else if ($context == "index")
141 $chapter = 2;
142 else if ($context == "read")
143 $chapter = 3;
f7942326 144
390372b4 145 if (!$chapter) {
146 echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n";
147 echo "<b><center>" . _("Table of Contents") . "</center></b><br>";
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
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>";
168 echo "</center></small><br>\n";
e222c290 169
390372b4 170 echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n";
171 if ($help_info[1])
172 echo "$help_info[1]";
173 else
174 echo "<p>$help_info[2]</p>";
175
176 for ($n = $help_info[3]; $n < count($doc); $n++) {
177 $section++;
178 $help_info = get_info($doc, $n);
179 echo "<b>$chapter.$section - $help_info[0]</b>";
180 echo "<ul>";
181 echo "$help_info[1]";
182 echo "</ul>";
183 $n = $help_info[3];
184 }
185
186 echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>";
187 }
188 }
e222c290 189?>
8442ac08 190<tr><td bgcolor="<?php echo $color[0] ?>">&nbsp;</td></tr></table>
390372b4 191<td></tr></table>
192</body></html>