mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Nuke
synced 2024-11-24 00:05:33 +00:00
Use the new Hook system
Bug: T271020 Change-Id: Icd15d5f483dd0e73cedf5604ec27e42c8f7e341d
This commit is contained in:
parent
3aba8fd035
commit
df1cd09150
|
@ -19,8 +19,13 @@
|
|||
"i18n"
|
||||
]
|
||||
},
|
||||
"HookHandlers": {
|
||||
"main": {
|
||||
"class": "MediaWiki\\Extension\\Nuke\\Hooks"
|
||||
}
|
||||
},
|
||||
"Hooks": {
|
||||
"ContributionsToolLinks": "MediaWiki\\Extension\\Nuke\\Hooks::nukeContributionsLinks"
|
||||
"ContributionsToolLinks": "main"
|
||||
},
|
||||
"ResourceModules": {
|
||||
"ext.nuke.confirm": {
|
||||
|
|
|
@ -2,29 +2,28 @@
|
|||
|
||||
namespace MediaWiki\Extension\Nuke;
|
||||
|
||||
use MediaWiki\Hook\ContributionsToolLinksHook;
|
||||
use SpecialPage;
|
||||
use Title;
|
||||
use Wikimedia\IPUtils;
|
||||
|
||||
class Hooks {
|
||||
class Hooks implements ContributionsToolLinksHook {
|
||||
|
||||
/**
|
||||
* Shows link to Special:Nuke on Special:Contributions/username if applicable
|
||||
*
|
||||
* @param int $userId
|
||||
* @param Title $userPageTitle
|
||||
* @param string[] &$toolLinks
|
||||
* @param SpecialPage $sp
|
||||
* @param int $id
|
||||
* @param Title $title
|
||||
* @param string[] &$tools
|
||||
* @param SpecialPage $specialPage
|
||||
*/
|
||||
public static function nukeContributionsLinks( $userId, $userPageTitle, &$toolLinks,
|
||||
SpecialPage $sp
|
||||
) {
|
||||
$username = $userPageTitle->getText();
|
||||
if ( $sp->getUser()->isAllowed( 'nuke' ) && !IPUtils::isValidRange( $username ) ) {
|
||||
$toolLinks['nuke'] = $sp->getLinkRenderer()->makeKnownLink(
|
||||
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' ),
|
||||
$sp->msg( 'nuke-linkoncontribs' )->text(),
|
||||
[ 'title' => $sp->msg( 'nuke-linkoncontribs-text', $username )->text() ],
|
||||
$specialPage->msg( 'nuke-linkoncontribs' )->text(),
|
||||
[ 'title' => $specialPage->msg( 'nuke-linkoncontribs-text', $username )->text() ],
|
||||
[ 'target' => $username ]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue