Index: trunk/extensions/Narayam/Narayam.hooks.php |
— | — | @@ -9,17 +9,13 @@ |
10 | 10 | |
11 | 11 | /// Hook: BeforePageDisplay |
12 | 12 | public static function addModules( $out, $skin ) { |
13 | | - if ( $out->getUser()->getOption( 'narayamDisable' ) ) { |
14 | | - return true; |
| 13 | + if ( $out->getUser()->getOption( 'narayamEnable' ) ) { |
| 14 | + $schemes = array_values( self::getSchemes () ); |
| 15 | + if ( count( $schemes ) ) { |
| 16 | + $out->addModules( $schemes ); |
| 17 | + $out->addModules( 'ext.narayam' ); |
| 18 | + } |
15 | 19 | } |
16 | | - |
17 | | - $schemes = array_values( self::getSchemes () ); |
18 | | - |
19 | | - if ( count( $schemes ) ) { |
20 | | - $out->addModules( $schemes ); |
21 | | - $out->addModules( 'ext.narayam' ); |
22 | | - } |
23 | | - |
24 | 20 | return true; |
25 | 21 | } |
26 | 22 | |
— | — | @@ -36,10 +32,6 @@ |
37 | 33 | public static function addVariables( &$vars ) { |
38 | 34 | global $wgUser, $wgNarayamSchemes, $wgNarayamUseBetaMapping; |
39 | 35 | |
40 | | - if ( $wgUser->getOption( 'narayamDisable' ) ) { |
41 | | - return true; |
42 | | - } |
43 | | - |
44 | 36 | $vars['wgNarayamAvailableSchemes'] = self::getSchemes(); // Note: scheme names must be keys, not values |
45 | 37 | $allSchemes = $wgNarayamSchemes; |
46 | 38 | foreach ( $allSchemes as $lang => $schemes ) { |
— | — | @@ -99,13 +91,24 @@ |
100 | 92 | /// Hook: GetPreferences |
101 | 93 | public static function addPreference( $user, &$preferences ) { |
102 | 94 | // A checkbox in preferences to disable Narayam |
103 | | - $preferences['narayamDisable'] = array( |
| 95 | + $preferences['narayamEnable'] = array( |
104 | 96 | 'type' => 'toggle', |
105 | | - 'label-message' => 'narayam-disable-preference', |
| 97 | + 'label-message' => 'narayam-enable-preference', |
106 | 98 | 'section' => 'editing/advancedediting', // under 'Advanced options' section of 'Editing' tab |
| 99 | + 'default' => $user->getOption( 'narayamEnable' ) |
107 | 100 | ); |
108 | 101 | |
109 | 102 | return true; |
110 | 103 | } |
111 | | - |
| 104 | + /** |
| 105 | + * UserGetDefaultOptions hook handler. |
| 106 | + * @param $defaultOptions array |
| 107 | + * @return bool |
| 108 | + */ |
| 109 | + public static function addDefaultOptions( &$defaultOptions ) { |
| 110 | + global $wgNarayamEnabledByDefault; |
| 111 | + // By default, the preference page option to enable Narayam is set to wgNarayamEnabledByDefault value. |
| 112 | + $defaultOptions['narayamEnable'] = $wgNarayamEnabledByDefault; |
| 113 | + return true; |
| 114 | + } |
112 | 115 | } |
Index: trunk/extensions/Narayam/Narayam.i18n.php |
— | — | @@ -17,11 +17,11 @@ |
18 | 18 | 'narayam-desc' => 'Allows to add custom input methods for input fields', |
19 | 19 | 'narayam-toggle-ime' => 'Enable ($1)', |
20 | 20 | 'narayam-menu' => 'Input Method', |
21 | | - 'narayam-menu-tooltip' => 'Control Narayam Input Method Editor (IME)', |
| 21 | + 'narayam-menu-tooltip' => 'Select an input method', |
22 | 22 | 'narayam-help' => 'Help', |
23 | 23 | 'narayam-help-page' => 'Help:Typing', |
24 | 24 | 'narayam-checkbox-tooltip' => 'To toggle input method on and off', // FIXME: better message |
25 | | - 'narayam-disable-preference' => 'Disable Narayam Input Method Editor (IME)', |
| 25 | + 'narayam-enable-preference' => 'Enable input method', |
26 | 26 | 'narayam-more-imes' => 'More input methods', |
27 | 27 | 'narayam-am' => 'Amharic Transliteration', |
28 | 28 | 'narayam-as' => 'Assamese Transliteration', |
— | — | @@ -1606,12 +1606,12 @@ |
1607 | 1607 | 'narayam-desc' => 'ഇൻപുട്ട് ഫീൽഡുകളിൽ ഇച്ഛാനുസരണമുള്ള ലിപികളിൽ എഴുതാനുള്ള സൗകര്യം കൂട്ടിച്ചേർക്കുന്നു', |
1608 | 1608 | 'narayam-toggle-ime' => 'സജീവമാക്കുക ($1)', |
1609 | 1609 | 'narayam-menu' => 'എഴുത്തുപകരണം', |
1610 | | - 'narayam-menu-tooltip' => 'നാരായം എഴുത്തുപകരണം (ഐ.എം.ഇ.) നിയന്ത്രിക്കുക', |
| 1610 | + 'narayam-menu-tooltip' => 'ഒരു എഴുത്തുരീതി തിരഞ്ഞെടുക്കുക', |
1611 | 1611 | 'narayam-help' => 'സഹായം', |
1612 | 1612 | 'narayam-help-page' => 'Help:എഴുത്ത്', |
1613 | 1613 | 'narayam-checkbox-tooltip' => 'എഴുത്തുപകരണം ഉപയോഗിക്കാനും ഒഴിവാക്കാനും ഇവിടെ ഞെക്കുക', |
1614 | | - 'narayam-disable-preference' => 'നാരായം എഴുത്തുപകരണം (IME) പ്രവർത്തനരഹിതമാക്കുക', |
1615 | | - 'narayam-more-imes' => 'കൂടുതൽ ലേഖന രീതികൾ', |
| 1614 | + 'narayam-enable-preference' => 'എഴുത്തുപകരണം ഉപയോഗിക്കുക', |
| 1615 | + 'narayam-more-imes' => 'കൂടുതൽ എഴുത്തുരീതികൾ', |
1616 | 1616 | 'narayam-am' => 'അംഹാറിക് ലിപ്യന്തരണം', |
1617 | 1617 | 'narayam-as' => 'ആസാമീസ് ലിപ്യന്തരണം', |
1618 | 1618 | 'narayam-as-avro' => 'ആസാമീസ് ആവ്റോ', |
Index: trunk/extensions/Narayam/Narayam.php |
— | — | @@ -168,10 +168,13 @@ |
169 | 169 | $wgHooks['ResourceLoaderGetConfigVars'][] = 'NarayamHooks::addConfig'; |
170 | 170 | $wgHooks['MakeGlobalVariablesScript'][] = 'NarayamHooks::addVariables'; |
171 | 171 | $wgHooks['GetPreferences'][] = 'NarayamHooks::addPreference'; |
| 172 | +$wgHooks['UserGetDefaultOptions'][] = 'NarayamHooks::addDefaultOptions'; |
172 | 173 | |
173 | 174 | // Autoloader |
174 | 175 | $wgAutoloadClasses['NarayamHooks'] = $dir . '/Narayam.hooks.php'; |
175 | 176 | |
| 177 | +$wgNarayamEnabledByDefault = true; |
| 178 | + |
176 | 179 | // ResourceLoader module registration |
177 | 180 | $narayamTpl = array( |
178 | 181 | 'localBasePath' => $dir, |