File: lang_change.mod

package info (click to toggle)
squirrelmail 1%3A1.2.6-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 8,300 kB
  • ctags: 4,949
  • sloc: php: 21,297; perl: 2,538; sh: 350; ansic: 122; makefile: 69
file content (99 lines) | stat: -rw-r--r-- 2,764 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
 * lang_change.mod
 * ----------------
 * Squirrelspell module
 *
 * Copyright (c) 1999-2002 The SquirrelMail development team
 * Licensed under the GNU GPL. For full terms see the file COPYING.
 *
 * This module changes the international dictionaries selection
 * for the user. Called after LANG_SETUP module.                
 *
 * $Id: lang_change.mod,v 1.2 2002/01/31 03:00:55 graf25 Exp $
 *
 * @author Konstantin Riabitsev <icon@duke.edu> ($Author: graf25 $)
 * @version $Date: 2002/01/31 03:00:55 $
 */

global $use_langs, $lang_default, $SQSPELL_APP_DEFAULT;
$words = sqspell_getWords();
if (!$words) {
  $words = sqspell_makeDummy();
}
$langs = sqspell_getSettings($words);
if (sizeof($use_langs)){
  /**
   * See if the user clicked any options on the previous page.
   */
  if (sizeof($use_langs)>1){
    /**
     * See if s/he wants more than one dictionary.
     */
    if ($use_langs[0]!=$lang_default){
      /**
       * See if we need to juggle the order of the dictionaries
       * to make the default dictionary first in line.
       */
      if (in_array($lang_default, $use_langs)){
	/**
	 * See if the user was dumb and chose a default dictionary
	 * to be something other than the ones he selected.
	 */
	$hold = array_shift($use_langs);
	$lang_string = join(", ", $use_langs);
	$lang_string = str_replace("$lang_default", "$hold", $lang_string);
	$lang_string = $lang_default . ", " . $lang_string;
      } else {
	/** 
	 * Yes, he is dumb.
	 */
	$lang_string = join(', ', $use_langs);
      }
    } else {
      /**
       * No need to juggle the order -- preferred is already first.
       */
      $lang_string = join(', ', $use_langs);
    }
  } else {
    /**
     * Just one dictionary, please.
     */
    $lang_string = $use_langs[0];
  }
  $lang_array = explode( ',', $lang_string );
  $dsp_string = '';
  foreach( $lang_array as $a) {
    $dsp_string .= _(trim($a)) . ', ';
  }
  $dsp_string = substr( $dsp_string, 0, -2 );
  $msg = '<p>'
    . sprintf(_("Settings adjusted to: <strong>%s</strong> with <strong>%s</strong> as default dictionary."), $dsp_string, _($lang_default))
    . '</p>';
} else {
  /**
   * No dictionaries selected. Use system default.
   */
  $msg = '<p>'
    . sprintf(_("Using <strong>%s</strong> dictionary (system default) for spellcheck." ), $SQSPELL_APP_DEFAULT)
    . '</p>';
  $lang_string = $SQSPELL_APP_DEFAULT;
}
$old_lang_string = join(", ", $langs);
$words = str_replace("# LANG: $old_lang_string", "# LANG: $lang_string", 
		     $words);
/**
 * Write it down where the sun don't shine.
 */
sqspell_writeWords($words);
sqspell_makePage(_("International Dictionaries Preferences Updated"), 
		 null, $msg);

/**
 * For Emacs weenies:
 * Local variables:
 * mode: php
 * End:
 */
?>