dbc577b690df6d32b4585584fa69f04b82b6a861
[squirrelmail.git] / src / help.php
1 <?php
2 /**
3 ** help.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** Displays help for the user
9 **
10 **/
11
12 session_start();
13
14 if (!isset($config_php))
15 include("../config/config.php");
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
31 include("../src/load_prefs.php");
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] = "search.hlp";
43 $helpdir[8] = "FAQ.hlp";
44
45 /****************[ HELP FUNCTIONS ]********************/
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
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;
83 }
84
85 /**************[ END HELP FUNCTIONS ]******************/
86
87 ?>
88
89 <br>
90 <table width=95% align=center cellpadding=2 cellspacing=2 border=0>
91 <tr><td bgcolor="<?php echo $color[0] ?>">
92 <center><b><?php echo _("Help") ?></b></center>
93 </td></tr></table>
94
95 <?php do_hook("help_top") ?>
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";
113 else if (strpos($ref, "src/search"))
114 $context = "search";
115 }
116
117 if (!$squirrelmail_language)
118 $squirrelmail_language = "en";
119
120 if (file_exists("../help/$squirrelmail_language")) {
121 $help_exists = true;
122 $user_language = $squirrelmail_language;
123 } else if (file_exists("../help/en")) {
124 $help_exists = true;
125 echo "<center><font color=\"$color[2]\">";
126 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
127 echo "</font></center><br>";
128 $user_language = "en";
129 } else {
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>";
134 echo "</td></tr></table>";
135 exit;
136 }
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;
151 else if ($context == "search")
152 $chapter = 8;
153
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>";
157 do_hook("help_chapter");
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
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";
178 echo "</center></small><br>\n";
179
180 echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n";
181 if ($help_info[1])
182 echo "$help_info[1]\n";
183 else
184 echo "<p>$help_info[2]</p>\n";
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
196 echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>\n";
197 }
198 }
199 do_hook("help_bottom");
200 ?>
201 <tr><td bgcolor="<?php echo $color[0] ?>">&nbsp;</td></tr></table>
202 <td></tr></table>
203 </body></html>