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

Documentation generated on Mon, 13 Jan 2020 04:22:41 +0100 by phpDocumentor 1.4.3