Extension:Logotipo

A quite simple example of a parser function: #logotipo: takes one parameter (a URL pointing to an image) and copies that value to $wgLogo.

Any special characters are removed from the input and caching of the individual page from which this function was invoked is disabled. The function then returns an empty string.

One example of this extension in use is: http://desciclopedia.org/wiki/Rede_Globo - that page jokingly replaces Desciclopédia's "batata" logo (a hollow potato) with a parody of Globo TV's network logo.

The extension code logotipo.php below must be stored as a file on the server, which is then invoked (using require_once) from LocalSettings.php:

logotipo.php
parser function to change the site logo ($wgLogo) on a per-page basis', );

// Register the parser function with the parser $wgHooks['ParserFirstCallInit'][] = 'wfLogotipoFunction_Setup';

$wgHooks['LanguageGetMagic'][] = 'wfLogotipoFunction_Magic';
 * 1) Add a hook to initialise as a MediaWiki magic word

function wfLogotipoFunction_Setup( &$parser ) { # Set a function hook associating the "logotipo" magic word with our function $parser->setFunctionHook( 'logotipo', 'wfLogotipoFunction_Render' ); return true; }
 * 1) Setup functions

function wfLogotipoFunction_Magic( &$magicWords, $langCode ) { # Add the magic word # The first array element is case sensitive, in this case it is not case sensitive # All remaining elements are synonyms for our parser function $magicWords['logotipo'] = array( 0, 'logotipo' ); # return true, otherwise other parser function extensions won't load. return true; }

function wfLogotipoFunction_Render( &$parser, $param1 = '' ) { global $wgLogo;
 * 1) The #logotipo: parser function itself
 * 2) This merely sets $wgLogo to a user-supplied URL, special characters removed,
 * 3) for the currently-displayed MediaWiki page.

# The parser function itself # The input parameter is a full URL of the desired logo for display, # which is simply copied into $wgLogo; any special characters are # removed and page caching is disabled for this one page.

$parser->disableCache; $wgLogo = htmlspecialchars( $param1 ); return ''; }