e7632938a75062ce0b96fff6dbddd447c05c18ff
[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] = "FAQ.hlp";
43
44 /****************[ HELP FUNCTIONS ]********************/
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
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;
82 }
83
84 /**************[ END HELP FUNCTIONS ]******************/
85
86 ?>
87
88 <br>
89 <table width=95% align=center cellpadding=2 cellspacing=2 border=0>
90 <tr><td bgcolor="<?php echo $color[0] ?>">
91 <center><b><?php echo _("Help") ?></b></center>
92 </td></tr></table>
93
94 <? do_hook("help_top") ?>
95
96 <table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><td>
97 <?php
98 if ($HTTP_REFERER) {
99 $ref = strtolower($HTTP_REFERER);
100 if (strpos($ref, "src/compose"))
101 $context = "compose";
102 else if (strpos($ref, "src/addr"))
103 $context = "address";
104 else if (strpos($ref, "src/folders"))
105 $context = "folders";
106 else if (strpos($ref, "src/options"))
107 $context = "options";
108 else if (strpos($ref, "src/right_main"))
109 $context = "index";
110 else if (strpos($ref, "src/read_body"))
111 $context = "read";
112 }
113
114 if (file_exists("../help/$squirrelmail_language")) {
115 $help_exists = true;
116 $user_language = $squirrelmail_language;
117 } else if (file_exists("../help/en")) {
118 $help_exists = true;
119 echo "<center><font color=\"$color[2]\">";
120 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
121 echo "</font></center><br>";
122 $user_language = "en";
123 } else {
124 $help_exists = false;
125 echo "<br><center><font color=\"$color[2]\">";
126 echo _("Some or all of the help documents are not present!");
127 echo "</font></center>";
128 echo "</td></tr></table>";
129 exit;
130 }
131
132 if ($help_exists) {
133 if ($context == "compose")
134 $chapter = 4;
135 else if ($context == "address")
136 $chapter = 5;
137 else if ($context == "folders")
138 $chapter = 6;
139 else if ($context == "options")
140 $chapter = 7;
141 else if ($context == "index")
142 $chapter = 2;
143 else if ($context == "read")
144 $chapter = 3;
145
146 if (!$chapter) {
147 echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n";
148 echo "<b><center>" . _("Table of Contents") . "</center></b><br>";
149 do_hook("help_chapter");
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
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>";
170 echo "</center></small><br>\n";
171
172 echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n";
173 if ($help_info[1])
174 echo "$help_info[1]";
175 else
176 echo "<p>$help_info[2]</p>";
177
178 for ($n = $help_info[3]; $n < count($doc); $n++) {
179 $section++;
180 $help_info = get_info($doc, $n);
181 echo "<b>$chapter.$section - $help_info[0]</b>";
182 echo "<ul>";
183 echo "$help_info[1]";
184 echo "</ul>";
185 $n = $help_info[3];
186 }
187
188 echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>";
189 }
190 }
191 do_hook("help_bottom");
192 ?>
193 <tr><td bgcolor="<?php echo $color[0] ?>">&nbsp;</td></tr></table>
194 <td></tr></table>
195 </body></html>