Repository navigation
Expand file tree
/
Copy pathAppropediaNavigation.php
More file actions
52 lines (44 loc) · 1.65 KB
/
Copy pathAppropediaNavigation.php
File metadata and controls
52 lines (44 loc) · 1.65 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
46
47
48
49
50
51
52
<?php
use MediaWiki\MediaWikiServices;
use MediaWiki\Title\Title;
/**
* This class customizes the various navigation menus
*/
class AppropediaNavigation {
public static function onSkinTemplateNavigationUniversal( SkinTemplate $skinTemplate, array &$links ) {
// Add a link to the admin panel to the user menu of admins
$user = $skinTemplate->getUser();
$services = MediaWikiServices::getInstance();
$groupManager = $services->getUserGroupManager();
$groups = $groupManager->getUserGroups( $user );
if ( in_array( 'sysop', $groups ) ) {
$link = [
'href' => '/Appropedia:Admin_panel',
'text' => $skinTemplate->msg( 'appropedia-admin-panel' ),
'icon' => 'unStar'
];
array_splice( $links['user-menu'], 2, 0, [ $link ] );
}
}
/**
* Remove upload tool from the toolbox because tools should only refer to the current page
*/
public static function onSidebarBeforeOutput( Skin $skin, &$sidebar ) {
unset( $sidebar['TOOLBOX']['upload'] );
}
/**
* Add links to the footer
*/
public static function onSkinAddFooterLinks( Skin $skin, string $key, array &$footerlinks ) {
if ( $key === 'places' ) {
$services = MediaWikiServices::getInstance();
$linkRenderer = $services->getLinkRenderer();
$policiesTitle = Title::newFromText( 'Policies', NS_PROJECT );
$policiesText = $skin->msg( 'appropedia-policies' );
$footerlinks['policies'] = $linkRenderer->makePreloadedLink( $policiesTitle, $policiesText );
$contactTitle = Title::newFromText( 'Contact', NS_PROJECT );
$contactText = $skin->msg( 'appropedia-contact' );
$footerlinks['contact'] = $linkRenderer->makePreloadedLink( $contactTitle, $contactText );
}
}
}