mediawiki-extensions-Nuke/includes/Hooks.php
TerraCodes 029111351c Add class to nuke contribs link
Continuation of MW core patch 603941

Change-Id: I3ae1aeddbd0c00ffecf7b8b8115cf161b0e15202
2022-06-17 18:53:57 +00:00

35 lines
981 B
PHP

<?php
namespace MediaWiki\Extension\Nuke;
use MediaWiki\Hook\ContributionsToolLinksHook;
use SpecialPage;
use Title;
use Wikimedia\IPUtils;
class Hooks implements ContributionsToolLinksHook {
/**
* Shows link to Special:Nuke on Special:Contributions/username if applicable
*
* @param int $id
* @param Title $title
* @param string[] &$tools
* @param SpecialPage $specialPage
*/
public function onContributionsToolLinks( $id, Title $title, array &$tools, SpecialPage $specialPage ) {
$username = $title->getText();
if ( $specialPage->getUser()->isAllowed( 'nuke' ) && !IPUtils::isValidRange( $username ) ) {
$tools['nuke'] = $specialPage->getLinkRenderer()->makeKnownLink(
SpecialPage::getTitleFor( 'Nuke' ),
$specialPage->msg( 'nuke-linkoncontribs' )->text(),
[
'title' => $specialPage->msg( 'nuke-linkoncontribs-text', $username )->text(),
'class' => 'mw-contributions-link-nuke'
],
[ 'target' => $username ]
);
}
}
}