User:Seb35/modifyToolbox

A small code snippet to allow administrators to modify the toolbox through MediaWiki:Sidebar. For example, move the "Recent changes" from the navigation to the toolbox: * navigation ** mainpage|mainpage-description ** randompage-url|randompage ** helppage|help * SEARCH * TOOLBOX ** WHATLINKSHERE|whatlinkshere ** RECENTCHANGESLINKED|recentchangeslinked-toolbox ** recentchanges-url|recentchanges ** FEEDS|feeds ** CONTRIBUTIONS|contributions ** LOG|log ** BLOCKIP|blockip ** EMAILUSER|emailuser ** USERRIGHTS|userrights ** UPLOAD|upload ** SPECIALPAGES|specialpages ** PRINT|printableversion ** PERMALINK|permalink ** INFO|pageinfo-toolboxlink * LANGUAGES All possible keywords are written here, but this means they could be displayed on appropriate pages (e.g. BLOCKIP only on user pages) and they are always displayed. It is exactly the current behaviour.

A demo is (currently) available on http://wiki.seb35.fr/MediaWiki:Sidebar (you can walk on other pages to see how the items change).

Code
For now, this is only a code snippet. Perhaps it could evolve as an extension.

Note this code is not really beautiful, particularly the inner foreach, but I didn’t find another way to retrieve the exact content of "MediaWiki:Sidebar" (without reparsing it obviously), since only the URL is given in the $toolbox array. Possibly it would be possible to "invert" the URL function to get the title, but this is also a bit hacky. Another solution would be to modify the core (Skin::addToSidebarPlain) to add this information in the array, but this a very bad solution to locally change MW core (without changing the official codebase itself).