Aktionen

MediaWiki

Sidebar: Unterschied zwischen den Versionen

Aus Gemeinwohlwiki Braunschweig

Zeile 1: Zeile 1:
* Navigation
+
$wgHooks['BaseTemplateToolbox'][] = 'modifyToolbox';
** mainpage|mainpage-description
 
* Initiativen
 
** Kategorie:Alle Initiativen|Initiativen nach Namen
 
** Kategorie:Themen|Initiativen nach Themen
 
** Kategorie:Methoden|Initiativen nach Methoden
 
** Kategorie:Zielgruppen|Initiativen nach Zielgruppen
 
* Wissen
 
** Kategorie: Tipps & Erfahrungen|Tipps & Erfahrungen
 
** Kategorie: Kommunikationstools|Kommunikationstools
 
** Kategorie: Organisationstools|Organisationstools
 
* Ressourcen
 
** Ressourcenangebote|Ressourcenangebote
 
* Anleitungen
 
** Kategorie:Kopiervorlagen|Anleitungen und Kopiervorlagen
 
  
* navigation
+
function modifyToolbox( BaseTemplate $baseTemplate, array &$toolbox ) {
** mainpage|mainpage-description
+
 
** randompage-url|randompage
+
static $keywords = array( 'WHATLINKSHERE', 'RECENTCHANGESLINKED', 'FEEDS', 'CONTRIBUTIONS', 'LOG', 'BLOCKIP', 'EMAILUSER', 'USERRIGHTS', 'UPLOAD', 'SPECIALPAGES', 'PRINT', 'PERMALINK', 'INFO' );
** helppage|help
+
 
* SEARCH
+
$modifiedToolbox = array();
* TOOLBOX
+
 
** WHATLINKSHERE|whatlinkshere
+
// Walk in the MediaWiki:Sidebar message, section toolbox
** UPLOAD|upload
+
foreach ( $baseTemplate->data['sidebar']['TOOLBOX'] as $value ) {
** SPECIALPAGES|specialpages
+
$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;
 +
}

Version vom 12. Januar 2021, 08:42 Uhr

$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; }