jenkins-bot has submitted this change and it was merged.

Change subject: Convert PageImages to extension registration
......................................................................


Convert PageImages to extension registration

Bug: T87953
Change-Id: Icc9096060899b9e401d53590f38865b0937a73ff
---
M PageImages.php
A extension.json
M includes/PageImages.php
3 files changed, 105 insertions(+), 110 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/PageImages.php b/PageImages.php
index 5888d0a..ce0ae8b 100644
--- a/PageImages.php
+++ b/PageImages.php
@@ -1,112 +1,13 @@
 <?php
-
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die;
+if ( function_exists( 'wfLoadExtension' ) ) {
+       wfLoadExtension( 'PageImages' );
+       // Keep i18n globals so mergeMessageFileList.php doesn't break
+       $wgMessagesDirs['PageImages'] = __DIR__ . '/i18n';
+       /*wfWarn(
+               'Deprecated PHP entry point used for PageImages extension. 
Please use wfLoadExtension instead, ' .
+               'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+       );*/
+       return;
+} else {
+       die( 'This version of the PageImages extension requires MediaWiki 
1.28+' );
 }
-
-define( 'PAGE_IMAGES_INSTALLED', true );
-
-$wgExtensionCredits['api'][] = array(
-       'path'           => __FILE__,
-       'name'           => 'PageImages',
-       'descriptionmsg' => 'pageimages-desc',
-       'author'         => 'Max Semenik',
-       'url'            => 
'https://www.mediawiki.org/wiki/Extension:PageImages',
-       'license-name'   => 'WTFPL',
-);
-
-$wgAutoloadClasses['ApiQueryPageImages'] = __DIR__ . 
'/includes/ApiQueryPageImages.php';
-$wgAutoloadClasses['PageImages'] = __DIR__ . '/includes/PageImages.php';
-$wgAutoloadClasses['PageImages\Hooks\LinksUpdateHookHandler']
-       = __DIR__ . '/includes/LinksUpdateHookHandler.php';
-$wgAutoloadClasses['PageImages\Hooks\ParserFileProcessingHookHandlers']
-       = __DIR__ . '/includes/ParserFileProcessingHookHandlers.php';
-
-$wgMessagesDirs['PageImages'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['PageImages'] = __DIR__ . "/PageImages.i18n.php";
-
-$wgHooks['ParserMakeImageParams'][]
-       = 
'PageImages\Hooks\ParserFileProcessingHookHandlers::onParserMakeImageParams';
-$wgHooks['LinksUpdate'][] = 
'PageImages\Hooks\LinksUpdateHookHandler::onLinksUpdate';
-$wgHooks['OpenSearchXml'][] = 'PageImages::onApiOpenSearchSuggest';
-$wgHooks['ApiOpenSearchSuggest'][] = 'PageImages::onApiOpenSearchSuggest';
-$wgHooks['InfoAction'][] = 'PageImages::onInfoAction';
-$wgHooks['AfterParserFetchFileAndTitle'][]
-       = 
'PageImages\Hooks\ParserFileProcessingHookHandlers::onAfterParserFetchFileAndTitle';
-$wgHooks['SpecialMobileEditWatchlist::images'][] = 
'PageImages::onSpecialMobileEditWatchlist_images';
-
-$wgHooks['UnitTestsList'][] = function( array &$paths ) {
-       $paths[] = __DIR__ . '/tests/phpunit';
-};
-
-$wgAPIPropModules['pageimages'] = 'ApiQueryPageImages';
-
-/**
- * Configures how various aspects of image affect its score
- */
-$wgPageImagesScores = array(
-       /** position of image in article */
-       'position' => array( 8, 6, 4, 3 ),
-       /** image width as shown on page */
-       'width' => array(
-               119 => -100, // Very small images are usually from maintenace 
or stub templates
-               400 => 10,
-               600 => 5, // Larger images are panoramas, less suitable
-               601 => 0,
-       ),
-       /** real width of a gallery image */
-       'galleryImageWidth' => array(
-               99 => -100,
-               100 => 0,
-       ),
-       /** width/height ratio, in tenths */
-       'ratio' => array(
-               3 => -100,
-               5 => 0,
-               20 => 5,
-               30 => 0,
-               31 => -100,
-       ),
-       'rights' => array(
-               'nonfree' => -100, // don't show nonfree images
-       ),
-);
-
-$wgPageImagesBlacklist = array(
-       array(
-               'type' => 'db',
-               'page' => 'MediaWiki:Pageimages-blacklist',
-               'db' => false, // current wiki
-       ),
-       /*
-       array(
-               'type' => 'db',
-               'page' => 'MediaWiki:Pageimages-blacklist',
-               'db' => 'commonswiki',
-       ),
-       array(
-               'type' => 'url',
-               'url' => 
'http://example.com/w/index.php?title=somepage&action=raw',
-       ),
-        */
-);
-
-/**
- * How long blacklist cache lives
- */
-$wgPageImagesBlacklistExpiry = 60 * 15;
-
-/**
- * Whether this extension's image information should be used by OpenSearch
- */
-$wgPageImagesExpandOpenSearchXml = false;
-
-/**
- * Collect data only for these namespaces
- */
-$wgPageImagesNamespaces = array( NS_MAIN );
-
-/**
- * If set to true, allows selecting images from galleries as page images
- */
-$wgPageImagesUseGalleries = false;
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..7c9bc0a
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,91 @@
+{
+       "name": "PageImages",
+       "author": "Max Semenik",
+       "url": "https://www.mediawiki.org/wiki/Extension:PageImages";,
+       "descriptionmsg": "pageimages-desc",
+       "license-name": "WTFPL",
+       "type": "api",
+       "callback": "PageImages::onRegistration",
+       "APIPropModules": {
+               "pageimages": "ApiQueryPageImages"
+       },
+       "MessagesDirs": {
+               "PageImages": [
+                       "i18n"
+               ]
+       },
+       "AutoloadClasses": {
+               "ApiQueryPageImages": "includes/ApiQueryPageImages.php",
+               "PageImages": "includes/PageImages.php",
+               "PageImages\\Hooks\\LinksUpdateHookHandler": 
"includes/LinksUpdateHookHandler.php",
+               "PageImages\\Hooks\\ParserFileProcessingHookHandlers": 
"includes/ParserFileProcessingHookHandlers.php"
+       },
+       "Hooks": {
+               "ParserMakeImageParams": 
"PageImages\\Hooks\\ParserFileProcessingHookHandlers::onParserMakeImageParams",
+               "LinksUpdate": 
"PageImages\\Hooks\\LinksUpdateHookHandler::onLinksUpdate",
+               "OpenSearchXml": "PageImages::onApiOpenSearchSuggest",
+               "ApiOpenSearchSuggest": "PageImages::onApiOpenSearchSuggest",
+               "InfoAction": "PageImages::onInfoAction",
+               "AfterParserFetchFileAndTitle": 
"PageImages\\Hooks\\ParserFileProcessingHookHandlers::onAfterParserFetchFileAndTitle",
+               "SpecialMobileEditWatchlist::images": 
"PageImages::onSpecialMobileEditWatchlist_images"
+       },
+       "config": {
+               "PageImagesScores": {
+                       "value": {
+                               "position": [
+                                       8,
+                                       6,
+                                       4,
+                                       3
+                               ],
+                               "width": {
+                                       "@doc119": "Very small images are 
usually from maintenace or stub templates",
+                                       "119": -100,
+                                       "400": 10,
+                                       "@doc600@": "Larger images are 
panoramas, less suitable",
+                                       "600": 5,
+                                       "601": 0
+                               },
+                               "galleryImageWidth": {
+                                       "99": -100,
+                                       "100": 0
+                               },
+                               "ratio": {
+                                       "3": -100,
+                                       "5": 0,
+                                       "20": 5,
+                                       "30": 0,
+                                       "31": -100
+                               },
+                               "rights": {
+                                       "@doc": "don't show nonfree images",
+                                       "nonfree": -100
+                               }
+                       }
+               },
+               "PageImagesBlacklist": {
+                       "value": [
+                               {
+                                       "type": "db",
+                                       "page": 
"MediaWiki:Pageimages-blacklist",
+                                       "db": false
+                               }
+                       ]
+               },
+               "PageImagesBlacklistExpiry": {
+                       "value": 900
+               },
+               "PageImagesExpandOpenSearchXml": {
+                       "value": false
+               },
+               "PageImagesNamespaces": {
+                       "value": [
+                               0
+                       ]
+               },
+               "PageImagesUseGalleries": {
+                       "value": false
+               }
+       },
+       "manifest_version": 2
+}
diff --git a/includes/PageImages.php b/includes/PageImages.php
index 67376fa..f652d6a 100644
--- a/includes/PageImages.php
+++ b/includes/PageImages.php
@@ -165,4 +165,7 @@
                }
        }
 
+       public static function onRegistration() {
+               define( 'PAGE_IMAGES_INSTALLED', true );
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/311184
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icc9096060899b9e401d53590f38865b0937a73ff
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/PageImages
Gerrit-Branch: master
Gerrit-Owner: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to