From eb3a743cba7574dbe5310d8c4b5211301aac9130 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Mon, 2 Mar 2015 18:51:39 -0800 Subject: [PATCH] Add extension.json Bug: T87901 Change-Id: Iba8dccbf5ec5b303610c89bb82ff13d86dc5883a --- ContactPage.php | 6 ++++++ ContactPage_body.php | 10 ++++++++++ extension.json | 47 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 extension.json diff --git a/ContactPage.php b/ContactPage.php index ebbe44a..e2ae761 100644 --- a/ContactPage.php +++ b/ContactPage.php @@ -15,6 +15,11 @@ if( !defined( 'MEDIAWIKI' ) ) { die( 1 ); } +/** + * This PHP entry point is deprecated. Please use wfLoadExtension() and the extension.json file instead. + * See https://www.mediawiki.org/wiki/Manual:Extension_registration for more details. + */ + // Extension credits that will show up on Special:Version $wgExtensionCredits['specialpage'][] = array( 'path' => __FILE__, @@ -64,6 +69,7 @@ $wgContactConfig['default'] = array( // The name to be used with SenderEmail. // This will be shown in the recipient's email program + // Defaults to "Contact Form on $wgSitename" 'SenderName' => 'Contact Form on ' . $wgSitename, // If true, users will be required to supply a name and an email address diff --git a/ContactPage_body.php b/ContactPage_body.php index 492174a..3931395 100644 --- a/ContactPage_body.php +++ b/ContactPage_body.php @@ -15,6 +15,16 @@ * @ingroup SpecialPage */ class SpecialContact extends UnlistedSpecialPage { + + /** + * Set default value after registration + */ + public static function onRegistration() { + global $wgContactConfig, $wgSitename; + if ( $wgContactConfig['default']['SenderName'] === null ) { + $wgContactConfig['default']['SenderName'] = "Contact Form on $wgSitename"; + } + } /** * Constructor */ diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..cc3c58a --- /dev/null +++ b/extension.json @@ -0,0 +1,47 @@ +{ + "name": "ContactPage", + "version": 2.2, + "author": [ + "Daniel Kinzler", + "Sam Reed" + ], + "url": "https://www.mediawiki.org/wiki/Extension:ContactPage", + "descriptionmsg": "contactpage-desc", + "license-name": "GPL-2.0+", + "type": "specialpage", + "ExtensionMessagesFiles": { + "ContactPageAliases": "ContactPage.alias.php" + }, + "MessagesDirs": { + "ContactPage": [ + "i18n" + ] + }, + "config": { + "ContactConfig": { + "default": { + "RecipientUser": null, + "SenderEmail": null, + "SenderName": null, + "RequireDetails": false, + "IncludeIP": false, + "AdditionalFields": { + "Text": { + "label-message": "emailmessage", + "type": "textarea", + "rows": 20, + "cols": 80, + "required": true + } + } + } + } + }, + "callback": "SpecialContact::onRegistration", + "SpecialPages": { + "Contact": "SpecialContact" + }, + "AutoloadClasses": { + "SpecialContact": "ContactPage_body.php" + } +}