MediaWiki:Sidebar: Difference between revisions

From ASA
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
// Licence WTFPL 2.0
$wgHooks['BaseTemplateToolbox'][] = 'modifyToolbox';
function modifyToolbox( BaseTemplate $baseTemplate, array &$toolbox ) {
static $keywords = array( 'WHATLINKSHERE', 'RECENTCHANGESLINKED', 'FEEDS', 'CONTRIBUTIONS', 'LOG', 'BLOCKIP', 'EMAILUSER', 'USERRIGHTS', 'UPLOAD', 'SPECIALPAGES', 'PRINT', 'PERMALINK', 'INFO' );
$modifiedToolbox = array();
// Walk in the MediaWiki:Sidebar message, section toolbox
foreach ( $baseTemplate->data['sidebar']['TOOLBOX'] as $value ) {
$specialLink = false;
// Search if the keyword exists
foreach ( $keywords as $key ) {
if ( $value['href'] == Title::newFromText($key)->fixSpecialName()->getLinkURL() ) {
$specialLink = true;
// This is a keyword, hence add this special link
if ( array_key_exists( strtolower($key), $toolbox ) ) {
$modifiedToolbox[strtolower($key)] = $toolbox[strtolower($key)];
break;
}
}
}
// This is a normal link
if ( !$specialLink ) {
$modifiedToolbox[] = $value;
}
}
$toolbox = $modifiedToolbox;
return true;
}
*empty section
*empty section
*navigation
*navigation
** mainpage|mainpage-description
** mainpage|mainpage-description
** helppage|help-mediawiki
** helppage|help-mediawiki

Revision as of 17:38, 10 February 2024

// Licence WTFPL 2.0 $wgHooks['BaseTemplateToolbox'][] = 'modifyToolbox';

function modifyToolbox( BaseTemplate $baseTemplate, array &$toolbox ) {

static $keywords = array( 'WHATLINKSHERE', 'RECENTCHANGESLINKED', 'FEEDS', 'CONTRIBUTIONS', 'LOG', 'BLOCKIP', 'EMAILUSER', 'USERRIGHTS', 'UPLOAD', 'SPECIALPAGES', 'PRINT', 'PERMALINK', 'INFO' );

$modifiedToolbox = array();

// Walk in the MediaWiki:Sidebar message, section toolbox foreach ( $baseTemplate->data['sidebar']['TOOLBOX'] as $value ) { $specialLink = false;

// Search if the keyword exists foreach ( $keywords as $key ) { if ( $value['href'] == Title::newFromText($key)->fixSpecialName()->getLinkURL() ) { $specialLink = true;

// This is a keyword, hence add this special link if ( array_key_exists( strtolower($key), $toolbox ) ) { $modifiedToolbox[strtolower($key)] = $toolbox[strtolower($key)]; break; } } }

// This is a normal link if ( !$specialLink ) { $modifiedToolbox[] = $value; } }

$toolbox = $modifiedToolbox;

return true; }


  • empty section
  • navigation
    • mainpage|mainpage-description
    • helppage|help-mediawiki