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:


 * External links are automatically opened in a new browser window.


 * The server name "localhost" is translated to the current server. This is useful if your MediaWiki site can be addressed by different IP addresses or names, and you want to comfortably access other resources on the same webserver. The normal meaning of "localhost" (the machine where the client is running) would not have any sense on a MediaWiki page, anyway.


 * A link like mailto:test@test.org is shown as [mailto:test@test.org test@test.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 has bugs. In particular, it is not applied to the page preview.

Installation

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


 * Add the following line to your LocalSettings.php:


 * The search-and-replace patterns are stored in a static class member ExtPatchOutput::$mTable. 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.10, it should work on MediaWiki >= 1.6.0.

Change Log

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


 * 0.1 :
 * First version published.