Mhutti1 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/258686

Change subject: Converted Petition to new extension registration system
......................................................................

Converted Petition to new extension registration system

Moved most of Petition.php to the new extension.json
and added method for backward compatable implementation
of the extension. Moved update function to SpecialPetition.php

Bug: T87958
Change-Id: If85dd702c147a25a301a66fbfb090d5901c0e24f
---
M Petition.php
M SpecialPetition.php
A extension.json
3 files changed, 84 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Petition 
refs/changes/86/258686/1

diff --git a/Petition.php b/Petition.php
index 9cc3640..600c331 100644
--- a/Petition.php
+++ b/Petition.php
@@ -1,56 +1,14 @@
 <?php
-// Petitions
-
-$wgExtensionCredits['other'][] = array(
-       'path'   => __FILE__,
-       'name'   => 'Petition',
-       'author' => array('Peter Coombe', 'Andrew Garrett'),
-       'url'    => 'https://www.mediawiki.org/wiki/Extension:Petition',
-       'descriptionmsg' => 'petition-desc',
-       'license-name' => 'GPL',
-);
-
-$wgResourceModules['ext.Petition'] = array(
-       'localBasePath' => __DIR__,
-       'remoteExtPath' => 'Petition',
-       'scripts'       => 'petition.js',
-       'styles'        => 'petition.css',
-       'dependencies'  => 'mediawiki.ui'
-);
-
-## Petition form
-$wgAutoloadClasses['SpecialPetition'] = __DIR__ . "/SpecialPetition.php";
-$wgSpecialPages['Petition'] = 'SpecialPetition';
-
-## Petition data download page
-$wgAutoloadClasses['SpecialPetitionData'] = __DIR__ . 
"/SpecialPetitionData.php";
-$wgSpecialPages['PetitionData'] = 'SpecialPetitionData';
-
-$wgMessagesDirs['Petition'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['PetitionDataAlias'] = __DIR__ . 
'/Petition.alias.php';
-
-$wgPetitionDatabase = false;
-
-$wgLogTypes[] = 'petition';
-$wgLogActionsHandlers['petition/sign'] = 'LogFormatter';
-
-$wgLogRestrictions['petition'] = 'view-petition-data';
-
-# Schema updates for update.php
-$wgHooks['LoadExtensionSchemaUpdates'][] = function( DatabaseUpdater $updater 
) {
-       $updater->addExtensionTable( 'petition_data', __DIR__ . '/table.sql', 
true );
-       return true;
-};
-
-$wgGroupPermissions['petitiondata']['view-petition-data'] = true;
-$wgAvailableRights[] = 'view-petition-data';
-
-/**
- * Options:
- *
- * $wgPetitionCountCacheTime
- *     time in seconds that the number of signatures count will be cached
- *     in memcached (if available). Default is 86400 i.e. 24 hours
- */
-
-$wgPetitionCountCacheTime = 86400;
+if ( function_exists( 'wfLoadExtension' ) ) {
+       wfLoadExtension( 'Petition' );
+       // Keep i18n globals so mergeMessageFileList.php doesn't break
+       $wgMessagesDirs['Petition'] = __DIR__ . '/i18n';
+       $wgExtensionMessagesFiles['PetitionAlias'] = __DIR__ . 
'/Petition.alias.php';
+       /*wfWarn(
+               'Deprecated PHP entry point used for Petition extension. Please 
use wfLoadExtension instead, ' .
+               'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+       );*/
+       return;
+} else {
+       die( 'This version of the Petition extension requires MediaWiki 1.25+' 
);
+}
\ No newline at end of file
diff --git a/SpecialPetition.php b/SpecialPetition.php
index da32998..dfe0611 100755
--- a/SpecialPetition.php
+++ b/SpecialPetition.php
@@ -130,6 +130,12 @@
                );
        }
 
+       # Schema updates for update.php
+       static function getUpdates(  DatabaseUpdater $updater ){
+               $updater->addExtensionTable( 'petition_data', __DIR__ . 
'/table.sql', true );
+               return true;
+       }
+
        /**
         * Retrieve the list of countries in given language via CLDR
         *
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..5ed18d1
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,65 @@
+{
+       "name": "Petition",
+       "author": [
+               "Peter Coombe",
+               "Andrew Garrett"
+       ],
+       "url": "https://www.mediawiki.org/wiki/Extension:Petition";,
+       "descriptionmsg": "petition-desc",
+       "license-name": "GPL",
+       "type": "other",
+       "GroupPermissions": {
+               "petitiondata": {
+                       "view-petition-data": true
+               }
+       },
+       "AvailableRights": [
+               "view-petition-data"
+       ],
+       "SpecialPages": {
+               "Petition": "SpecialPetition",
+               "PetitionData": "SpecialPetitionData"
+       },
+       "LogTypes": [
+               "petition"
+       ],
+       "LogRestrictions": {
+               "petition": "view-petition-data"
+       },
+       "LogActionsHandlers": {
+               "petition/sign": "LogFormatter"
+       },
+       "MessagesDirs": {
+               "Petition": [
+                       "i18n"
+               ]
+       },
+       "ExtensionMessagesFiles": {
+               "PetitionDataAlias": "Petition.alias.php"
+       },
+       "AutoloadClasses": {
+               "SpecialPetition": "SpecialPetition.php",
+               "SpecialPetitionData": "SpecialPetitionData.php"
+       },
+       "ResourceModules": {
+               "ext.Petition": {
+                       "scripts": "petition.js",
+                       "styles": "petition.css",
+                       "dependencies": "mediawiki.ui"
+               }
+       },
+       "ResourceFileModulePaths": {
+               "localBasePath": "",
+               "remoteExtPath": "Petition"
+       },
+       "Hooks": {
+               "LoadExtensionSchemaUpdates": [
+                       "SpecialPetition::getUpdates"
+               ]
+       },
+       "config": {
+               "PetitionDatabase": false,
+               "PetitionCountCacheTime": 86400
+       },
+       "manifest_version": 1
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If85dd702c147a25a301a66fbfb090d5901c0e24f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Petition
Gerrit-Branch: master
Gerrit-Owner: Mhutti1 <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to