849bdf42 |
1 | <?php |
d112ed5a |
2 | /** |
3 | * lang_change.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 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 | */ |
2b5a7157 |
18 | |
d8aa9efe |
19 | global $SQSPELL_APP_DEFAULT; |
20 | |
21 | $use_langs = $_POST['use_langs']; |
22 | $lang_default = $_POST['lang_default']; |
23 | |
d112ed5a |
24 | $words = sqspell_getWords(); |
25 | if (!$words) { |
26 | $words = sqspell_makeDummy(); |
27 | } |
28 | $langs = sqspell_getSettings($words); |
29 | if (sizeof($use_langs)){ |
30 | /** |
31 | * See if the user clicked any options on the previous page. |
32 | */ |
33 | if (sizeof($use_langs)>1){ |
34 | /** |
35 | * See if s/he wants more than one dictionary. |
36 | */ |
37 | if ($use_langs[0]!=$lang_default){ |
38 | /** |
39 | * See if we need to juggle the order of the dictionaries |
40 | * to make the default dictionary first in line. |
41 | */ |
42 | if (in_array($lang_default, $use_langs)){ |
43 | /** |
44 | * See if the user was dumb and chose a default dictionary |
45 | * to be something other than the ones he selected. |
46 | */ |
47 | $hold = array_shift($use_langs); |
48 | $lang_string = join(", ", $use_langs); |
49 | $lang_string = str_replace("$lang_default", "$hold", $lang_string); |
50 | $lang_string = $lang_default . ", " . $lang_string; |
51 | } else { |
52 | /** |
53 | * Yes, he is dumb. |
54 | */ |
55 | $lang_string = join(', ', $use_langs); |
56 | } |
849bdf42 |
57 | } else { |
d112ed5a |
58 | /** |
59 | * No need to juggle the order -- preferred is already first. |
60 | */ |
61 | $lang_string = join(', ', $use_langs); |
849bdf42 |
62 | } |
d112ed5a |
63 | } else { |
64 | /** |
65 | * Just one dictionary, please. |
66 | */ |
67 | $lang_string = $use_langs[0]; |
68 | } |
69 | $lang_array = explode( ',', $lang_string ); |
70 | $dsp_string = ''; |
71 | foreach( $lang_array as $a) { |
72 | $dsp_string .= _(trim($a)) . ', '; |
73 | } |
74 | $dsp_string = substr( $dsp_string, 0, -2 ); |
75 | $msg = '<p>' |
76 | . sprintf(_("Settings adjusted to: <strong>%s</strong> with <strong>%s</strong> as default dictionary."), $dsp_string, _($lang_default)) |
77 | . '</p>'; |
78 | } else { |
79 | /** |
80 | * No dictionaries selected. Use system default. |
81 | */ |
82 | $msg = '<p>' |
83 | . sprintf(_("Using <strong>%s</strong> dictionary (system default) for spellcheck." ), $SQSPELL_APP_DEFAULT) |
84 | . '</p>'; |
85 | $lang_string = $SQSPELL_APP_DEFAULT; |
86 | } |
87 | $old_lang_string = join(", ", $langs); |
88 | $words = str_replace("# LANG: $old_lang_string", "# LANG: $lang_string", |
89 | $words); |
90 | /** |
91 | * Write it down where the sun don't shine. |
92 | */ |
93 | sqspell_writeWords($words); |
94 | sqspell_makePage(_("International Dictionaries Preferences Updated"), |
95 | null, $msg); |
96 | |
97 | /** |
98 | * For Emacs weenies: |
99 | * Local variables: |
100 | * mode: php |
101 | * End: |
102 | */ |
15e6162e |
103 | ?> |