Convert InputBox.php to extension.json for extension registration

Bug: T87931
Change-Id: Ib3cd4714c842ebf17da5b1f0932fd886dbc65c66
This commit is contained in:
Florian 2015-04-26 01:56:22 +02:00 committed by Kunal Mehta
parent 7d55e876d4
commit d5dbe717b6
3 changed files with 65 additions and 104 deletions

View file

@ -1,35 +0,0 @@
<?php
/**
* This is a backwards-compatibility shim, generated by:
* https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
*
* Beginning with MediaWiki 1.23, translation strings are stored in json files,
* and the EXTENSION.i18n.php file only exists to provide compatibility with
* older releases of MediaWiki. For more information about this migration, see:
* https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
*
* This shim maintains compatibility back to MediaWiki 1.17.
*/
$messages = array();
if ( !function_exists( 'wfJsonI18nShim5f0a0d9bac62c1be' ) ) {
function wfJsonI18nShim5f0a0d9bac62c1be( $cache, $code, &$cachedData ) {
$codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] );
foreach ( $codeSequence as $csCode ) {
$fileName = dirname( __FILE__ ) . "/i18n/$csCode.json";
if ( is_readable( $fileName ) ) {
$data = FormatJson::decode( file_get_contents( $fileName ), true );
foreach ( array_keys( $data ) as $key ) {
if ( $key === '' || $key[0] === '@' ) {
unset( $data[$key] );
}
}
$cachedData['messages'] = array_merge( $data, $cachedData['messages'] );
}
$cachedData['deps'][] = new FileDependency( $fileName );
}
return true;
}
$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 'wfJsonI18nShim5f0a0d9bac62c1be';
}

View file

@ -1,71 +1,13 @@
<?php
/**
* InputBox extension
*
* @file
* @ingroup Extensions
*
* This file contains the main include file for the Inputbox extension of
* MediaWiki.
*
* Usage: Add the following line in LocalSettings.php:
* require_once( "$IP/extensions/InputBox/InputBox.php" );
*
* @author Erik Moeller <moeller@scireview.de>
* namespaces search improvements partially by
* Leonardo Pimenta <leo.lns@gmail.com>
* Cleaned up by Trevor Parscal <tparscal@wikimedia.org>
* @copyright Public domain
* @license Public domain
* @version 0.1.4
*/
// Check environment
if ( !defined( 'MEDIAWIKI' ) ) {
echo "This is an extension to the MediaWiki package and cannot be run standalone.\n";
die( -1 );
}
// Credits
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'InputBox',
'author' => array( 'Erik Moeller', 'Leonardo Pimenta', 'Rob Church', 'Trevor Parscal', 'DaSch' ),
'version' => '0.3.0',
'url' => 'https://www.mediawiki.org/wiki/Extension:InputBox',
'description' => 'Allow inclusion of predefined HTML forms.',
'descriptionmsg' => 'inputbox-desc',
);
// Internationalization
if ( function_exists( 'wfLoadExtension' ) ) {
wfLoadExtension( 'InputBox' );
// Keep i18n globals so mergeMessageFileList.php doesn't break
$wgMessagesDirs['InputBox'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['InputBox'] = __DIR__ . '/InputBox.i18n.php';
// Register auto load for the special page class
$wgAutoloadClasses['InputBoxHooks'] = __DIR__ . '/InputBox.hooks.php';
$wgAutoloadClasses['InputBox'] = __DIR__ . '/InputBox.classes.php';
// Register parser hook
$wgHooks['ParserFirstCallInit'][] = 'InputBoxHooks::register';
$wgHooks['MediaWikiPerformAction'][] = 'InputBoxHooks::onMediaWikiPerformAction';
$wgHooks['SpecialPageBeforeExecute'][] = 'InputBoxHooks::onSpecialPageBeforeExecute';
$resourcePaths = array(
'localBasePath' => __DIR__ . '/resources',
'remoteExtPath' => 'InputBox/resources'
);
$wgResourceModules['ext.inputBox.styles'] = $resourcePaths + array(
'position' => 'top',
'styles' => 'ext.inputBox.styles.css',
'targets' => array( 'mobile', 'desktop' ),
);
$wgResourceModules['ext.inputBox'] = $resourcePaths + array(
'scripts' => 'ext.inputBox.js',
'dependencies' => array(
'jquery.throttle-debounce'
)
);
unset( $resourcePaths );
/* wfWarn(
'Deprecated PHP entry point used for InputBox extension. Please use wfLoadExtension instead, ' .
'see https://www.mediawiki.org/wiki/Extension_registration for more details.'
); */
return;
} else {
die( 'This version of the InputBox extension requires MediaWiki 1.25+' );
}

54
extension.json Normal file
View file

@ -0,0 +1,54 @@
{
"name": "InputBox",
"version": "0.3.0",
"author": [
"Erik Moeller",
"Leonardo Pimenta",
"Rob Church",
"Trevor Parscal",
"DaSch"
],
"url": "https://www.mediawiki.org/wiki/Extension:InputBox",
"description": "Allow inclusion of predefined HTML forms.",
"descriptionmsg": "inputbox-desc",
"type": "parserhook",
"MessagesDirs": {
"InputBox": [
"i18n"
]
},
"AutoloadClasses": {
"InputBoxHooks": "InputBox.hooks.php",
"InputBox": "InputBox.classes.php"
},
"ResourceModules": {
"ext.inputBox.styles": {
"styles": "ext.inputBox.styles.css"
},
"ext.inputBox": {
"scripts": "ext.inputBox.js",
"dependencies": [
"jquery.throttle-debounce"
],
"targets": [
"mobile",
"desktop"
]
}
},
"ResourceFileModulePaths": {
"localBasePath": "resources",
"remoteExtPath": "InputBox/resources"
},
"Hooks": {
"ParserFirstCallInit": [
"InputBoxHooks::register"
],
"MediaWikiPerformAction": [
"InputBoxHooks::onMediaWikiPerformAction"
],
"SpecialPageBeforeExecute": [
"InputBoxHooks::onSpecialPageBeforeExecute"
]
}
}