Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
Hooks | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
onContributionsToolLinks | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 |
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 | * Shows link to Special:Nuke on Special:Contributions/username if applicable |
14 | * |
15 | * @param int $id |
16 | * @param Title $title |
17 | * @param string[] &$tools |
18 | * @param SpecialPage $specialPage |
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 | } |