Source for file help.php

Documentation is available at help.php

  1. <?php
  2.  
  3. /**
  4.  * help.php
  5.  *
  6.  * Displays help for the user
  7.  *
  8.  * @copyright &copy; 1999-2006 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: help.php,v 1.42.2.13 2006/06/15 21:27:24 jervfors Exp $
  11.  * @package squirrelmail
  12.  */
  13.  
  14. /**
  15.  * Path for SquirrelMail required files.
  16.  * @ignore
  17.  */
  18. define('SM_PATH','../');
  19.  
  20. /* SquirrelMail required files. */
  21. require_once(SM_PATH 'include/validate.php');
  22. require_once(SM_PATH 'functions/global.php');
  23. require_once(SM_PATH 'functions/display_messages.php');
  24.  
  25. displayPageHeader($color'None' );
  26.  
  27. $helpdir[0'basic.hlp';
  28. $helpdir[1'main_folder.hlp';
  29. $helpdir[2'read_mail.hlp';
  30. $helpdir[3'compose.hlp';
  31. $helpdir[4'addresses.hlp';
  32. $helpdir[5'folders.hlp';
  33. $helpdir[6'options.hlp';
  34. $helpdir[7'search.hlp';
  35. $helpdir[8'FAQ.hlp';
  36.  
  37. /****************[ HELP FUNCTIONS ]********************/
  38.  
  39. /**
  40.  * parses through and gets the information from the different documents.
  41.  * this returns one section at a time.  You must keep track of the position
  42.  * so that it knows where to start to look for the next section.
  43.  */
  44.  
  45. function get_info($doc$pos{
  46.     $ary array(0,0,0);
  47.  
  48.     $cntdoc count($doc);
  49.  
  50.     for ($n=$pos$n $cntdoc$n++{
  51.         if (trim(strtolower($doc[$n])) == '<chapter>'
  52.             || trim(strtolower($doc[$n])) == '<section>'{
  53.             for ($n++$n $cntdoc
  54.                  && (trim(strtolower($doc[$n])) != '</section>')
  55.                  && (trim(strtolower($doc[$n])) != '</chapter>')$n++{
  56.                 if (trim(strtolower($doc[$n])) == '<title>'{
  57.                     $n++;
  58.                     $ary[0trim($doc[$n]);
  59.                 }
  60.                 if (trim(strtolower($doc[$n])) == '<description>'{
  61.                     $ary[1'';
  62.                     for ($n++;$n $cntdoc
  63.                          && (trim(strtolower($doc[$n])) != '</description>');
  64.                          $n++{
  65.                         $ary[1.= $doc[$n];
  66.                     }
  67.                 }
  68.                 if (trim(strtolower($doc[$n])) == '<summary>'{
  69.                     $ary[2'';
  70.                     for ($n++$n $cntdoc
  71.                          && (trim(strtolower($doc[$n])) != '</summary>');
  72.                          $n++{
  73.                         $ary[2.= $doc[$n];
  74.                     }
  75.                 }
  76.             }
  77.             if (isset($ary)) {
  78.                 $ary[3$n;
  79.             else {
  80.                 $ary[0_("ERROR: Help files are not in the right format!");
  81.                 $ary[1$ary[0];
  82.                 $ary[2$ary[0];
  83.             }
  84.             return$ary );
  85.         else if (!trim(strtolower($doc[$n]))) {
  86.             $ary[0'';
  87.             $ary[1'';
  88.             $ary[2'';
  89.             $ary[3$n;
  90.         }
  91.     }
  92.     $ary[0_("ERROR: Help files are not in the right format!");
  93.     $ary[1$ary[0];
  94.     $ary[2$ary[0];
  95.     $ary[3$n;
  96.     return$ary );
  97. }
  98.  
  99. /**************[ END HELP FUNCTIONS ]******************/
  100.  
  101. echo html_tag'table',
  102.         html_tag'tr',
  103.             html_tag'td','<div style="text-align: center;"><b>' _("Help".'</b></div>''center'$color[0)
  104.         ,
  105.     'center''''width="95%" cellpadding="1" cellspacing="2" border="0"' );
  106.  
  107. do_hook('help_top');
  108.  
  109. echo html_tag'table''''center''''width="90%" cellpadding="0" cellspacing="10" border="0"' .
  110.         html_tag'tr' .
  111.             html_tag'td' );
  112.  
  113. if (!isset($squirrelmail_language)) {
  114.     $squirrelmail_language 'en_US';
  115. }
  116.  
  117. if (file_exists("../help/$squirrelmail_language")) {
  118.     $user_language $squirrelmail_language;
  119. else if (file_exists('../help/en_US')) {
  120.     error_box(_("Help is not available in the selected language. It will be displayed in English instead.")$color);
  121.     echo '<br />';
  122.     $user_language 'en_US';
  123. else {
  124.     error_box_("Help is not available. Please contact your system administrator for assistance.")$color );
  125.     echo '</td></tr></table>';
  126.     exit;
  127. }
  128.  
  129.  
  130. /* take the chapternumber from the GET-vars,
  131.  * else see if we can get a relevant chapter from the referer */
  132. $chapter 0;
  133.  
  134. if sqgetGlobalVar('chapter'$tempSQ_GET) ) {
  135.     $chapter = (int) $temp;
  136. elseif sqgetGlobalVar('HTTP_REFERER'$tempSQ_SERVER) ) {
  137.     $ref strtolower($temp);
  138.  
  139.     $contexts array 'src/compose' => 4'src/addr' => 5,
  140.         'src/folders' => 6'src/options' => 7'src/right_main' => 2,
  141.         'src/read_body' => 3'src/search' => );
  142.  
  143.     foreach($contexts as $path => $chap{
  144.         if(strpos($ref$path)) {
  145.             $chapter $chap;
  146.             break;
  147.         }
  148.     }
  149. }
  150.  
  151. if $chapter == || !isset$helpdir[$chapter-1) ) {
  152.     // Initialise the needed variables.
  153.         $toc array();
  154.  
  155.     // Get the chapter numbers, title and decriptions.
  156.         for ($i=0$cnt count($helpdir)$i $cnt$i++{
  157.         if (file_exists("../help/$user_language/$helpdir[$i]")) {
  158.             // First try the selected language.
  159.                         $doc file("../help/$user_language/$helpdir[$i]");
  160.             $help_info get_info($doc0);
  161.             $toc[array($i+1$help_info[0]$help_info[2]);
  162.         elseif (file_exists("../help/en_US/$helpdir[$i]")) {
  163.             // If the selected language can't be found, try English.
  164.                         $doc file("../help/en_US/$helpdir[$i]");
  165.             $help_info get_info($doc0);
  166.             $toc[array($i+1$help_info[0],
  167.                     _("This chapter is not available in the selected language. It will be displayed in English instead.".
  168.                     '<br />' $help_info[2]);
  169.         else {
  170.             // If English can't be found, the chapter went MIA.
  171.                         $toc[array($i+1_("This chapter is missing"),
  172.                     sprintf(_("For some reason, chapter %s is not available.")$i+1));
  173.         }
  174.     }
  175.  
  176.     // Write the TOC header
  177.         echo html_tag'table''''center''''cellpadding="0" cellspacing="0" border="0"' .
  178.          html_tag'tr' .
  179.          html_tag'td' .
  180.          '<div style="text-align: center;"><b>' _("Table of Contents"'</b></div><br />';
  181.     echo html_tag'ol' );
  182.  
  183.     // Write the TOC chapters.
  184.     // FIXME: HTML code is not compliant.
  185.         for ($i=0$cnt count($toc)$i $cnt$i++{
  186.         echo '<li><a href="../src/help.php?chapter=' $toc[$i][0]'">' .
  187.             $toc[$i][1'</a>' html_tag'ul'$toc[$i][2);
  188.     }
  189.  
  190.     // Provide hook for external help scripts.
  191.         do_hook('help_chapter');
  192.  
  193.     // Write the TOC footer.
  194.         echo '</ol></td></tr></table>';
  195. else {
  196.     // Initialise the needed variables.
  197.         $display_chapter TRUE;
  198.  
  199.     // Get the chapter.
  200.         if (file_exists("../help/$user_language/$helpdir[$chapter-1])) {
  201.         // First try the selected language.
  202.                 $doc file("../help/$user_language/$helpdir[$chapter-1]);
  203.     elseif (file_exists("../help/en_US/" $helpdir[$chapter-1])) {
  204.         // If the selected language can't be found, try English.
  205.                 $doc file("../help/en_US/" $helpdir[$chapter-1]);
  206.         error_box(_("This chapter is not available in the selected language. It will be displayed in English instead.")$color);
  207.         echo '<br />';
  208.     else {
  209.         // If English can't be found, the chapter went MIA.
  210.                 $display_chapter FALSE;
  211.     }
  212.  
  213.     // Write the chpater header.
  214.         echo '<div style="text-align: center;"><small>';
  215.     if ($chapter <= 1){
  216.         echo '<font color="' $color[9'">' _("Previous")
  217.              . '</font> | ';
  218.     else {
  219.         echo '<a href="../src/help.php?chapter=' ($chapter-1)
  220.              . '">' _("Previous"'</a> | ';
  221.     }
  222.     echo '<a href="../src/help.php">' _("Table of Contents"'</a>';
  223.     if ($chapter >= count($helpdir)){
  224.         echo ' | <font color="' $color[9'">' _("Next"'</font>';
  225.     else {
  226.         echo ' | <a href="../src/help.php?chapter=' ($chapter+1)
  227.              . '">' _("Next"'</a>';
  228.     }
  229.     echo '</small></div><br />';
  230.  
  231.     // Write the chapter.
  232.         if ($display_chapter{
  233.         // If there is a valid chapter, display it.
  234.                 $help_info get_info($doc0);
  235.         echo '<font size="5"><b>' $chapter ' - ' $help_info[0]
  236.             . '</b></font><br /><br />';
  237.  
  238.         if (isset($help_info[1]&& $help_info[1]{
  239.             echo $help_info[1];
  240.         else {
  241.             echo html_tag'p'$help_info[2]'left' );
  242.         }
  243.  
  244.         $section 0;
  245.         for ($n $help_info[3]$cnt count($doc)$n $cnt$n++{
  246.             $section++;
  247.             $help_info get_info($doc$n);
  248.             echo "<b>$chapter.$section - $help_info[0]</b>.
  249.                 $help_info[1];
  250.             $n $help_info[3];
  251.         }
  252.  
  253.         echo '<br /><div style="text-align: center;"><a href="#pagetop">' _("Top"'</a></div>';
  254.     else {
  255.         // If the help file went MIA, display an error message.
  256.                 error_box(sprintf(_("For some reason, chapter %s is not available.")$chapter)$color);
  257.     }
  258. }
  259.  
  260. do_hook('help_bottom');
  261.  
  262. echo html_tag'tr',
  263.             html_tag'td''&nbsp;''left'$color[0)
  264.         );
  265.  
  266. ?>
  267. </table></body></html>

Documentation generated on Sat, 07 Oct 2006 16:31:28 +0300 by phpDocumentor 1.3.0RC6