Mediawiki Plugin

I've been playing with mediawiki a lot recently, and ended up having to roll a quick plugin. There seems to be a bit of interest around this, so here it is. It adds a back to top link next to each edit link on the page...not very complicated. This should be deprecated in the latest versions, as it has a hook already for changing the contents of the edit link section, so that would be cleaner...
Add the following code in a file in the extensions directory, then you need to include that from the LocalSettings.php file. Oh, and an FYI; mediawiki seems very sensitive to added whitespace lines at the end of its included files.

<?php
if( !defined( 'MEDIAWIKI' ) ) {
die( "This file is part of MediaWiki and is not a valid entry point\n" );
}
#install extension hook
$wgExtensionFunctions[] = "addtoplink";

$wgExtensionCredits['addtoplink'][]= array(
'name' => 'addtoplink',
'version' => '1.0.0',
'author' => 'Felix Cohen',
'url' => 'http://www.opendemocracy.net',
'description' => 'Add back to top links next to edit links');

function addtoplink () {
global $wgOut;
$wgOut->addScript(
"\n"."addOnloadHook(function ()
{
addTopArray = document.getElementsByTagName('span');
for (addTopCntr=0;addTopCntr [top] \";
}
}
})"."\n");
return;
}
?>

Comments

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
Sorry, but I hate spam, so please just fill it in...
3 + 13 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Back to top