Source for file help.php

Documentation is available at help.php

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

Documentation generated on 2020年1月13日 04:22:41 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /