edit_dic.mod 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * edit_dic.mod
  4. * -------------
  5. * Squirrelspell module
  6. *
  7. * Copyright (c) 1999-2002 The SquirrelMail development team
  8. * Licensed under the GNU GPL. For full terms see the file COPYING.
  9. *
  10. * This module lets the user edit his/her personal dictionary.
  11. *
  12. * $Id$
  13. *
  14. * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
  15. * @version $Date
  16. */
  17. global $color;
  18. /**
  19. * Get the user dictionary and see if it's empty or not.
  20. */
  21. $words=sqspell_getWords();
  22. if (!$words){
  23. /**
  24. * Agt. Smith: "You're empty."
  25. * Neo: "So are you."
  26. */
  27. sqspell_makePage(_("Personal Dictionary"), null,
  28. '<p>' . _("No words in your personal dictionary.")
  29. . '</p>');
  30. } else {
  31. /**
  32. * We're loaded with booty.
  33. */
  34. $pre_msg = '<p>'
  35. . _("Please check any words you wish to delete from your dictionary.")
  36. . "</p>\n";
  37. $pre_msg .= "<table border=\"0\" width=\"95%\" align=\"center\">\n";
  38. /**
  39. * Get how many dictionaries this user has defined.
  40. */
  41. $langs=sqspell_getSettings($words);
  42. for ($i=0; $i<sizeof($langs); $i++){
  43. /**
  44. * Get all words from this language dictionary.
  45. */
  46. $lang_words = sqspell_getLang($words, $langs[$i]);
  47. if ($lang_words){
  48. /**
  49. * There are words in this dictionary. If this is the first
  50. * language we're processing, prepend the output with the
  51. * "header" message.
  52. */
  53. if (!$msg) {
  54. $msg = $pre_msg;
  55. }
  56. $msg .= "<tr bgcolor=\"$color[0]\" align=\"center\"><th>"
  57. . sprintf( _("%s dictionary"), $langs[$i] ) . '</th></tr>'
  58. . '<tr><td align="center">'
  59. . '<form method="post">'
  60. . '<input type="hidden" name="MOD" value="forget_me">'
  61. . '<input type="hidden" name="sqspell_use_app" value="'
  62. . $langs[$i] . '">'
  63. . '<table border="0" width="95%" align="center">'
  64. . '<tr>'
  65. . "<td valign=\"top\">\n";
  66. $words_ary=explode("\n", $lang_words);
  67. /**
  68. * There are two lines we need to remove:
  69. * 1st: # Language
  70. * last: # End
  71. */
  72. array_pop($words_ary);
  73. array_shift($words_ary);
  74. /**
  75. * Do some fancy stuff to separate the words into three
  76. * columns.
  77. */
  78. for ($j=0; $j<sizeof($words_ary); $j++){
  79. if ($j==intval(sizeof($words_ary)/3)
  80. || $j==intval(sizeof($words_ary)/3*2)){
  81. $msg .= "</td><td valign=\"top\">\n";
  82. }
  83. $msg .= "<input type=\"checkbox\" name=\"words_ary[]\" "
  84. . "value=\"$words_ary[$j]\"> $words_ary[$j]<br>";
  85. }
  86. $msg .= '</td></tr></table></td></tr>'
  87. . "<tr bgcolor=\"$color[0]\" align=\"center\"><td>"
  88. . '<input type="submit" value="' . _("Delete checked words")
  89. . '"></form>'
  90. . '</td></tr><tr><td><hr>'
  91. . "</td></tr>\n";
  92. }
  93. }
  94. /**
  95. * Check if all dictionaries were empty.
  96. */
  97. if (!$msg) {
  98. $msg = '<p>' . _("No words in your personal dictionary.") . '</p>';
  99. } else {
  100. $msg .= '</table>';
  101. }
  102. sqspell_makePage(_("Edit your Personal Dictionary"), null, $msg);
  103. }
  104. /**
  105. * For Emacs weenies:
  106. * Local variables:
  107. * mode: php
  108. * End:
  109. */
  110. ?>