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 '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

 * Enable/disable keywords for 'sectional execution' support
 * By default, replacement is 'enabled' until a 'disable' magic word is encountered
 * Execution is stopped (i.e. no replacement occurs) until an 'enable' magic word is next encountered
 * 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.

Nesting
Recursive invocation is supported; example:

Dependancy

 * StubManager extension

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 'strip' process i.e. before the parser really begins.
 * Added 'enable' magic word
 * Added support for 'sectional execution' i.e. replacement between 'enable' and 'disable' magic words
 * Added 'recursive' (aka 'nesting') processing functionality
 * Changed calls to $this->execute in order to remove PHP warning.

1.0.0

 * Moved to PEAR repository

TODO

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