Extension:ParserPhase2

Purpose
This extension enables performing a 'second pass' through a 'parser cached' page replacing for 'dynamic' variables. In a word, once a page is normally processed (i.e. 'first pass') Mediawiki 'fixes' all templates & variables in a 'parser cached' page. This extension enables substituting selected variables upon page view whilst still preserving the valuable job performed by the parser/parser cache.

Additionally, the extension enables the execution of 'parser functions' and 'magic words' *after* the page's 'tidy' process is executed. This functionality is referred to as 'parser after tidy'. This capability allows for the inclusion of text that would otherwise upset MediaWiki's parser e.g. execution of a parser functions that replaces text in an tagged section.

Theory of operation
In the standard MW processing flow, when a page is viewed it is retrieved (either from the cache or 'raw' from the database) and sent to the 'output page' object. What this extension does is intercept the flow process through the 'OutputPageBeforeHTML' hook and: This same process is performed for both 'parser phase 2' and 'parser after tidy' functionalities.
 * Extracts the  tags (and other supported invocation formats)
 * Looks for 'magic word' in the dictionary and retrieve the value if found
 * Looks for 'magic word' in the 'parser function' dictionary and execute the function if found

Features

 * Integrates with the standard Mediawiki Parser Cache
 * Provides a simple 'magic word' based interface to standard Mediawiki variables & parser functions
 * Handles two invocation forms for the 'parser phase 2' functionality:
 * Does not handle 'nested' magic words e.g. (($ magic word1 | (($magic word 2$)) $))
 * Handles one invocation for the 'parser after tidy' functionality:
 * Does not handle 'nested' magic words e.g. (($ magic word1 | (($magic word 2$)) $))
 * Handles one invocation for the 'parser after tidy' functionality:

ParserPhase2 functionality

 * Where 'variable' is a standard Mediawiki magic word e.g. CURRENTTIME, REVISIONID etc.

Dependancy

 * Extension:StubManager

Installation
To install outside the BizzWiki platform:
 * Download Extension:StubManager
 * Place 'StubManager.php' file in '/extensions' directory
 * Download the extension files from the SVN repository
 * Place the files in '/extensions/ScriptingTools' directory
 * Perform the following changes to 'LocalSettings.php':

History

 * fixed client side caching logic due to a bug in PHP's preg_match_all function
 * fixed issue with $wgParser not having a valid 'mTitle' property set
 * added 'disable' command
 * Removed dependency on 'ExtensionClass'
 * Added 'stub' capability
 * Added 'EndParserPhase2' hook
 * Added pattern: ((magic word|... )) which more closely maps to standard MW parser function calling
 * DO NOT MIX PATTERNS ON THE SAME PAGE i.e. no (($...$)) mixing up with ((...))
 * Added functionality to execute parser functions/magic words just after the 'tidy' process

TODO

 * possibly fix to allow mixing up (($..$)) and ((..)) patterns on the same page (TBD)