Extension:Replace Text

'''

Description
Replace Text is an extension to MediaWiki that provides a special page to allow administrators to do a global string find-and-replace on all the content pages of the wiki. The search is case-sensitive, and does not currently allow regular expressions. Talk pages and "MediaWiki:" pages are not modified; though pages in talk namespaces other than the main one (like "Template talk") are modified; this is a known bug.

By default, once an administrator enters a search string and its replacement, they are then shown a list of all the pages that contain that search string, with a checkbox for each, so that they can uncheck whichever pages they don't want replaced. The user then can hit "Replace" to do the actual replacement. Once a text replace is done, it is not directly undoable; though you can always run a "reverse" replace, replacing the new string with the original string. For that reason, if the replacement string is blank or is a string that already exists in the wiki, the user is first asked to confirm their action before being shown the list of possible pages, since this action will not be easily undoable.

If the search string is contained multiple times on a page, every such instance is replaced. Every page's replacements shows up as a wiki edit, with the administrator who performed the text replacement as the user who made the edit and an edit summary that looks like "Text replace: ' search string ' to ' replacement string '".

Code and download
You can download the Replace Text code in either one of these two compressed files:


 * replace_text_0.2.1.tar.gz
 * replace_text_0.2.1.zip

You can also download the code directly via SVN from the MediaWiki source code repository, at http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/ReplaceText/. From a command line, you can call the following:

To view the code online, including version history for each file, you can go here.

Installation
After you've obtained a 'ReplaceText' directory (either by extracting a compressed file or downloading via SVN), place this directory within the main MediaWiki 'extensions' directory. Then, in the file ' LocalSettings.php' in the main MediaWiki directory, add the following line somewhere below the calls for the Semantic MediaWiki extension (both the main 'include_once' line and the 'enableSemantics' line):

Author
Replace Text was written by Yaron Koren, reachable at yaron57 -at- gmail.com.

Version
Replace Text is currently at version 0.2.1.

The version history is:


 * 0.1 - April 29, 2008 - Initial version
 * 0.1.1 - May 7, 2008 - Language support added for Arabic, Dutch, French, Javanese, Malayalam, Norwegian Bokmål, Occitan, Portuguese, Serbian Cyrillic, Slovak, Swedish and Thai
 * 0.2 - May 12, 2008 - Replacement turned into two-step process, asking user to select among list of pages; actual replacement implemented as MediaWiki jobs; language support added for Traditional Chinese, Esperanto, Farsi, German, Khmer and Marathi
 * 0.2.1 - May 14, 2008 - Retrieval of matching pages done through SQL call, instead of manually; language support added for Bulgarian, Taiwanese Chinese and Luxembourgish

Screenshot
Below is an image of the page reached, after entering a target string and replacement string of "George F. Will" and "George Will", respectively, on Discourse DB. Hitting "Replace" would replace this value in all of these pages.



Code structure
The following are the files in the Replace Text extension:


 * README - description of the extension
 * ReplaceText.php - main file
 * ReplaceTextJob.php - class for the MediaWiki job that does the text replacement
 * ReplaceText.i18n.php - language file

Languages supported
Replace Text supports Arabic, Bulgarian, Taiwanese Chinese, Traditional Chinese, Dutch, English, Esperanto, Farsi, French, German, Javanese, Khmer, Luxembourgish, Malayalam, Marathi, Norwegian Bokmål, Occitan, Portuguese, Serbian Cyrillic, Slovak, Swedish and Thai.

Bugs and feature requests
Send any bug reports and requests to Yaron Koren, at yaron57 -at- gmail.com.

Contributing patches to the project
If you found some bug and fixed it, please create a patch by going to the "ReplaceText" directory, and typing:

svn diff >descriptivename.patch

Then send this patch, with a description, to Yaron Koren.

Translating
Translation of Replace Text is done through Betawiki. The translation for this extension can be found here. To add language values or change existing ones, you should create an account on Betawiki, then request permission from the administrators to translate a certain language or languages on this page (this is a very simple process). Once you have permission for a given language, you can log in and add or edit whatever messages you want to in that language.