2013-07-08 14:10:06 -04:00
< ? 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
*/
2013-07-11 15:09:34 -04:00
2013-07-08 14:10:06 -04:00
$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 (),
2013-07-17 15:28:27 -04:00
'id' => 'n-mainpage' ,
2013-07-08 14:10:06 -04:00
'active' => ''
),
array (
'text' => 'Random Page' ,
'href' => Title :: newFromText ( wfMsgForContent ( 'randompage-url' ) ) -> getFullURL (),
2013-07-17 15:28:27 -04:00
'id' => 'n-randompage' ,
2013-07-08 14:10:06 -04:00
'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 (),
2013-07-17 15:28:27 -04:00
'id' => 'n-portal' ,
2013-07-08 14:10:06 -04:00
'active' => ''
);
2013-07-12 11:14:55 -04:00
$bar [ 'navigation' ][] = array (
'text' => 'Current Events' ,
'href' => Title :: newFromText ( wfMsgForContent ( 'currentevents-url' ) ) -> getFullURL (),
2013-07-17 15:28:27 -04:00
'id' => 'n-currentevents' ,
2013-07-12 11:14:55 -04:00
'active' => ''
);
2013-07-08 14:10:06 -04:00
$bar [ 'navigation' ][] = array (
'text' => 'Recent Changes' ,
'href' => Title :: newFromText ( wfMsgForContent ( 'recentchanges-url' ) ) -> getFullURL (),
2013-07-17 15:28:27 -04:00
'id' => 'n-recentchanges' ,
'active' => '' ,
2013-07-08 14:10:06 -04:00
);
$bar [ 'navigation' ][] = array (
'text' => 'Help' ,
'href' => Title :: newFromText ( wfMsgForContent ( 'helppage' ) ) -> getFullURL (),
2013-07-17 15:28:27 -04:00
'id' => 'n-help' ,
2013-07-08 14:10:06 -04:00
'active' => ''
);
}
return true ;
}