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.70 2006/08/25 21:36:14 stevetruckstuff Exp $
  11.  * @package squirrelmail
  12.  */
  13.  
  14. /**
  15.  * Include the SquirrelMail initialization file.
  16.  */
  17. require('../include/init.php');
  18.  
  19. displayPageHeader($color'None' );
  20.  
  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';
  30.  
  31. /****************[ HELP FUNCTIONS ]********************/
  32.  
  33. /**
  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.
  37.  */
  38.  
  39. function get_info($doc$pos{
  40.     $ary array(0,0,0);
  41.  
  42.     $cntdoc count($doc);
  43.  
  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>'{
  51.                     $n++;
  52.                     $ary[0trim($doc[$n]);
  53.                 }
  54.                 if (trim(strtolower($doc[$n])) == '<description>'{
  55.                     $ary[1'';
  56.                     for ($n++;$n $cntdoc
  57.                          && (trim(strtolower($doc[$n])) != '</description>');
  58.                          $n++{
  59.                         $ary[1.= $doc[$n];
  60.                     }
  61.                 }
  62.                 if (trim(strtolower($doc[$n])) == '<summary>'{
  63.                     $ary[2'';
  64.                     for ($n++$n $cntdoc
  65.                          && (trim(strtolower($doc[$n])) != '</summary>');
  66.                          $n++{
  67.                         $ary[2.= $doc[$n];
  68.                     }
  69.                 }
  70.             }
  71.             if (isset($ary)) {
  72.                 $ary[3$n;
  73.             else {
  74.                 $ary[0_("ERROR: Help files are not in the right format!");
  75.                 $ary[1$ary[0];
  76.                 $ary[2$ary[0];
  77.             }
  78.             return$ary );
  79.         else if (!trim(strtolower($doc[$n]))) {
  80.             $ary[0'';
  81.             $ary[1'';
  82.             $ary[2'';
  83.             $ary[3$n;
  84.         }
  85.     }
  86.     $ary[0_("ERROR: Help files are not in the right format!");
  87.     $ary[1$ary[0];
  88.     $ary[2$ary[0];
  89.     $ary[3$n;
  90.     return$ary );
  91. }
  92.  
  93. /**************[ END HELP FUNCTIONS ]******************/
  94.  
  95. do_hook('help_top');
  96.  
  97. if (!isset($squirrelmail_language)) {
  98.     $squirrelmail_language 'en_US';
  99. }
  100.  
  101. if (file_exists("../help/$squirrelmail_language")) {
  102.     $user_language $squirrelmail_language;
  103. else if (file_exists('../help/en_US')) {
  104.     error_box(_("Help is not available in the selected language. It will be displayed in English instead."));
  105.     echo '<br />';
  106.     $user_language 'en_US';
  107. else {
  108.     error_box_("Help is not available. Please contact your system administrator for assistance."));
  109.     echo '</td></tr></table>';
  110.     // Display footer (closes HTML tags) and stop script execution.
  111.         $oTemplate->display('footer.tpl');
  112.     exit;
  113. }
  114.  
  115.  
  116. /* take the chapternumber from the GET-vars,
  117.  * else see if we can get a relevant chapter from the referer */
  118. $chapter 0;
  119.  
  120. if sqgetGlobalVar('chapter'$tempSQ_GET) ) {
  121.     $chapter = (int) $temp;
  122. elseif sqgetGlobalVar('HTTP_REFERER'$tempSQ_SERVER) ) {
  123.     $ref strtolower($temp);
  124.  
  125.     $contexts array 'src/compose' => 4'src/addr' => 5,
  126.         'src/folders' => 6'src/options' => 7'src/right_main' => 2,
  127.         'src/read_body' => 3'src/search' => );
  128.  
  129.     foreach($contexts as $path => $chap{
  130.         if(strpos($ref$path)) {
  131.             $chapter $chap;
  132.             break;
  133.         }
  134.     }
  135. }
  136.  
  137. if $chapter == || !isset$helpdir[$chapter-1) ) {
  138.     // Initialise the needed variables.
  139.         $toc array();
  140.  
  141.     // Get the chapter numbers, title and decriptions.
  142.         for ($i=0$cnt count($helpdir)$i $cnt$i++{
  143.         if (file_exists("../help/$user_language/$helpdir[$i]")) {
  144.             // First try the selected language.
  145.                         $doc file("../help/$user_language/$helpdir[$i]");
  146.             $help_info get_info($doc0);
  147.             $toc[array($i+1$help_info[0]$help_info[2]);
  148.         elseif (file_exists("../help/en_US/$helpdir[$i]")) {
  149.             // If the selected language can't be found, try English.
  150.                         $doc file("../help/en_US/$helpdir[$i]");
  151.             $help_info get_info($doc0);
  152.             $toc[array($i+1$help_info[0],
  153.                     _("This chapter is not available in the selected language. It will be displayed in English instead.".
  154.                     '<br />' $help_info[2]);
  155.         else {
  156.             // If English can't be found, the chapter went MIA.
  157.                         $toc[array($i+1_("This chapter is missing"),
  158.                     sprintf(_("For some reason, chapter %s is not available.")$i+1));
  159.         }
  160.     }
  161.  
  162.     // Provide hook for external help scripts.
  163.         do_hook('help_chapter');
  164.  
  165.     $new_toc array();
  166.     foreach ($toc as $ch{
  167.         $a array();
  168.         $a['Chapter'$ch[0];
  169.         $a['Title'$ch[1];
  170.         $a['Summary'trim($ch[2]);
  171.         $new_toc[$a;
  172.     }
  173.     
  174.     $oTemplate->assign('toc'$new_toc);
  175.     
  176.     $oTemplate->display('help_toc.tpl');
  177. else {
  178.     // Initialise the needed variables.
  179.         $display_chapter TRUE;
  180.  
  181.     // Get the chapter.
  182.         if (file_exists("../help/$user_language/$helpdir[$chapter-1])) {
  183.         // First try the selected language.
  184.                 $doc file("../help/$user_language/$helpdir[$chapter-1]);
  185.     elseif (file_exists("../help/en_US/" $helpdir[$chapter-1])) {
  186.         // If the selected language can't be found, try English.
  187.                 $doc file("../help/en_US/" $helpdir[$chapter-1]);
  188.         error_box(_("This chapter is not available in the selected language. It will be displayed in English instead."));
  189.         echo '<br />';
  190.     else {
  191.         // If English can't be found, the chapter went MIA.
  192.                 $display_chapter FALSE;
  193.     }
  194.  
  195.     // Write the chapter.
  196.         if ($display_chapter{
  197.         // If there is a valid chapter, display it.
  198.                 $help_info get_info($doc0);
  199.         $ch array();
  200.         $ch['Chapter'$chapter;
  201.         $ch['Title'$help_info[0];
  202.         $ch['Summary'= isset($help_info[1]&& $help_info[1trim($help_info[1]$help_info[2];
  203.         $ch['Sections'array();
  204.         $section 0;
  205.         for ($n $help_info[3]$cnt count($doc)$n $cnt$n++{
  206.             $section++;
  207.             $help_info get_info($doc$n);
  208.             $n $help_info[3];
  209.  
  210.             $a array();
  211.             $a['SectionNumber'$section;
  212.             $a['SectionTitle'$help_info[0];
  213.             $a['SectionText'= isset($help_info[1]trim($help_info[1]'';;
  214.             
  215.             $ch['Sections'][$a;
  216.         }
  217.         
  218.         $oTemplate->assign('chapter_number'$chapter);
  219.         $oTemplate->assign('chapter_count'count($helpdir));
  220.         $oTemplate->assign('chapter_title'$ch['Title']);
  221.         $oTemplate->assign('chapter_summary'$ch['Summary']);
  222.         $oTemplate->assign('sections'$ch['Sections']);
  223.         $oTemplate->assign('error_msg'NULL);
  224.     else {
  225.         // If the help file went MIA, trigger an error message.
  226.                 $oTemplate->assign('chapter_number'$chapter);
  227.         $oTemplate->assign('chapter_count'count($helpdir));
  228.         $oTemplate->assign('chapter_title''');
  229.         $oTemplate->assign('chapter_summary''');
  230.         $oTemplate->assign('sections'array());
  231.         $oTemplate->assign('error_msg'sprintf(_("For some reason, chapter %s is not available.")$chapter));
  232.     }
  233.     
  234.     $oTemplate->display('help_chapter.tpl');
  235. }
  236.  
  237. do_hook('help_bottom');
  238.  
  239. $oTemplate->display('footer.tpl');
  240. ?>

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