2008-04-29 14:43:25 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Replace Text - a MediaWiki extension that provides a special page to
|
|
|
|
* allow administrators to do a global string find-and-replace on all the
|
|
|
|
* content pages of a wiki.
|
|
|
|
*
|
2016-03-10 13:26:21 +00:00
|
|
|
* https://www.mediawiki.org/wiki/Extension:Replace_Text
|
2008-04-29 14:43:25 +00:00
|
|
|
*
|
|
|
|
* The special page created is 'Special:ReplaceText', and it provides
|
|
|
|
* a form to do a global search-and-replace, with the changes to every
|
|
|
|
* page showing up as a wiki edit, with the administrator who performed
|
|
|
|
* the replacement as the user, and an edit summary that looks like
|
|
|
|
* "Text replace: 'search string' * to 'replacement string'".
|
|
|
|
*
|
|
|
|
* If the replacement string is blank, or is already found in the wiki,
|
|
|
|
* the page provides a warning prompt to the user before doing the
|
|
|
|
* replacement, since it is not easily reversible.
|
|
|
|
*/
|
|
|
|
|
2015-08-12 20:55:33 +00:00
|
|
|
if ( function_exists( 'wfLoadExtension' ) ) {
|
|
|
|
wfLoadExtension( 'ReplaceText' );
|
|
|
|
// Keep i18n globals so mergeMessageFileList.php doesn't break
|
|
|
|
$wgMessagesDirs['ReplaceText'] = __DIR__ . '/i18n';
|
2018-04-11 02:25:55 +00:00
|
|
|
$wgExtensionMessagesFiles['ReplaceTextAlias'] = __DIR__ . '/ReplaceText.i18n.alias.php';
|
2015-08-12 20:55:33 +00:00
|
|
|
/* wfWarn(
|
2016-05-30 21:35:28 +00:00
|
|
|
'Deprecated PHP entry point used for Replace Text extension. ' .
|
|
|
|
'Please use wfLoadExtension instead, ' .
|
|
|
|
'see https://www.mediawiki.org/wiki/Extension_registration for more details.'
|
2015-08-12 20:55:33 +00:00
|
|
|
); */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-30 21:35:28 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
|
|
|
die();
|
|
|
|
}
|
2008-04-29 14:43:25 +00:00
|
|
|
|
2018-04-03 17:02:47 +00:00
|
|
|
define( 'REPLACE_TEXT_VERSION', '1.4' );
|
2012-11-14 19:31:24 +00:00
|
|
|
|
2008-08-06 16:13:25 +00:00
|
|
|
// credits
|
2017-06-20 07:20:41 +00:00
|
|
|
$wgExtensionCredits['specialpage'][] = [
|
2009-04-27 03:15:19 +00:00
|
|
|
'path' => __FILE__,
|
2008-08-06 16:13:25 +00:00
|
|
|
'name' => 'Replace Text',
|
2012-11-14 19:31:24 +00:00
|
|
|
'version' => REPLACE_TEXT_VERSION,
|
2017-06-20 07:20:41 +00:00
|
|
|
'author' => [ 'Yaron Koren', 'Niklas Laxström', '...' ],
|
2011-12-13 23:49:33 +00:00
|
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:Replace_Text',
|
2016-03-10 13:26:21 +00:00
|
|
|
'descriptionmsg' => 'replacetext-desc',
|
2018-03-02 23:35:23 +00:00
|
|
|
'license-name' => 'GPL-2.0-or-later'
|
2017-06-20 07:20:41 +00:00
|
|
|
];
|
2008-08-06 16:13:25 +00:00
|
|
|
|
2014-03-27 10:59:35 +00:00
|
|
|
$wgMessagesDirs['ReplaceText'] = __DIR__ . '/i18n';
|
2018-04-11 02:25:55 +00:00
|
|
|
$wgExtensionMessagesFiles['ReplaceTextAlias'] = __DIR__ . '/ReplaceText.i18n.alias.php';
|
2008-05-12 20:34:19 +00:00
|
|
|
$wgJobClasses['replaceText'] = 'ReplaceTextJob';
|
2010-06-25 19:51:26 +00:00
|
|
|
|
|
|
|
// This extension uses its own permission type, 'replacetext'
|
2009-01-08 10:13:33 +00:00
|
|
|
$wgAvailableRights[] = 'replacetext';
|
2011-02-16 03:24:35 +00:00
|
|
|
$wgGroupPermissions['sysop']['replacetext'] = true;
|
2010-06-25 19:51:26 +00:00
|
|
|
|
2015-08-12 20:52:08 +00:00
|
|
|
$wgHooks['AdminLinks'][] = 'ReplaceTextHooks::addToAdminLinks';
|
2008-05-12 20:34:19 +00:00
|
|
|
|
2015-04-22 13:17:22 +00:00
|
|
|
$wgSpecialPages['ReplaceText'] = 'SpecialReplaceText';
|
2018-04-11 02:25:55 +00:00
|
|
|
$wgAutoloadClasses['ReplaceTextHooks'] = __DIR__ . '/src/ReplaceTextHooks.php';
|
|
|
|
$wgAutoloadClasses['SpecialReplaceText'] = __DIR__ . '/src/SpecialReplaceText.php';
|
|
|
|
$wgAutoloadClasses['ReplaceTextJob'] = __DIR__ . '/src/ReplaceTextJob.php';
|
|
|
|
$wgAutoloadClasses['ReplaceTextSearch'] = __DIR__ . '/src/ReplaceTextSearch.php';
|
|
|
|
|
|
|
|
$wgResourceModules['ext.ReplaceText'] = [
|
|
|
|
'scripts' => 'ext.ReplaceText.js',
|
|
|
|
'localBasePath' => 'resources',
|
|
|
|
'remoteExtPath' => 'ReplaceText/resources',
|
|
|
|
];
|
2016-05-31 19:22:31 +00:00
|
|
|
|
|
|
|
// Global variables
|
|
|
|
$wgReplaceTextUser = null;
|