3 # Guard against direct invocation from the web, print a friendly help message
5 if ( !defined( 'MEDIAWIKI' ) ) {
8 <p>This is the Parser_function example extension. To enable it, put the
9 following in your LocalSettings.php:</p>
11 require_once( "\$IP/extensions/examples/Parser_function.php" );
17 # Define a setup function
18 $wgHooks['ParserFirstCallInit'][] = 'wfExampleParserFunction_Setup';
19 # Add a file to initialise the magic word
20 $dir = dirname(__FILE__
) . '/';
21 $wgExtensionMessagesFiles['Parser_functionMagic'] = $dir . 'Parser_function.i18n.magic.php';
23 function wfExampleParserFunction_Setup( $parser ) {
24 # Set a function hook associating the "example" magic word with our function
25 $parser->setFunctionHook( 'example', 'wfExampleParserFunction_Render' );
29 function wfExampleParserFunction_Render( &$parser, $param1 = '', $param2 = '' ) {
30 # The parser function itself
31 # The input parameters are wikitext with templates expanded
32 # The output should be wikitext too
33 return "param1 is $param1 and param2 is $param2";