lang_change.mod 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * lang_change.mod
  4. * ----------------
  5. * Squirrelspell module
  6. *
  7. * Copyright (c) 1999-2003 The SquirrelMail development team
  8. * Licensed under the GNU GPL. For full terms see the file COPYING.
  9. *
  10. * This module changes the international dictionaries selection
  11. * for the user. Called after LANG_SETUP module.
  12. *
  13. * $Id$
  14. *
  15. * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
  16. * @version $Date$
  17. */
  18. global $SQSPELL_APP_DEFAULT;
  19. $use_langs = $_POST['use_langs'];
  20. $lang_default = $_POST['lang_default'];
  21. $words = sqspell_getWords();
  22. if (!$words) {
  23. $words = sqspell_makeDummy();
  24. }
  25. $langs = sqspell_getSettings($words);
  26. if (sizeof($use_langs)){
  27. /**
  28. * See if the user clicked any options on the previous page.
  29. */
  30. if (sizeof($use_langs)>1){
  31. /**
  32. * See if s/he wants more than one dictionary.
  33. */
  34. if ($use_langs[0]!=$lang_default){
  35. /**
  36. * See if we need to juggle the order of the dictionaries
  37. * to make the default dictionary first in line.
  38. */
  39. if (in_array($lang_default, $use_langs)){
  40. /**
  41. * See if the user was dumb and chose a default dictionary
  42. * to be something other than the ones he selected.
  43. */
  44. $hold = array_shift($use_langs);
  45. $lang_string = join(", ", $use_langs);
  46. $lang_string = str_replace("$lang_default", "$hold", $lang_string);
  47. $lang_string = $lang_default . ", " . $lang_string;
  48. } else {
  49. /**
  50. * Yes, he is dumb.
  51. */
  52. $lang_string = join(', ', $use_langs);
  53. }
  54. } else {
  55. /**
  56. * No need to juggle the order -- preferred is already first.
  57. */
  58. $lang_string = join(', ', $use_langs);
  59. }
  60. } else {
  61. /**
  62. * Just one dictionary, please.
  63. */
  64. $lang_string = $use_langs[0];
  65. }
  66. $lang_array = explode( ',', $lang_string );
  67. $dsp_string = '';
  68. foreach( $lang_array as $a) {
  69. $dsp_string .= _(trim($a)) . ', ';
  70. }
  71. $dsp_string = substr( $dsp_string, 0, -2 );
  72. $msg = '<p>'
  73. . sprintf(_("Settings adjusted to: %s with %s as default dictionary."), '<strong>'.$dsp_string.'</strong>', '<strong>'._($lang_default).'</strong>')
  74. . '</p>';
  75. } else {
  76. /**
  77. * No dictionaries selected. Use system default.
  78. */
  79. $msg = '<p>'
  80. . sprintf(_("Using %s dictionary (system default) for spellcheck." ), '<strong>'.$SQSPELL_APP_DEFAULT.'</strong>')
  81. . '</p>';
  82. $lang_string = $SQSPELL_APP_DEFAULT;
  83. }
  84. $old_lang_string = join(", ", $langs);
  85. $words = str_replace("# LANG: $old_lang_string", "# LANG: $lang_string",
  86. $words);
  87. /**
  88. * Write it down where the sun don't shine.
  89. */
  90. sqspell_writeWords($words);
  91. sqspell_makePage(_("International Dictionaries Preferences Updated"),
  92. null, $msg);
  93. /**
  94. * For Emacs weenies:
  95. * Local variables:
  96. * mode: php
  97. * End:
  98. * vim: syntax=php
  99. */
  100. ?>