help.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <?php
  2. /**
  3. * help.php
  4. *
  5. * Copyright (c) 1999-2002 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * Displays help for the user
  9. *
  10. * $Id$
  11. */
  12. require_once('../src/validate.php');
  13. require_once('../functions/display_messages.php');
  14. require_once('../functions/imap.php');
  15. require_once('../functions/array.php');
  16. displayPageHeader($color, 'None' );
  17. $helpdir[0] = 'basic.hlp';
  18. $helpdir[1] = 'main_folder.hlp';
  19. $helpdir[2] = 'read_mail.hlp';
  20. $helpdir[3] = 'compose.hlp';
  21. $helpdir[4] = 'addresses.hlp';
  22. $helpdir[5] = 'folders.hlp';
  23. $helpdir[6] = 'options.hlp';
  24. $helpdir[7] = 'search.hlp';
  25. $helpdir[8] = 'FAQ.hlp';
  26. /****************[ HELP FUNCTIONS ]********************/
  27. /**
  28. * parses through and gets the information from the different documents.
  29. * this returns one section at a time. You must keep track of the position
  30. * so that it knows where to start to look for the next section.
  31. */
  32. function get_info($doc, $pos) {
  33. for ($n=$pos; $n < count($doc); $n++) {
  34. if (trim(strtolower($doc[$n])) == '<chapter>'
  35. || trim(strtolower($doc[$n])) == '<section>') {
  36. for ($n++;$n < count($doc)
  37. && (trim(strtolower($doc[$n])) != '</section>')
  38. && (trim(strtolower($doc[$n])) != '</chapter>'); $n++) {
  39. if (trim(strtolower($doc[$n])) == '<title>') {
  40. $n++;
  41. $ary[0] = trim($doc[$n]);
  42. }
  43. if (trim(strtolower($doc[$n])) == '<description>') {
  44. $ary[1] = '';
  45. for ($n++;$n < count($doc)
  46. && (trim(strtolower($doc[$n])) != '</description>');
  47. $n++) {
  48. $ary[1] .= $doc[$n];
  49. }
  50. }
  51. if (trim(strtolower($doc[$n])) == '<summary>') {
  52. $ary[2] = '';
  53. for ($n++; $n < count($doc)
  54. && (trim(strtolower($doc[$n])) != '</summary>');
  55. $n++) {
  56. $ary[2] .= $doc[$n];
  57. }
  58. }
  59. }
  60. if (isset($ary)) {
  61. $ary[3] = $n;
  62. return $ary;
  63. } else {
  64. $ary[0] = 'ERROR: Help files are not in the right format!';
  65. $ary[1] = 'ERROR: Help files are not in the right format!';
  66. $ary[2] = 'ERROR: Help files are not in the right format!';
  67. return $ary;
  68. }
  69. }
  70. }
  71. $ary[0] = 'ERROR: Help files are not in the right format!';
  72. $ary[1] = 'ERROR: Help files are not in the right format!';
  73. return $ary;
  74. }
  75. /**************[ END HELP FUNCTIONS ]******************/
  76. ?>
  77. <br>
  78. <table width="95%" align="center" cellpadding="2" cellspacing="2" border="0">
  79. <tr>
  80. <td bgcolor="<?php echo $color[0] ?>">
  81. <center><b><?php echo _("Help") ?></b></center>
  82. </td>
  83. </tr>
  84. </table>
  85. <?php do_hook("help_top") ?>
  86. <table width="90%" cellpadding="0" cellspacing="10" border="0" align="center">
  87. <tr>
  88. <td>
  89. <?php
  90. if (isset($HTTP_REFERER)) {
  91. $ref = strtolower($HTTP_REFERER);
  92. if (strpos($ref, 'src/compose')){
  93. $context = 'compose';
  94. } else if (strpos($ref, 'src/addr')){
  95. $context = 'address';
  96. } else if (strpos($ref, 'src/folders')){
  97. $context = 'folders';
  98. } else if (strpos($ref, 'src/options')){
  99. $context = 'options';
  100. } else if (strpos($ref, 'src/right_main')){
  101. $context = 'index';
  102. } else if (strpos($ref, 'src/read_body')){
  103. $context = 'read';
  104. } else if (strpos($ref, 'src/search')){
  105. $context = 'search';
  106. }
  107. }
  108. if (!isset($squirrelmail_language)) {
  109. $squirrelmail_language = 'en_US';
  110. }
  111. if (file_exists("../help/$squirrelmail_language")) {
  112. $help_exists = true;
  113. $user_language = $squirrelmail_language;
  114. } else if (file_exists('../help/en_US')) {
  115. $help_exists = true;
  116. echo "<center><font color=\"$color[2]\">";
  117. printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]['NAME']);
  118. echo '</font></center><br>';
  119. $user_language = 'en_US';
  120. } else {
  121. $help_exists = false;
  122. echo "<br><center><font color=\"$color[2]\">" .
  123. _("Some or all of the help documents are not present!").
  124. '</font></center>'.
  125. '</td></tr></table>';
  126. /* this is really silly, because there may be some
  127. * footers. What about them.
  128. * TODO: Fix this so it's not just "exit".
  129. */
  130. exit;
  131. }
  132. if ($help_exists == true) {
  133. if (!isset($context)){
  134. $context = '';
  135. }
  136. if ($context == 'compose'){
  137. $chapter = 4;
  138. } else if ($context == 'address'){
  139. $chapter = 5;
  140. } else if ($context == 'folders'){
  141. $chapter = 6;
  142. } else if ($context == 'options'){
  143. $chapter = 7;
  144. } else if ($context == 'index'){
  145. $chapter = 2;
  146. } else if ($context == 'read'){
  147. $chapter = 3;
  148. } else if ($context == 'search'){
  149. $chapter = 8;
  150. }
  151. if (!isset($chapter)) {
  152. echo '<table cellpadding="0" cellspacing="0" border="0" align="center"><tr><td>' .
  153. '<b><center>' . _("Table of Contents") . '</center></b><br>';
  154. do_hook('help_chapter');
  155. echo '<ol>';
  156. for ($i=0; $i < count($helpdir); $i++) {
  157. $doc = file("../help/$user_language/$helpdir[$i]");
  158. $help_info = get_info($doc, 0);
  159. echo '<li><a href="../src/help.php?chapter=' . ($i+1)
  160. . '">' . $help_info[0] . '</a>';
  161. echo '<ul>' . $help_info[2] . '</ul>';
  162. }
  163. echo '</ol></td></tr></table>';
  164. } else {
  165. $doc = file("../help/$user_language/" . $helpdir[$chapter-1]);
  166. $help_info = get_info($doc, 0);
  167. echo '<small><center>';
  168. if ($chapter <= 1){
  169. echo '<font color="' . $color[9] . '">' . _("Previous")
  170. . '</font> | ';
  171. } else {
  172. echo '<a href="../src/help.php?chapter=' . ($chapter-1)
  173. . '">' . _("Previous") . '</a> | ';
  174. }
  175. echo '<a href="../src/help.php">' . _("Table of Contents") . '</a>';
  176. if ($chapter >= count($helpdir)){
  177. echo ' | <font color="$color[9]">' . _("Next") . '</font>';
  178. } else {
  179. echo ' | <a href="../src/help.php?chapter=' . ($chapter+1)
  180. . '">' . _("Next") . '</a>';
  181. }
  182. echo '</center></small><br>';
  183. echo '<font size="5"><b>' . $chapter . ' - ' . $help_info[0]
  184. . '</b></font><br><br>';
  185. if (isset($help_info[1])){
  186. echo $help_info[1];
  187. } else {
  188. echo '<p>' . $help_info[2] . '</p>';
  189. }
  190. $section = 0;
  191. for ($n = $help_info[3]; $n < count($doc); $n++) {
  192. $section++;
  193. $help_info = get_info($doc, $n);
  194. echo "<b>$chapter.$section - $help_info[0]</b>";
  195. echo '<ul>';
  196. echo $help_info[1];
  197. echo '</ul>';
  198. $n = $help_info[3];
  199. }
  200. echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';
  201. }
  202. }
  203. do_hook('help_bottom');
  204. ?>
  205. <tr><td bgcolor="<?php echo $color[0] ?>">&nbsp;</td></tr></table>
  206. </body></html>