- did decodeHeader on to_ary and cc_ary
[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="<? echo $color[0] ?>">
91 <center><b><? echo _("Help") ?></b></center>
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";
111 }
112
113 if (file_exists("../help/$squirrelmail_language")) {
114 $help_exists = true;
115 } else if (file_exists("../help/en")) {
116 $help_exists = true;
117 echo "<center><font color=\"$color[2]\">";
118 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
119 echo "</font></center><br>";
120 $user_language = "en";
121 } else {
122 $help_exists = false;
123 echo "<br><center><font color=\"$color[2]\">";
124 echo _("Some or all of the help documents are not present!");
125 echo "</font></center>";
126 }
127
128 if ($help_exists) {
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;
141
142 if (!$chapter) {
143 echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n";
144 echo "<b><center>" . _("Table of Contents") . "</center></b><br>";
145 echo "<ol>\n";
146 for ($i=0; $i < count($helpdir); $i++) {
147 $doc = file("../help/$user_language/$helpdir[$i]");
148 $help_info = get_info($doc, 0);
149 echo "<li><a href=\"../src/help.php?chapter=". ($i+1) ."\">$help_info[0]</a>\n";
150 echo "<ul>$help_info[2]</ul>";
151 }
152 echo "</ol>\n";
153 echo "</td></tr></table>\n";
154 } else {
155 $doc = file("../help/$user_language/".$helpdir[$chapter-1]);
156 $help_info = get_info($doc, 0);
157
158 echo "<small><center>";
159
160 if ($chapter <= 1) echo "<font color=\"$color[9]\">Previous</font> | ";
161 else echo "<a href=\"../src/help.php?chapter=".($chapter-1)."\">Previous</a> | ";
162 echo "<a href=\"../src/help.php\">Table of Contents</a>";
163 if ($chapter >= count($helpdir)) echo " | <font color=\"$color[9]\">Next</font>";
164 else echo " | <a href=\"../src/help.php?chapter=".($chapter+1)."\">Next</a>";
165 echo "</center></small><br>\n";
166
167 echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n";
168 if ($help_info[1])
169 echo "$help_info[1]";
170 else
171 echo "<p>$help_info[2]</p>";
172
173 for ($n = $help_info[3]; $n < count($doc); $n++) {
174 $section++;
175 $help_info = get_info($doc, $n);
176 echo "<b>$chapter.$section - $help_info[0]</b>";
177 echo "<ul>";
178 echo "$help_info[1]";
179 echo "</ul>";
180 $n = $help_info[3];
181 }
182
183 echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>";
184 }
185 }
186 ?>
187 <tr><td bgcolor="<? echo $color[0] ?>">&nbsp;</td></tr></table>
188 <td></tr></table>
189 </body></html>