Extension:RegexNamespaceContext

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
RegexNamespaceContext

Release status: beta

Implementation Page action
Description
Author(s) Jean-Lou Dupont
Version See SVN ($Id: RegexNamespaceContext.php 597 2007-08-06 23:54:28Z jeanlou.dupont $)
MediaWiki tested on 1.10 but probably works with a earlier versions
Download SVN
Hooks used

EditFormPreloadText
ParserAfterTidy
BeforePageDisplay

Contents

[edit] Purpose

Supports regex based 'edit form' text preloading and 'header'/'footer' wikitext pages insertion.

[edit] Features

  • Can load 'preload edit form' text based on a per-namespace regex 'context'
  • Can add 'headers' and 'footers' text pages based on a per-namespace regex 'context'
  • Creates a hook 'ContextPageParsingComplete'

[edit] Usage

On a per-namespace basis (only the ones required), edit the page 'Context' and place+customize the following:

== Preload Patterns ==
* Preloads '{{NAMESPACE}}:preloadPage' page upon '*.log' page name
* add other patterns below
{{#varaset:preloadPattern|{{NAMESPACE}}:preloadPage|(.*)\.log}}
...more patterns here...

=== Preload Generation ===
Do not modify the following:
{{#varaset:ContextVars|preloadPageName|
 {{#regx_vars:preloadPattern|{{#varaget:ContextVars|PageName}} }}
}}

== Header Patterns ==
* Header page for all pages in namespace following the '*.log' pattern
* add other patterns below
{{#varaset:headerPattern|{{NAMESPACE}}:LogHeaderPage|(.*)\.log}}
...more patterns here...

=== Header Generation ===
Do not modify the following:
{{#varaset:ContextVars|headerPageName|
 {{#regx_vars:headerPattern|{{#varaget:ContextVars|PageName}} }}
}}

== Footer Patterns ==
* Footer page for all pages in namespace following the '*.log' pattern
* add other patterns below
{{#varaset:footerPattern|{{NAMESPACE}}:LogFooterPage|(.*)\.log}}
...more patterns here...

=== Footer Generation ===
Do not modify the following:
{{#varaset:ContextVars|footerPageName|
 {{#regx_vars:footerPattern|{{#varaget:ContextVars|PageName}} }}
}}

[edit] Dependencies

[edit] Installation

To install independently from BizzWiki:

require('extensions/StubManager.php');
require('extensions/PageFunctions.php');
require('extensions/ParserCacheControl.php');
require('extensions/RegexTools.php');
StubManager::createStub('RegexNamespaceContext', 
                        $IP.'/extensions/RegexNamespaceContext/RegexNamespaceContext.php',
                        null,                                                  
                        array( 'EditFormPreloadText', 'ParserAfterTidy', 'BeforePageDisplay' ),
                        false
                        );

[edit] History

  • Used another parser instance instead of the global wgParser one: better integration with other extensions
  • Fixed major bug: needed to 'clone' the wgParser in order to keep all the hooks/parser functions etc.
  • Fixed 'skin' related bug: 'ParserAfterTidy' gets called during MediaWiki skin's string processing

[edit] See Also

This extension is part of the BizzWiki Platform.

Personal tools