Extension:PatchOutput

Purpose
This extension applies some patches to the HTML code of a page before it is displayed. It can be seen as a demo for using the OutputPageBeforeHTML hook. You're likely to customize it for your needs.

The current version achieves the following:


 * A link like mailto:test@example.org is shown as [mailto:test@example.org test@example.org] (while the link behind is still a mailto: link).

Warnings

 * The result is achieved via crude string search-and-replace on the html code. The search patterns are likely to be subject to change in future MediaWiki versions.


 * As stated on OutputPageBeforeHTML#Warning, the hook may have bugs.

Installation

 * Save the to a file $IP/extensions/PatchOutput/PatchOutput.php.


 * Add the following line to your LocalSettings.php:


 * The search-and-replace patterns are stored in a global variable $wgPatchOutputTable. It contains an array where keys are the terms to search and values the corresponding replacements. You can redefine this array or add entries in your LocalSettings.php.

Even though this extension has been tested on MediaWiki 1.20, it should work on earlier versions as well.

Change Log

 * 0.21 :
 * Removed the replacement pair used to open links in a new browser windwo. This is now achieved better with the configuration parameter $wgExternalLinkTarget.
 * Removed the replacement pair used to translate "localhost" with the current server. It is better to use the magic word instead.
 * The code has been reviewed in order to comply better with the guidelines on mediawiki.org.


 * 0.2 :
 * The configuration parameter now a class member.


 * 0.1 :
 * First version published.