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.
|
|
|
|
*
|
2009-01-08 05:48:38 +00:00
|
|
|
* http://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.
|
|
|
|
*/
|
|
|
|
|
2012-10-07 10:56:07 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) { die(); }
|
2008-04-29 14:43:25 +00:00
|
|
|
|
2013-04-08 15:12:47 +00:00
|
|
|
define( 'REPLACE_TEXT_VERSION', '0.9.7' );
|
2012-11-14 19:31:24 +00:00
|
|
|
|
2008-08-06 16:13:25 +00:00
|
|
|
// credits
|
|
|
|
$wgExtensionCredits['specialpage'][] = array(
|
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,
|
2009-04-27 08:52:10 +00:00
|
|
|
'author' => array( 'Yaron Koren', 'Niklas Laxström' ),
|
2011-12-13 23:49:33 +00:00
|
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:Replace_Text',
|
2008-08-06 16:13:25 +00:00
|
|
|
'descriptionmsg' => 'replacetext-desc',
|
|
|
|
);
|
|
|
|
|
2009-04-27 09:02:48 +00:00
|
|
|
$rtgIP = dirname( __FILE__ ) . '/';
|
2009-04-07 19:03:31 +00:00
|
|
|
$wgExtensionMessagesFiles['ReplaceText'] = $rtgIP . 'ReplaceText.i18n.php';
|
2011-12-25 23:09:26 +00:00
|
|
|
$wgExtensionMessagesFiles['ReplaceTextAlias'] = $rtgIP . 'ReplaceText.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
|
|
|
|
2009-05-19 15:23:48 +00:00
|
|
|
$wgHooks['AdminLinks'][] = 'rtAddToAdminLinks';
|
2008-05-12 20:34:19 +00:00
|
|
|
|
2009-01-08 10:13:33 +00:00
|
|
|
$wgSpecialPages['ReplaceText'] = 'ReplaceText';
|
2008-12-29 18:29:23 +00:00
|
|
|
$wgSpecialPageGroups['ReplaceText'] = 'wiki';
|
2009-04-07 19:03:31 +00:00
|
|
|
$wgAutoloadClasses['ReplaceText'] = $rtgIP . 'SpecialReplaceText.php';
|
|
|
|
$wgAutoloadClasses['ReplaceTextJob'] = $rtgIP . 'ReplaceTextJob.php';
|
2009-05-19 15:23:48 +00:00
|
|
|
|
2012-11-06 02:08:00 +00:00
|
|
|
/**
|
|
|
|
* This function should really go into a "ReplaceText_body.php" file.
|
|
|
|
*
|
|
|
|
* Handler for 'AdminLinks' hook in the AdminLinks extension
|
|
|
|
*
|
|
|
|
* @param $admin_links_tree ALTree
|
|
|
|
* @return bool
|
|
|
|
*/
|
2012-10-07 10:56:07 +00:00
|
|
|
function rtAddToAdminLinks( ALTree &$admin_links_tree ) {
|
|
|
|
$general_section = $admin_links_tree->getSection( wfMessage( 'adminlinks_general' )->text() );
|
2012-02-11 12:17:58 +00:00
|
|
|
$extensions_row = $general_section->getRow( 'extensions' );
|
|
|
|
|
2010-03-14 18:10:47 +00:00
|
|
|
if ( is_null( $extensions_row ) ) {
|
|
|
|
$extensions_row = new ALRow( 'extensions' );
|
|
|
|
$general_section->addRow( $extensions_row );
|
2009-05-19 15:23:48 +00:00
|
|
|
}
|
2012-02-11 12:17:58 +00:00
|
|
|
|
2010-03-14 18:10:47 +00:00
|
|
|
$extensions_row->addItem( ALItem::newFromSpecialPage( 'ReplaceText' ) );
|
2012-02-11 12:17:58 +00:00
|
|
|
|
2009-05-19 15:23:48 +00:00
|
|
|
return true;
|
|
|
|
}
|