849bdf42 |
1 | <?php |
2 | /** |
3 | LANG_CHANGE.MOD.PHP |
4 | -------------------- |
5 | This module changes the international dictionaries selection |
6 | for the user. Called after LANG_SETUP module. |
7 | **/ |
8 | // For poor wretched souls with E_ALL. |
9 | global $use_langs, $lang_default, $SQSPELL_APP_DEFAULT; |
10 | |
11 | $words = sqspell_getWords(); |
12 | if (!$words) $words = sqspell_makeDummy(); |
13 | $langs = sqspell_getSettings($words); |
14 | if (sizeof($use_langs)){ |
15 | // See if the user clicked any options on the previous page. |
16 | if (sizeof($use_langs)>1){ |
17 | // See if s/he wants more than one dictionary. |
18 | if ($use_langs[0]!=$lang_default){ |
19 | // See if we need to juggle the order of the dictionaries |
20 | // to make the default dictionary first in line. |
21 | if (in_array($lang_default, $use_langs)){ |
22 | // see if the user was dumb and chose a default dictionary |
23 | // to be something other than the ones he selected. |
24 | $hold = array_shift($use_langs); |
25 | $lang_string = join(", ", $use_langs); |
26 | $lang_string = str_replace("$lang_default", "$hold", $lang_string); |
27 | $lang_string = $lang_default . ", " . $lang_string; |
28 | } else { |
29 | // Yes, he is dumb. |
30 | $lang_string = join(", ", $use_langs); |
31 | } |
32 | } else { |
33 | // No need to juggle the order -- preferred is already first. |
34 | $lang_string = join(", ", $use_langs); |
35 | } |
36 | } else { |
37 | // Just one dictionary, please. |
38 | $lang_string = $use_langs[0]; |
39 | } |
40 | $msg = "<p>Settings adjusted to: <strong>$lang_string</strong> with |
41 | <strong>$lang_default</strong> as default dictionary.</p>"; |
42 | } else { |
43 | // No dictionaries selected. Use system default. |
44 | $msg = "<p>Using <strong>$SQSPELL_APP_DEFAULT</strong> dictionary (system default) |
45 | for spellcheck.</p>"; |
46 | $lang_string = $SQSPELL_APP_DEFAULT; |
47 | } |
48 | $old_lang_string = join(", ", $langs); |
49 | $words = str_replace("# LANG: $old_lang_string", "# LANG: $lang_string", $words); |
50 | // write it down where the sun don't shine. |
51 | sqspell_writeWords($words); |
52 | sqspell_makePage("International Dictionaries Preferences Updated", null, $msg); |
53 | ?> |