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