Extension:LinkTitles

What can this extension do?
The LinkTitles extension automatically adds links to page titles to the words of a page. Whenever a page is edited and saved, the extension will look if any existing page titles occur in the text, and automatically link to the corresponding pages. This will automatically cross-reference your wiki for you.

'''This extension is still in a very experimental phase as of May 2012. If it breaks your page content, revert the page back to its previous state by using 'View History'! Contact me if you have any questions/suggestions.'''

Usage
There is not much to do. Simply install the extension, and then edit a page. When you save the page, any existing page titles that occur on the page will be converted to MediaWiki links.

When the checkbox "This is a minor edit" is checked, the extension will not parse the page, in order to save time when you make frequent small edits to a page.

Parsing a page may be time consuming in larger wikis – I have no experience yet with it.

If it messes up your page
If the extension messes up your page, you can always revert back to a previous version. Just make sure to click the "This is a minor edit" checkbox at the bottom of the edit form. If this box is checked, the extension will leave your page content alone.

If only minor fixes are needed (e.g., links were inserted where you really don't want them), you can manually edit the page. Again, make sure to click the "Minor edit" checkbox before saving the page.

Download & Installation
To install this extension, download the archive and extract it to the extensions directory of your MediaWiki installation. Then, add the following to LocalSettings.php:

Configuration parameters
There are currently no configuration parameters.

Algorithm
The extension uses the following algorithm to convert words to links:
 * The extension is called whenever an ArticleSave event occurs.
 * It requests the page titles one by one from the mediawiki database.
 * If the working page title from the database is different from the current page title, a case-insensitive regular expression search and replace is performed to add ... to every occurrence of the title in the page content.
 * Return the converted page content.

Issues

 * The extension performs a case-insensitive regexp search. Therefore, brackets may be added to words that have incorrect capitalization, causing 'broken' wiki links to appear. You may want to create redirecting pages for these variants (to also handle different user inputs).
 * When a page title is the last word on the page, it will not get converted to a link.
 * When a page title contains special characters, they may be escaped in the regex properly, causing unexpected behavior.
 * Only the first occurrence of a page title will be converted; however, on each subsequent edit, the next occurrence will be converted.

Credits
Credits to Eugene at StackOverflow for help with the regular expression.