f9d07b51aa3c28bd06a0197eccc18c5ebc200461
6 * Displays help for the user
8 * @copyright © 1999-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
15 * Include the SquirrelMail initialization file.
17 require('../include/init.php');
19 displayPageHeader($color, 'None' );
21 $helpdir[0] = 'basic.hlp';
22 $helpdir[1] = 'main_folder.hlp';
23 $helpdir[2] = 'read_mail.hlp';
24 $helpdir[3] = 'compose.hlp';
25 $helpdir[4] = 'addresses.hlp';
26 $helpdir[5] = 'folders.hlp';
27 $helpdir[6] = 'options.hlp';
28 $helpdir[7] = 'search.hlp';
29 $helpdir[8] = 'FAQ.hlp';
31 /****************[ HELP FUNCTIONS ]********************/
34 * parses through and gets the information from the different documents.
35 * this returns one section at a time. You must keep track of the position
36 * so that it knows where to start to look for the next section.
39 function get_info($doc, $pos) {
42 $cntdoc = count($doc);
44 for ($n=$pos; $n < $cntdoc; $n++
) {
45 if (trim(strtolower($doc[$n])) == '<chapter>'
46 ||
trim(strtolower($doc[$n])) == '<section>') {
47 for ($n++
; $n < $cntdoc
48 && (trim(strtolower($doc[$n])) != '</section>')
49 && (trim(strtolower($doc[$n])) != '</chapter>'); $n++
) {
50 if (trim(strtolower($doc[$n])) == '<title>') {
52 $ary[0] = trim($doc[$n]);
54 if (trim(strtolower($doc[$n])) == '<description>') {
56 for ($n++
;$n < $cntdoc
57 && (trim(strtolower($doc[$n])) != '</description>');
62 if (trim(strtolower($doc[$n])) == '<summary>') {
64 for ($n++
; $n < $cntdoc
65 && (trim(strtolower($doc[$n])) != '</summary>');
74 $ary[0] = _("ERROR: Help files are not in the right format!");
79 } else if (!trim(strtolower($doc[$n]))) {
86 $ary[0] = _("ERROR: Help files are not in the right format!");
93 /**************[ END HELP FUNCTIONS ]******************/
95 echo html_tag( 'table',
97 html_tag( 'td','<div style="text-align: center;"><b>' . _("Help") .'</b></div>', 'center', $color[0] )
99 'center', '', 'width="95%" cellpadding="1" cellspacing="2" border="0"' );
103 echo html_tag( 'table', '', 'center', '', 'width="90%" cellpadding="0" cellspacing="10" border="0"' ) .
107 if (!isset($squirrelmail_language)) {
108 $squirrelmail_language = 'en_US';
111 if (file_exists("../help/$squirrelmail_language")) {
112 $user_language = $squirrelmail_language;
113 } else if (file_exists('../help/en_US')) {
114 error_box(_("Help is not available in the selected language. It will be displayed in English instead."), $color);
116 $user_language = 'en_US';
118 error_box( _("Help is not available. Please contact your system administrator for assistance."), $color );
123 /* take the chapternumber from the GET-vars,
124 * else see if we can get a relevant chapter from the referer */
127 if ( sqgetGlobalVar('chapter', $temp, SQ_GET
) ) {
128 $chapter = (int) $temp;
129 } elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER
) ) {
130 $ref = strtolower($temp);
132 $contexts = array ( 'src/compose' => 4, 'src/addr' => 5,
133 'src/folders' => 6, 'src/options' => 7, 'src/right_main' => 2,
134 'src/read_body' => 3, 'src/search' => 8 );
136 foreach($contexts as $path => $chap) {
137 if(strpos($ref, $path)) {
144 if ( $chapter == 0 ||
!isset( $helpdir[$chapter-1] ) ) {
145 // Initialise the needed variables.
148 // Get the chapter numbers, title and decriptions.
149 for ($i=0, $cnt = count($helpdir); $i < $cnt; $i++
) {
150 if (file_exists("../help/$user_language/$helpdir[$i]")) {
151 // First try the selected language.
152 $doc = file("../help/$user_language/$helpdir[$i]");
153 $help_info = get_info($doc, 0);
154 $toc[] = array($i+
1, $help_info[0], $help_info[2]);
155 } elseif (file_exists("../help/en_US/$helpdir[$i]")) {
156 // If the selected language can't be found, try English.
157 $doc = file("../help/en_US/$helpdir[$i]");
158 $help_info = get_info($doc, 0);
159 $toc[] = array($i+
1, $help_info[0],
160 _("This chapter is not available in the selected language. It will be displayed in English instead.") .
161 '<br />' . $help_info[2]);
163 // If English can't be found, the chapter went MIA.
164 $toc[] = array($i+
1, _("This chapter is missing"),
165 sprintf(_("For some reason, chapter %s is not available."), $i+
1));
169 // Write the TOC header
170 echo html_tag( 'table', '', 'center', '', 'cellpadding="0" cellspacing="0" border="0"' ) .
173 '<div style="text-align: center;"><b>' . _("Table of Contents") . '</b></div><br />';
174 echo html_tag( 'ol' );
176 // Write the TOC chapters.
177 for ($i=0, $cnt = count($toc); $i < $cnt; $i++
) {
178 echo '<li><a href="../src/help.php?chapter=' . $toc[$i][0]. '">' .
179 $toc[$i][1] . '</a>' . html_tag( 'ul', $toc[$i][2] );
182 // Provide hook for external help scripts.
183 do_hook('help_chapter');
185 // Write the TOC footer.
186 echo '</ol></td></tr></table>';
188 // Initialise the needed variables.
189 $display_chapter = TRUE;
192 if (file_exists("../help/$user_language/" . $helpdir[$chapter-1])) {
193 // First try the selected language.
194 $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
195 } elseif (file_exists("../help/en_US/" . $helpdir[$chapter-1])) {
196 // If the selected language can't be found, try English.
197 $doc = file("../help/en_US/" . $helpdir[$chapter-1]);
198 error_box(_("This chapter in not available in the selected language. It will be displayed in English instead."), $color);
201 // If English can't be found, the chapter went MIA.
202 $display_chapter = FALSE;
205 // Write the chpater header.
206 echo '<div style="text-align: center;"><small>';
208 echo '<font color="' . $color[9] . '">' . _("Previous")
211 echo '<a href="../src/help.php?chapter=' . ($chapter-1)
212 . '">' . _("Previous") . '</a> | ';
214 echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
215 if ($chapter >= count($helpdir)){
216 echo ' | <font color="' . $color[9] . '">' . _("Next") . '</font>';
218 echo ' | <a href="../src/help.php?chapter=' . ($chapter+
1)
219 . '">' . _("Next") . '</a>';
221 echo '</small></div><br />';
223 // Write the chapter.
224 if ($display_chapter) {
225 // If there is a valid chapter, display it.
226 $help_info = get_info($doc, 0);
227 echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
228 . '</b></font><br /><br />';
230 if (isset($help_info[1]) && $help_info[1]) {
233 echo html_tag( 'p', $help_info[2], 'left' );
237 for ($n = $help_info[3], $cnt = count($doc); $n < $cnt; $n++
) {
239 $help_info = get_info($doc, $n);
240 echo "<b>$chapter.$section - $help_info[0]</b>" .
241 html_tag( 'ul', $help_info[1] );
245 echo '<br /><div style="text-align: center;"><a href="#pagetop">' . _("Top") . '</a></div>';
247 // If the help file went MIA, display an error message.
248 error_box(sprintf(_("For some reason, chapter %s is not available."), $chapter), $color);
252 do_hook('help_bottom');
255 html_tag( 'td', ' ', 'left', $color[0] )
261 $oTemplate->display('footer.tpl');