Repository navigation
Expand file tree
/
Copy pathVectorMenuSidebar.class.php
More file actions
executable file
·45 lines (40 loc) · 2.71 KB
/
Copy pathVectorMenuSidebar.class.php
File metadata and controls
executable file
·45 lines (40 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
class VectorMenuSidebar {
public static function BeforePageDisplay( $out, $skin ) {
global $wgEnableVMSCustomStyle, $wgOut, $wgVectorMenuSidebar, $wgShowAfterMenuSidebar;//defined in LocalSettings.php
if ( $wgOut->getSkin()->getSkinName() === "vector" ) {
if ( $wgEnableVMSCustomStyle === true ){
$style = wfMessage( 'MenuSidebar.css' )->plain();
$out->addHeadItems( '<style type="text/css">'.$style.'</style>' );
} else {
$out->addHeadItems( '<link rel="stylesheet" type="text/css" href="/extensions/VectorMenuSidebar/resources/baseStyle.css">' );
}
if ( $wgVectorMenuSidebar === true ) {
$out->addHTML( '<div id="MenuSidebar" style="display:none">'. self::menuMessage( 'MenuSidebar', $skin->getSkinName() )->parse() . '<p id="vmsTB">' . wfMessage('toolbox')->plain() . '</p><ul id="MSToolbox"></ul>' );
if ( $wgShowAfterMenuSidebar === true ) {
$out->addHTML( '<div>' . wfMessage('MenuSidebarAfter')->parse() . '</div>' );
}
$out->addHTML( '</div>' );
$out->addHTML( '<script>window.addEventListener("DOMContentLoaded",(function(){document.querySelector("#MSToolbox").innerHTML=document.querySelector("#p-tb ul").innerHTML,document.querySelectorAll("#mw-panel > *:not(#p-logo)").forEach((function(e){return e.remove()}));for(var e=document.querySelectorAll("#MenuSidebar li>ul"),n=0;n<e.length;n++)e[n].parentElement.classList.add("child");e=document.querySelectorAll("#MenuSidebar > ul#MSToolbox > li");for(var o=0;o<e.length;o++)""===e[o].innerHTML&&e[o].parentNode.removeChild(e[o]);var r=document.querySelector("#MenuSidebar");r.setAttribute("style",""),document.querySelector("#mw-panel").appendChild(r)}));</script>' );
}
}
return true;
}
/**
* MediaWiki:<name>-<skin> when that page exists, MediaWiki:<name> otherwise.
*
* MediaWiki:MenuSidebar may be shared with another skin that renders it itself
* (Skin:Arknights does). The per-skin page lets this skin's copy differ without
* forking the whole menu: it can be a one-line transclusion of the shared page with
* a parameter, e.g. MediaWiki:MenuSidebar-vector = {{MediaWiki:MenuSidebar|vector=1}},
* and the shared page wraps what only this skin should show in {{#if:{{{vector|}}}|…}}
* (read directly, {{{vector|}}} is empty).
*/
private static function menuMessage( $name, $skinName ) {
$msg = wfMessage( $name . '-' . $skinName );
if ( $msg->exists() && !$msg->isDisabled() ) {
return $msg;
}
return wfMessage( $name );
}
}