Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
(back to plain) Tag: Replaced |
(this time the java works?) |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
+ | // 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; | ||
+ | } |
Revision as of 16:40, 14 January 2021
/* Any JavaScript here will be loaded for all users on every page load. */ // 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; }