mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Nuke
synced 2024-11-27 09:40:43 +00:00
a5e92ffbfd
Adds `tag-nuke` and `tag-nuke-description` messages for user in Special:Tags and changes the canonical tag name to "nuke" instead of "Nuke". Bug: T379168 Change-Id: Ic8846781cdac3bf08c6733f39d0cc5988fb09f6a
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Nuke;
|
|
|
|
use MediaWiki\Hook\ContributionsToolLinksHook;
|
|
use MediaWiki\SpecialPage\SpecialPage;
|
|
use MediaWiki\Title\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 ]
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Registers Nuke tag for deletion logs
|
|
*
|
|
* @param string[] &$tags
|
|
*/
|
|
public static function onRegisterTags( array &$tags ): bool {
|
|
$tags[] = 'nuke';
|
|
return true;
|
|
}
|
|
}
|