X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fhelp.php;h=4f75306fc1a4b1399ff72a055decba34164f8014;hb=7111b0daa5f74c1c96d3bcf87da7a05e4ba6e189;hp=155d184b55f036185063b2de347e776d16cb531d;hpb=15e6162eacc97158393bc75aed3afeb7b19c24a6;p=squirrelmail.git
diff --git a/src/help.php b/src/help.php
index 155d184b..4f75306f 100644
--- a/src/help.php
+++ b/src/help.php
@@ -3,209 +3,262 @@
/**
* help.php
*
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
* Displays help for the user
*
- * $Id$
+ * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ */
+
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../include/init.php');
+
+displayPageHeader($color, 'None' );
+
+$helpdir[0] = 'basic.hlp';
+$helpdir[1] = 'main_folder.hlp';
+$helpdir[2] = 'read_mail.hlp';
+$helpdir[3] = 'compose.hlp';
+$helpdir[4] = 'addresses.hlp';
+$helpdir[5] = 'folders.hlp';
+$helpdir[6] = 'options.hlp';
+$helpdir[7] = 'search.hlp';
+$helpdir[8] = 'FAQ.hlp';
+
+/****************[ HELP FUNCTIONS ]********************/
+
+/**
+ * parses through and gets the information from the different documents.
+ * this returns one section at a time. You must keep track of the position
+ * so that it knows where to start to look for the next section.
*/
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
-/*** + Base level indent should begin at left margin, as ***/
-/*** the require_once below looks. ***/
-/*** + All identation should consist of four space blocks ***/
-/*** + Tab characters are evil. ***/
-/*** + all comments should use "slash-star ... star-slash" ***/
-/*** style -- no pound characters, no slash-slash style ***/
-/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
-/*** ALWAYS USE { AND } CHARACTERS!!! ***/
-/*** + Please use ' instead of ", when possible. Note " ***/
-/*** should always be used in _( ) function calls. ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
-
-require_once('../src/validate.php');
-require_once('../functions/display_messages.php');
-require_once('../functions/imap.php');
-require_once('../functions/array.php');
-
-
- displayPageHeader($color, 'None' );
-
- $helpdir[0] = 'basic.hlp';
- $helpdir[1] = 'main_folder.hlp';
- $helpdir[2] = 'read_mail.hlp';
- $helpdir[3] = 'compose.hlp';
- $helpdir[4] = 'addresses.hlp';
- $helpdir[5] = 'folders.hlp';
- $helpdir[6] = 'options.hlp';
- $helpdir[7] = 'search.hlp';
- $helpdir[8] = 'FAQ.hlp';
-
- /****************[ HELP FUNCTIONS ]********************/
- // parses through and gets the information from the different documents.
- // this returns one section at a time. You must keep track of the position
- // so that it knows where to start to look for the next section.
-
- function get_info($doc, $pos) {
- for ($n=$pos; $n < count($doc); $n++) {
- if (trim(strtolower($doc[$n])) == "
- |
-";
- printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]);
- echo " "; - $user_language = "en"; - } else { - $help_exists = false; - echo " |
\n";
- echo " "; - do_hook("help_chapter"); - echo "
'; + $user_language = 'en_US'; +} else { + error_box( _("Help is not available. Please contact your system administrator for assistance.")); + // display footer (closes html tags) and stop script execution + $oTemplate->display('footer.tpl'); + exit(); +} + + +/* take the chapternumber from the GET-vars, + * else see if we can get a relevant chapter from the referer */ +$chapter = 0; + +if ( sqgetGlobalVar('chapter', $temp, SQ_GET) ) { + $chapter = (int) $temp; +} elseif ( sqgetGlobalVar('HTTP_REFERER', $temp, SQ_SERVER) ) { + $ref = strtolower($temp); + + $contexts = array ( 'src/compose' => 4, 'src/addr' => 5, + 'src/folders' => 6, 'src/options' => 7, 'src/right_main' => 2, + 'src/read_body' => 3, 'src/search' => 8 ); + + foreach($contexts as $path => $chap) { + if(strpos($ref, $path)) { + $chapter = $chap; + break; + } + } +} + +if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) { + // Initialise the needed variables. + $toc = array(); + + // Get the chapter numbers, title and decriptions. + for ($i=0, $cnt = count($helpdir); $i < $cnt; $i++) { + if (file_exists("../help/$user_language/$helpdir[$i]")) { + // First try the selected language. $doc = file("../help/$user_language/$helpdir[$i]"); $help_info = get_info($doc, 0); - echo " |
$help_info[2]
\n"; - - $section = 0; - for ($n = $help_info[3]; $n < count($doc); $n++) { + $toc[] = array($i+1, $help_info[0], $help_info[2]); + } elseif (file_exists("../help/en_US/$helpdir[$i]")) { + // If the selected language can't be found, try English. + $doc = file("../help/en_US/$helpdir[$i]"); + $help_info = get_info($doc, 0); + $toc[] = array($i+1, $help_info[0], + _("This chapter is not available in the selected language. It will be displayed in English instead.") . + '