Extension:ParserPhase2

<?php //((@disable@)) (($disable$)) ((%disable%)) /*

Purpose
This extension enables performing a 'second pass' through a 'parser cached' page replacing for 'dynamic' variabl. 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 'html' tagged section.

Finally, the extension enables the execution of 'parser functions' and 'magic words' *before* the page's 'strip' process is executed i.e. before the MediaWiki begins parsing the page. This functionality is referred to as 'parser before strip'.

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. See Extension:ParserPhase2/Flow Summary for more details.
 * 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:
 * Handles one invocation for the 'parser before strip' functionality:
 * Handles one invocation for the 'parser after tidy' functionality:
 * Handles one invocation for the 'parser before strip' functionality:
 * Handles one invocation for the 'parser before strip' functionality:

ParserPhase2 functionality

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

Dependancy

 * StubManager extension

Installation
To install independantly from BizzWiki:
 * Download & Install Extension:StubManager extension
 * Dowload all this extension's files and place in the desired directory
 * Apply the following changes to 'LocalSettings.php' after the statements of Extension:StubManager:

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
 * Added functionality to execute parser functions/magic words just BEFORE the 'stip' process i.e. before the parser really begins.

TODO

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