Krinkle has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/345616 )
Change subject: Convert WikimediaBadges to extension registration
......................................................................
Convert WikimediaBadges to extension registration
Bug: T92980
Change-Id: Ib997c0906b9a4f3d6c33d09a5be67327e408157a
---
M WikimediaBadges.php
A extension.json
D resources/Resources.php
3 files changed, 52 insertions(+), 86 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/WikimediaBadges.php b/WikimediaBadges.php
index f75594d..4b78bf4 100644
--- a/WikimediaBadges.php
+++ b/WikimediaBadges.php
@@ -13,57 +13,15 @@
* @license GNU GPL v2+
*/
-if ( !defined( 'MEDIAWIKI' ) ) {
- die( 'Not an entry point.' );
-}
-
-if ( defined( 'WIKIMEDIA_BADGES_VERSION' ) ) {
- // Do not initialize more than once.
- return 1;
-}
-
-define( 'WIKIMEDIA_BADGES_VERSION', '0.1 alpha' );
-
-// This is the path to the autoloader generated by composer in case of a
composer install.
-if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
- require_once __DIR__ . '/vendor/autoload.php';
-}
-
-$GLOBALS['wgMessagesDirs']['WikimediaBadges'] = __DIR__ . '/i18n';
-
-/**
- * The Property id of the commons category property.
- * This is used to construct the link target for the other projects
- * sidebar link to Wikimedia Commons.
- *
- * Set this to null in order to disable the other projects
- * sidebar replacement.
- */
-$GLOBALS['wgWikimediaBadgesCommonsCategoryProperty'] = 'P373';
-
-$GLOBALS['wgExtensionFunctions'][] = function() {
- global $wgExtensionCredits, $wgHooks, $wgResourceModules;
-
- $wgExtensionCredits['wikibase'][] = array(
- 'path' => __FILE__,
- 'name' => 'WikimediaBadges',
- 'version' => WIKIMEDIA_BADGES_VERSION,
- 'author' => array( '[https://www.mediawiki.org/wiki/User:Bene*
Bene*]', 'Marius Hoch' ),
- 'url' => 'https://github.com/wmde/WikimediaBadges',
- 'descriptionmsg' => 'wikimediabadges-desc',
- 'license-name' => 'GPL-2.0+'
- );
-
- // Hooks
- $wgHooks['BeforePageDisplay'][] =
'WikimediaBadges\BeforePageDisplayHookHandler::onBeforePageDisplay';
- $wgHooks['WikibaseClientOtherProjectsSidebar'][] =
'WikimediaBadges\OtherProjectsSidebarHookHandler::addToSidebar';
-
- // Register phpunit tests
- $wgHooks['UnitTestsList'][] = function( array &$files ) {
- $files[] = __DIR__ . '/tests/phpunit';
- };
-
- // Resource Loader modules
- $wgResourceModules = array_merge( $wgResourceModules, include __DIR__ .
'/resources/Resources.php' );
-
-};
+if ( function_exists( 'wfLoadExtension' ) ) {
+ wfLoadExtension( 'WikimediaBadges', __DIR__ . '/extension.json' );
+ // Keep i18n globals so mergeMessageFileList.php doesn't break
+ $wgMessagesDirs['WikimediaBadges'] = __DIR__ . '/i18n';
+ /*wfWarn(
+ 'Deprecated PHP entry point used for WikimediaBadges extension.
Please use wfLoadExtension instead, ' .
+ 'see https://www.mediawiki.org/wiki/Extension_registration for
more details.'
+ );*/
+ return;
+} else {
+ die( 'This version of the WikimediaBadges extension requires MediaWiki
1.25+' );
+}
\ No newline at end of file
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..016ecde
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,40 @@
+{
+ "name": "WikimediaBadges",
+ "version": "0.1 alpha",
+ "author": [
+ "[https://www.mediawiki.org/wiki/User:Bene* Bene*]",
+ "Marius Hoch"
+ ],
+ "url": "https://github.com/wmde/WikimediaBadges",
+ "descriptionmsg": "wikimediabadges-desc",
+ "license-name": "GPL-2.0+",
+ "type": "wikibase",
+ "MessagesDirs": {
+ "WikimediaBadges": [
+ "i18n"
+ ]
+ },
+ "ResourceModules": {
+ "ext.wikimediaBadges": {
+ "position": "bottom",
+ "skinStyles": {
+ "vector": "skins/vector/wikimedia-badges.css",
+ "monobook":
"skins/monobook/wikimedia-badges.css",
+ "cologneblue":
"skins/cologneblue/wikimedia-badges.css",
+ "modern": "skins/modern/wikimedia-badges.css"
+ }
+ }
+ },
+ "ResourceFileModulePaths": {
+ "localBasePath": "resources",
+ "remoteExtPath": "WikimediaBadges/resources"
+ },
+ "Hooks": {
+ "BeforePageDisplay":
"WikimediaBadges\\BeforePageDisplayHookHandler::onBeforePageDisplay",
+ "WikibaseClientOtherProjectsSidebar":
"WikimediaBadges\\OtherProjectsSidebarHookHandler::addToSidebar"
+ },
+ "config": {
+ "WikimediaBadgesCommonsCategoryProperty": "P373"
+ },
+ "manifest_version": 1
+}
diff --git a/resources/Resources.php b/resources/Resources.php
deleted file mode 100644
index a55288a..0000000
--- a/resources/Resources.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-/**
- * WikimediaBadges ResourceLoader modules
- *
- * @since 0.1
- *
- * @licence GNU GPL v2+
- * @author Bene* < [email protected] >
- */
-
-return call_user_func( function() {
- $remoteExtPathParts = explode( DIRECTORY_SEPARATOR . 'extensions' .
DIRECTORY_SEPARATOR , __DIR__, 2 );
- $moduleTemplate = array(
- 'localBasePath' => __DIR__,
- 'remoteExtPath' => $remoteExtPathParts[1]
- );
-
- $modules = array(
- 'ext.wikimediaBadges' => $moduleTemplate + array(
- 'position' => 'bottom',
- 'skinStyles' => array(
- 'vector' => 'skins/vector/wikimedia-badges.css',
- 'monobook' =>
'skins/monobook/wikimedia-badges.css',
- 'cologneblue' =>
'skins/cologneblue/wikimedia-badges.css',
- 'modern' => 'skins/modern/wikimedia-badges.css',
- )
- )
- );
-
- return $modules;
-} );
--
To view, visit https://gerrit.wikimedia.org/r/345616
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib997c0906b9a4f3d6c33d09a5be67327e408157a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaBadges
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>
Gerrit-Reviewer: Bene <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits