Remove MW 1.34 backward compatible code
Move hooks and scripts to extensions.json Bug: T282783 Change-Id: Id63d17d04789bb36fff35e0512e7878dc8bfe12c
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
"descriptionmsg": "uls-desc",
|
"descriptionmsg": "uls-desc",
|
||||||
"license-name": "GPL-2.0-or-later OR MIT",
|
"license-name": "GPL-2.0-or-later OR MIT",
|
||||||
"requires": {
|
"requires": {
|
||||||
"MediaWiki": ">= 1.34.0"
|
"MediaWiki": ">= 1.35.0"
|
||||||
},
|
},
|
||||||
"Hooks": {
|
"Hooks": {
|
||||||
"BeforePageDisplay": "UniversalLanguageSelectorHooks::addModules",
|
"BeforePageDisplay": "UniversalLanguageSelectorHooks::addModules",
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"MakeGlobalVariablesScript": "UniversalLanguageSelectorHooks::addVariables",
|
"MakeGlobalVariablesScript": "UniversalLanguageSelectorHooks::addVariables",
|
||||||
"PersonalUrls": "UniversalLanguageSelectorHooks::addPersonalBarTrigger",
|
"PersonalUrls": "UniversalLanguageSelectorHooks::addPersonalBarTrigger",
|
||||||
"ResourceLoaderGetConfigVars": "UniversalLanguageSelectorHooks::addConfig",
|
"ResourceLoaderGetConfigVars": "UniversalLanguageSelectorHooks::addConfig",
|
||||||
"ResourceLoaderRegisterModules": "UniversalLanguageSelectorHooks::onResourceLoaderRegisterModules",
|
"SkinAfterPortlet": "UniversalLanguageSelectorHooks::onSkinAfterPortlet",
|
||||||
"UserGetLanguageObject": "UniversalLanguageSelectorHooks::getLanguage"
|
"UserGetLanguageObject": "UniversalLanguageSelectorHooks::getLanguage"
|
||||||
},
|
},
|
||||||
"APIModules": {
|
"APIModules": {
|
||||||
@@ -171,6 +171,21 @@
|
|||||||
"localBasePath": "resources",
|
"localBasePath": "resources",
|
||||||
"remoteExtPath": "UniversalLanguageSelector/resources"
|
"remoteExtPath": "UniversalLanguageSelector/resources"
|
||||||
},
|
},
|
||||||
|
"ext.uls.ime": {
|
||||||
|
"localBasePath": "resources",
|
||||||
|
"scripts": "js/ext.uls.ime.js",
|
||||||
|
"dependencies": [
|
||||||
|
"ext.uls.common",
|
||||||
|
"ext.uls.preferences",
|
||||||
|
"ext.uls.mediawiki",
|
||||||
|
"ext.uls.messages",
|
||||||
|
"jquery.ime"
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
"uls-ime-helppage"
|
||||||
|
],
|
||||||
|
"remoteExtPath": "UniversalLanguageSelector/resources"
|
||||||
|
},
|
||||||
"ext.uls.displaysettings": {
|
"ext.uls.displaysettings": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"js/ext.uls.inputsettings.js",
|
"js/ext.uls.inputsettings.js",
|
||||||
@@ -311,6 +326,32 @@
|
|||||||
},
|
},
|
||||||
"remoteExtPath": "UniversalLanguageSelector/resources"
|
"remoteExtPath": "UniversalLanguageSelector/resources"
|
||||||
},
|
},
|
||||||
|
"ext.uls.setlang": {
|
||||||
|
"localBasePath": "resources",
|
||||||
|
"styles": [
|
||||||
|
"css/ext.uls.dialog.less",
|
||||||
|
"css/ext.uls.setlang.less"
|
||||||
|
],
|
||||||
|
"scripts": [
|
||||||
|
"js/ext.uls.dialog.js",
|
||||||
|
"js/ext.uls.setlang.js"
|
||||||
|
],
|
||||||
|
"dependencies": [
|
||||||
|
"mediawiki.api",
|
||||||
|
"mediawiki.ui.button",
|
||||||
|
"mediawiki.Uri"
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
"ext-uls-setlang-error",
|
||||||
|
"ext-uls-setlang-unknown-error",
|
||||||
|
"ext-uls-setlang-heading",
|
||||||
|
"ext-uls-setlang-message",
|
||||||
|
"ext-uls-setlang-accept",
|
||||||
|
"ext-uls-setlang-cancel",
|
||||||
|
"ext-uls-setlang-loading"
|
||||||
|
],
|
||||||
|
"remoteExtPath": "UniversalLanguageSelector/resources"
|
||||||
|
},
|
||||||
"ext.uls.webfonts": {
|
"ext.uls.webfonts": {
|
||||||
"targets": [ "desktop", "mobile" ],
|
"targets": [ "desktop", "mobile" ],
|
||||||
"scripts": "js/ext.uls.webfonts.js",
|
"scripts": "js/ext.uls.webfonts.js",
|
||||||
|
|||||||
@@ -26,15 +26,7 @@ class UniversalLanguageSelectorHooks {
|
|||||||
* Used when extension registration in use which skips the main php file
|
* Used when extension registration in use which skips the main php file
|
||||||
*/
|
*/
|
||||||
public static function setVersionConstant() {
|
public static function setVersionConstant() {
|
||||||
global $wgHooks;
|
|
||||||
define( 'ULS_VERSION', '2020-07-20' );
|
define( 'ULS_VERSION', '2020-07-20' );
|
||||||
// The SkinAfterPortlet hook was introduced in version >= 1.35.
|
|
||||||
// It is the same as BaseTemplateAfterPortlet with the exception of its parameters.
|
|
||||||
if ( interface_exists( MediaWiki\Skins\Hook\SkinAfterPortletHook::class ) ) {
|
|
||||||
$wgHooks['SkinAfterPortlet'][] = "UniversalLanguageSelectorHooks::onSkinAfterPortlet";
|
|
||||||
} else {
|
|
||||||
$wgHooks['BaseTemplateAfterPortlet'][] = "UniversalLanguageSelectorHooks::onBaseTemplateAfterPortlet";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,14 +77,8 @@ class UniversalLanguageSelectorHooks {
|
|||||||
if ( $wgULSCompactLanguageLinksBetaFeature === false ) {
|
if ( $wgULSCompactLanguageLinksBetaFeature === false ) {
|
||||||
// Compact language links is a default feature in this wiki.
|
// Compact language links is a default feature in this wiki.
|
||||||
// Check user preference
|
// Check user preference
|
||||||
$services = MediaWikiServices::getInstance();
|
return MediaWikiServices::getInstance()->getUserOptionsLookup()
|
||||||
if ( method_exists( $services, 'getUserOptionsLookup' ) ) {
|
|
||||||
// MW 1.35 +
|
|
||||||
return $services->getUserOptionsLookup()
|
|
||||||
->getBoolOption( $user, 'compact-language-links' );
|
->getBoolOption( $user, 'compact-language-links' );
|
||||||
} else {
|
|
||||||
return $user->getBoolOption( 'compact-language-links' );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -178,63 +164,6 @@ class UniversalLanguageSelectorHooks {
|
|||||||
$out->addModules( 'ext.uls.setlang' );
|
$out->addModules( 'ext.uls.setlang' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ResourceLoader $resourceLoader
|
|
||||||
*/
|
|
||||||
public static function onResourceLoaderRegisterModules( ResourceLoader $resourceLoader ) {
|
|
||||||
global $wgVersion;
|
|
||||||
|
|
||||||
// Support: MediaWiki 1.34
|
|
||||||
$hasOldNotify = version_compare( $wgVersion, '1.35', '<' );
|
|
||||||
|
|
||||||
$tpl = [
|
|
||||||
'localBasePath' => dirname( __DIR__ ) . '/resources',
|
|
||||||
'remoteExtPath' => 'UniversalLanguageSelector/resources',
|
|
||||||
];
|
|
||||||
|
|
||||||
$modules = [
|
|
||||||
"ext.uls.ime" => $tpl + [
|
|
||||||
"scripts" => "js/ext.uls.ime.js",
|
|
||||||
"dependencies" => array_merge( [
|
|
||||||
"ext.uls.common",
|
|
||||||
"ext.uls.preferences",
|
|
||||||
"ext.uls.mediawiki",
|
|
||||||
"ext.uls.messages",
|
|
||||||
"jquery.ime",
|
|
||||||
], $hasOldNotify ? [ 'mediawiki.notify' ] : [] ),
|
|
||||||
"messages" => [
|
|
||||||
"uls-ime-helppage"
|
|
||||||
],
|
|
||||||
],
|
|
||||||
"ext.uls.setlang" => $tpl + [
|
|
||||||
"styles" => [
|
|
||||||
"css/ext.uls.dialog.less",
|
|
||||||
"css/ext.uls.setlang.less"
|
|
||||||
],
|
|
||||||
"scripts" => [
|
|
||||||
"js/ext.uls.dialog.js",
|
|
||||||
"js/ext.uls.setlang.js"
|
|
||||||
],
|
|
||||||
"dependencies" => array_merge( [
|
|
||||||
"mediawiki.api",
|
|
||||||
"mediawiki.ui.button",
|
|
||||||
"mediawiki.Uri"
|
|
||||||
], $hasOldNotify ? [ 'mediawiki.notify' ] : [] ),
|
|
||||||
"messages" => [
|
|
||||||
"ext-uls-setlang-error",
|
|
||||||
"ext-uls-setlang-unknown-error",
|
|
||||||
"ext-uls-setlang-heading",
|
|
||||||
"ext-uls-setlang-message",
|
|
||||||
"ext-uls-setlang-accept",
|
|
||||||
"ext-uls-setlang-cancel",
|
|
||||||
"ext-uls-setlang-loading"
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$resourceLoader->register( $modules );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add some tabs for navigation for users who do not use Ajax interface.
|
* Add some tabs for navigation for users who do not use Ajax interface.
|
||||||
* Hook: PersonalUrls
|
* Hook: PersonalUrls
|
||||||
@@ -494,34 +423,6 @@ class UniversalLanguageSelectorHooks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Kept for backward compatability with MW < 1.35, and older versions of skins
|
|
||||||
* such as Vector and Timeless
|
|
||||||
* @param QuickTemplate $template
|
|
||||||
* @param string $name
|
|
||||||
* @param string &$content
|
|
||||||
*/
|
|
||||||
public static function onBaseTemplateAfterPortlet(
|
|
||||||
QuickTemplate $template,
|
|
||||||
string $name,
|
|
||||||
string &$content
|
|
||||||
) {
|
|
||||||
global $wgULSPosition;
|
|
||||||
|
|
||||||
if ( $wgULSPosition !== 'interlanguage' ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !self::isToolbarEnabled( $template->getSkin()->getUser() ) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set to an empty array, just to make sure that the section appears
|
|
||||||
if ( $template->get( 'language_urls' ) === false ) {
|
|
||||||
$template->set( 'language_urls', [] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Skin $skin
|
* @param Skin $skin
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
|||||||
Reference in New Issue
Block a user