Use wmf geoip by default
Unlike freegeoip it also works with https Also moved the getCountryCode function to init, as it should be available regardless of whether we load the optional geoclient module. Bug: 40965 Change-Id: Ia18130890d09f86a93b5b61f7da7c48fcfa480c7
This commit is contained in:
committed by
Amir E. Aharoni
parent
7416740f95
commit
60242e2c53
@@ -68,7 +68,6 @@ $wgResourceModules['ext.uls.interface'] = array(
|
|||||||
'jquery.tipsy',
|
'jquery.tipsy',
|
||||||
'ext.uls.displaysettings',
|
'ext.uls.displaysettings',
|
||||||
'ext.uls.inputsettings',
|
'ext.uls.inputsettings',
|
||||||
'ext.uls.geoclient',
|
|
||||||
),
|
),
|
||||||
'position' => 'top',
|
'position' => 'top',
|
||||||
) + $resourcePaths;
|
) + $resourcePaths;
|
||||||
|
|||||||
@@ -41,9 +41,15 @@ class UniversalLanguageSelectorHooks {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function addModules( $out, $skin ) {
|
public static function addModules( $out, $skin ) {
|
||||||
|
global $wgULSGeoService;
|
||||||
|
|
||||||
// If extension is enabled, basic features(API, language data) available.
|
// If extension is enabled, basic features(API, language data) available.
|
||||||
$out->addModules( 'ext.uls.init' );
|
$out->addModules( 'ext.uls.init' );
|
||||||
$out->addModules( 'ext.uls.geoclient' );
|
|
||||||
|
if ( is_string( $wgULSGeoService ) ) {
|
||||||
|
$out->addModules( 'ext.uls.geoclient' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( self::isToolbarEnabled( $out->getUser() ) ) {
|
if ( self::isToolbarEnabled( $out->getUser() ) ) {
|
||||||
// Enable UI language selection for the user.
|
// Enable UI language selection for the user.
|
||||||
$out->addModules( 'ext.uls.interface' );
|
$out->addModules( 'ext.uls.interface' );
|
||||||
@@ -224,7 +230,9 @@ class UniversalLanguageSelectorHooks {
|
|||||||
$wgULSAnonCanChangeLanguage;
|
$wgULSAnonCanChangeLanguage;
|
||||||
|
|
||||||
// Place constant stuff here (not depending on request context)
|
// Place constant stuff here (not depending on request context)
|
||||||
$vars['wgULSGeoService'] = $wgULSGeoService;
|
if ( is_string( $wgULSGeoService ) ) {
|
||||||
|
$vars['wgULSGeoService'] = $wgULSGeoService;
|
||||||
|
}
|
||||||
$vars['wgULSIMEEnabled'] = $wgULSIMEEnabled;
|
$vars['wgULSIMEEnabled'] = $wgULSIMEEnabled;
|
||||||
$vars['wgULSPosition'] = $wgULSPosition;
|
$vars['wgULSPosition'] = $wgULSPosition;
|
||||||
$vars['wgULSAnonCanChangeLanguage'] = $wgULSAnonCanChangeLanguage;
|
$vars['wgULSAnonCanChangeLanguage'] = $wgULSAnonCanChangeLanguage;
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ $wgExtensionCredits['other'][] = array(
|
|||||||
* country the user is vising from. Setting this to false will prevent
|
* country the user is vising from. Setting this to false will prevent
|
||||||
* builtin geolocation from being used. You can provide your own geolocation
|
* builtin geolocation from being used. You can provide your own geolocation
|
||||||
* by setting window.Geo to object which has key 'country_code' or 'country'.
|
* by setting window.Geo to object which has key 'country_code' or 'country'.
|
||||||
* This is what Wikipedia does.
|
* If set to true, it will query Wikimedia's geoip service.
|
||||||
*
|
*
|
||||||
* The service should return jsonp that uses the supplied callback parameter.
|
* The service should return jsonp that uses the supplied callback parameter.
|
||||||
*/
|
*/
|
||||||
$wgULSGeoService = 'http://freegeoip.net/json/';
|
$wgULSGeoService = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable language selection, input methods and webfonts for everyone, unless
|
* Enable language selection, input methods and webfonts for everyone, unless
|
||||||
@@ -138,4 +138,17 @@ $wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'UniversalLanguageSelectorHooks
|
|||||||
$wgDefaultUserOptions['uls-preferences'] = '';
|
$wgDefaultUserOptions['uls-preferences'] = '';
|
||||||
$wgHooks['GetPreferences'][] = 'UniversalLanguageSelectorHooks::onGetPreferences';
|
$wgHooks['GetPreferences'][] = 'UniversalLanguageSelectorHooks::onGetPreferences';
|
||||||
|
|
||||||
|
$wgExtensionFunctions[] = function() {
|
||||||
|
global $wgHooks, $wgULSGeoService;
|
||||||
|
|
||||||
|
if ( $wgULSGeoService === true ) {
|
||||||
|
$wgHooks['BeforePageDisplay'][] = function( &$out ) {
|
||||||
|
$out->addScript( '<script src="//bits.wikimedia.org/geoiplookup"></script>' );
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
require( "$dir/Resources.php" );
|
require( "$dir/Resources.php" );
|
||||||
|
|||||||
@@ -25,10 +25,6 @@
|
|||||||
window.Geo = data;
|
window.Geo = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
mw.uls.getCountryCode = function () {
|
|
||||||
return window.Geo && ( window.Geo.country || window.Geo.country_code );
|
|
||||||
};
|
|
||||||
|
|
||||||
var currentProto, httpOnly, settings,
|
var currentProto, httpOnly, settings,
|
||||||
service = mw.config.get( 'wgULSGeoService' );
|
service = mw.config.get( 'wgULSGeoService' );
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,10 @@
|
|||||||
return ( window.navigator.language || window.navigator.userLanguage ).split( '-' )[0];
|
return ( window.navigator.language || window.navigator.userLanguage ).split( '-' )[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mw.uls.getCountryCode = function () {
|
||||||
|
return window.Geo && ( window.Geo.country || window.Geo.country_code );
|
||||||
|
};
|
||||||
|
|
||||||
mw.uls.getAcceptLanguageList = function () {
|
mw.uls.getAcceptLanguageList = function () {
|
||||||
return mw.config.get( 'wgULSAcceptLanguageList' );
|
return mw.config.get( 'wgULSAcceptLanguageList' );
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user