Added a counter pref and a fix for the imapid
[squirrelmail.git] / src / help.php
1 <?php
2
3 /**
4 ** help.php
5 **
6 ** Copyright (c) 1999-2001 The SquirrelMail development team
7 ** Licensed under the GNU GPL. For full terms see the file COPYING.
8 **
9 ** Displays help for the user
10 **
11 ** $Id$
12 **/
13
14 require_once('../src/validate.php');
15 require_once('../functions/display_messages.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/array.php');
18
19
20 displayPageHeader($color, 'None' );
21
22 $helpdir[0] = 'basic.hlp';
23 $helpdir[1] = 'main_folder.hlp';
24 $helpdir[2] = 'read_mail.hlp';
25 $helpdir[3] = 'compose.hlp';
26 $helpdir[4] = 'addresses.hlp';
27 $helpdir[5] = 'folders.hlp';
28 $helpdir[6] = 'options.hlp';
29 $helpdir[7] = 'search.hlp';
30 $helpdir[8] = 'FAQ.hlp';
31
32 /****************[ HELP FUNCTIONS ]********************/
33 // parses through and gets the information from the different documents.
34 // this returns one section at a time. You must keep track of the position
35 // so that it knows where to start to look for the next section.
36
37 function get_info($doc, $pos) {
38 for ($n=$pos; $n < count($doc); $n++) {
39 if (trim(strtolower($doc[$n])) == "<chapter>" || trim(strtolower($doc[$n])) == "<section>") {
40 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</section>") && (trim(strtolower($doc[$n])) != "</chapter>"); $n++) {
41 if (trim(strtolower($doc[$n])) == "<title>") {
42 $n++;
43 $ary[0] = trim($doc[$n]);
44 }
45 if (trim(strtolower($doc[$n])) == "<description>") {
46 $ary[1] = "";
47 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</description>"); $n++) {
48 $ary[1] .= $doc[$n];
49 }
50 }
51 if (trim(strtolower($doc[$n])) == "<summary>") {
52 $ary[2] = "";
53 for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) {
54 $ary[2] .= $doc[$n];
55 }
56 }
57 }
58 if (isset($ary)) {
59 $ary[3] = $n;
60 return $ary;
61 } else {
62 $ary[0] = "ERROR: Help files are not in the right format!";
63 $ary[1] = "ERROR: Help files are not in the right format!";
64 $ary[2] = "ERROR: Help files are not in the right format!";
65 return $ary;
66 }
67 }
68 }
69 $ary[0] = "ERROR: Help files are not in the right format!";
70 $ary[1] = "ERROR: Help files are not in the right format!";
71 return $ary;
72 }
73
74 /**************[ END HELP FUNCTIONS ]******************/
75
76 ?>
77
78 <br>
79 <table width=95% align=center cellpadding=2 cellspacing=2 border=0>
80 <tr><td bgcolor="<?php echo $color[0] ?>">
81 <center><b><?php echo _("Help") ?></b></center>
82 </td></tr></table>
83
84 <?php do_hook("help_top") ?>
85
86 <table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><td>
87 <?php
88 if ($HTTP_REFERER) {
89 $ref = strtolower($HTTP_REFERER);
90 if (strpos($ref, "src/compose"))
91 $context = "compose";
92 else if (strpos($ref, "src/addr"))
93 $context = "address";
94 else if (strpos($ref, "src/folders"))
95 $context = "folders";
96 else if (strpos($ref, "src/options"))
97 $context = "options";
98 else if (strpos($ref, "src/right_main"))
99 $context = "index";
100 else if (strpos($ref, "src/read_body"))
101 $context = "read";
102 else if (strpos($ref, "src/search"))
103 $context = "search";
104 }
105
106 if (!$squirrelmail_language)
107 $squirrelmail_language = "en";
108
109 if (file_exists("../help/$squirrelmail_language")) {
110 $help_exists = true;
111 $user_language = $squirrelmail_language;
112 } else if (file_exists("../help/en")) {
113 $help_exists = true;
114 echo "<center><font color=\"$color[2]\">";
115 printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
116 echo "</font></center><br>";
117 $user_language = "en";
118 } else {
119 $help_exists = false;
120 echo "<br><center><font color=\"$color[2]\">";
121 echo _("Some or all of the help documents are not present!");
122 echo "</font></center>";
123 echo "</td></tr></table>";
124 exit;
125 }
126
127 if ($help_exists) {
128 if (! isset($context))
129 $context = '';
130 if ($context == "compose")
131 $chapter = 4;
132 else if ($context == "address")
133 $chapter = 5;
134 else if ($context == "folders")
135 $chapter = 6;
136 else if ($context == "options")
137 $chapter = 7;
138 else if ($context == "index")
139 $chapter = 2;
140 else if ($context == "read")
141 $chapter = 3;
142 else if ($context == "search")
143 $chapter = 8;
144
145 if (!isset($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 do_hook("help_chapter");
149 echo "<ol>\n";
150 for ($i=0; $i < count($helpdir); $i++) {
151 $doc = file("../help/$user_language/$helpdir[$i]");
152 $help_info = get_info($doc, 0);
153 echo "<li><a href=\"../src/help.php?chapter=". ($i+1) ."\">$help_info[0]</a>\n";
154 echo "<ul>$help_info[2]</ul>";
155 }
156 echo "</ol>\n";
157 echo "</td></tr></table>\n";
158 } else {
159 $doc = file("../help/$user_language/".$helpdir[$chapter-1]);
160 $help_info = get_info($doc, 0);
161
162 echo "<small><center>";
163
164 if ($chapter <= 1) echo "<font color=\"$color[9]\">"._("Previous")."</font> | ";
165 else echo "<a href=\"../src/help.php?chapter=".($chapter-1)."\">"._("Previous")."</a> | ";
166 echo "<a href=\"../src/help.php\">"._("Table of Contents")."</a>";
167 if ($chapter >= count($helpdir)) echo " | <font color=\"$color[9]\">"._("Next")."</font>";
168 else echo " | <a href=\"../src/help.php?chapter=".($chapter+1)."\">"._("Next")."</a>\n";
169 echo "</center></small><br>\n";
170
171 echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n";
172 if (isset($help_info[1]))
173 echo "$help_info[1]\n";
174 else
175 echo "<p>$help_info[2]</p>\n";
176
177 $section = 0;
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>\n";
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>