| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\Nuke; |
| 4 |
|
| 5 |
use MediaWiki\Hook\ContributionsToolLinksHook; |
| 6 |
use MediaWiki\SpecialPage\SpecialPage; |
| 7 |
use MediaWiki\Title\Title; |
| 8 |
use Wikimedia\IPUtils; |
| 9 |
|
| 10 |
class Hooks implements ContributionsToolLinksHook { |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
public function onContributionsToolLinks( $id, Title $title, array &$tools, SpecialPage $specialPage ) { |
| 21 |
$username = $title->getText(); |
| 22 |
if ( $specialPage->getUser()->isAllowed( 'nuke' ) && !IPUtils::isValidRange( $username ) ) { |
| 23 |
$tools['nuke'] = $specialPage->getLinkRenderer()->makeKnownLink( |
| 24 |
SpecialPage::getTitleFor( 'Nuke' ), |
| 25 |
$specialPage->msg( 'nuke-linkoncontribs' )->text(), |
| 26 |
[ |
| 27 |
'title' => $specialPage->msg( 'nuke-linkoncontribs-text', $username )->text(), |
| 28 |
'class' => 'mw-contributions-link-nuke' |
| 29 |
], |
| 30 |
[ 'target' => $username ] |
| 31 |
); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public static function onRegisterTags( array &$tags ): bool { |
| 41 |
$tags[] = 'Nuke'; |
| 42 |
return true; |
| 43 |
} |
| 44 |
} |