From 87333c0daa1b3e95b2fc16d2e2a98cbb60e460f4 Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Tue, 12 Jan 2010 19:45:49 +0000 Subject: [PATCH] * Show [edit] links for users with editinterface right only * While I am at it: Use Xml::/Html:: functions, commaList() and link() instead of deprecated functions --- SpecialGadgets.php | 47 +++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/SpecialGadgets.php b/SpecialGadgets.php index 2be7b93e..725592bc 100644 --- a/SpecialGadgets.php +++ b/SpecialGadgets.php @@ -50,54 +50,63 @@ class SpecialGadgets extends SpecialPage { $listOpen = false; $msgOpt = array( 'parseinline', 'parsemag' ); - + $editInterfaceAllowed = $wgUser->isAllowed( 'editinterface' ) ? true : false ; + foreach ( $gadgets as $section => $entries ) { if ( $section !== false && $section !== '' ) { $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-section-$section$lang" ); - $lnk = $t ? $skin->makeLinkObj( $t, wfMsgHTML("edit"), 'action=edit' ) : htmlspecialchars($section); + if ( $editInterfaceAllowed ) { + $lnkTarget = $t + ? $skin->link( $t, wfMsgHTML( 'edit' ), array(), array( 'action' => 'edit' ) ) + : htmlspecialchars( $section ); + $lnk = "    [$lnkTarget]"; + } else { + $lnk = ''; + } $ttext = wfMsgExt( "gadget-section-$section", $msgOpt ); if( $listOpen ) { - $wgOut->addHTML( '' ); + $wgOut->addHTML( Xml::closeElement( 'ul' ) . "\n" ); $listOpen = false; } - $wgOut->addHTML( "\n

$ttext     [$lnk]

\n" ); + $wgOut->addHTML( Html::rawElement( 'h2', array(), $ttext . $lnk ) . "\n" ); } foreach ( $entries as $gname => $code ) { $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-$gname$lang" ); if ( !$t ) continue; - $lnk = $skin->makeLinkObj( $t, wfMsgHTML("edit"), 'action=edit' ); + if ( $editInterfaceAllowed ) { + $lnkTarget = $skin->link( $t, wfMsgHTML( 'edit' ), array(), array( 'action' => 'edit' ) ); + $lnk = "    [$lnkTarget]"; + } else { + $lnk = ''; + } $ttext = wfMsgExt( "gadget-$gname", $msgOpt ); if( !$listOpen ) { $listOpen = true; - $wgOut->addHTML( '' ); + $wgOut->addHTML( Xml::closeElement( 'ul' ) . "\n" ); } } }