mirror of
https://github.com/scratchfoundation/swiki-navbar.git
synced 2024-11-23 16:18:03 -05:00
62 lines
3 KiB
PHP
62 lines
3 KiB
PHP
<?php
|
|
/*
|
|
This extension for the Scratch wikis creates a different navigation bar for logged in and logged out users,
|
|
hiding links that are unnecessary or confusing from non-editors. Logged out users can see the link to the main page and
|
|
a link to a random page. Logged in users can also see a link to the community portal, the recent changes, and the help pages.
|
|
|
|
Code adapted from:
|
|
https://www.mediawiki.org/wiki/Manual:Interface/Sidebar#Advanced_customization
|
|
*/
|
|
|
|
$wgHooks['SkinBuildSidebar'][] = 'lfHideSidebar';
|
|
function lfHideSidebar( $skin, &$bar ) {
|
|
global $wgUser;
|
|
//make the navigation bar have a link to the main page and a random page for all users.
|
|
$bar = array(
|
|
'navigation' => array(
|
|
array(
|
|
'text' => Title::newFromText( wfMsgForContent( 'mainpage' ) ),
|
|
'href' => Title::newFromText( wfMsgForContent( 'mainpage' ) )->getFullURL(),
|
|
'id' => 'n-mainpage',
|
|
'active' => ''
|
|
),
|
|
array(
|
|
'text' => 'Random Page',
|
|
'href' => Title::newFromText( wfMsgForContent( 'randompage-url' ) )->getFullURL(),
|
|
'id' => 'n-randompage',
|
|
'active' => ''
|
|
)
|
|
)
|
|
);
|
|
|
|
//add Community Portal, Recent Changes, Help to the navigation bar if the user is logged it.
|
|
if ($wgUser->isLoggedIn() ) {
|
|
$bar['navigation'][] = array(
|
|
'text' => 'Community Portal',
|
|
'href' => Title::newFromText( wfMsgForContent( 'portal-url' ) )->getFullURL(),
|
|
'id' => 'n-portal',
|
|
'active' => ''
|
|
);
|
|
$bar['navigation'][] = array(
|
|
'text' => 'Current Events',
|
|
'href' => Title::newFromText( wfMsgForContent( 'currentevents-url' ) )->getFullURL(),
|
|
'id' => 'n-currentevents',
|
|
'active' => ''
|
|
);
|
|
$bar['navigation'][] = array(
|
|
'text' => 'Recent Changes',
|
|
'href' => Title::newFromText( wfMsgForContent( 'recentchanges-url' ) )->getFullURL(),
|
|
'id' => 'n-recentchanges',
|
|
'active' => '',
|
|
|
|
);
|
|
$bar['navigation'][] = array(
|
|
'text' => 'Help',
|
|
'href' => Title::newFromText( wfMsgForContent( 'helppage' ) )->getFullURL(),
|
|
'id' => 'n-help',
|
|
'active' => ''
|
|
);
|
|
|
|
}
|
|
return true;
|
|
}
|