mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-12 08:49:28 +00:00
915b9a1538
Bug: T220191 Change-Id: I54e20870a32ff98b41a98495694ff563c4c4c5ca
73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
/**
|
|
* Parent class for AbuseFilter special pages.
|
|
*/
|
|
abstract class AbuseFilterSpecialPage extends SpecialPage {
|
|
/**
|
|
* Add topbar navigation links
|
|
*
|
|
* @param string $pageType
|
|
*/
|
|
protected function addNavigationLinks( $pageType ) {
|
|
$user = $this->getUser();
|
|
|
|
$linkDefs = [
|
|
'home' => 'Special:AbuseFilter',
|
|
'recentchanges' => 'Special:AbuseFilter/history',
|
|
'examine' => 'Special:AbuseFilter/examine',
|
|
];
|
|
|
|
if ( MediaWikiServices::getInstance()->getPermissionManager()
|
|
->userHasRight( $user, 'abusefilter-log' )
|
|
) {
|
|
$linkDefs = array_merge( $linkDefs, [
|
|
'log' => 'Special:AbuseLog'
|
|
] );
|
|
}
|
|
|
|
if ( AbuseFilter::canViewPrivate( $user ) ) {
|
|
$linkDefs = array_merge( $linkDefs, [
|
|
'test' => 'Special:AbuseFilter/test',
|
|
'tools' => 'Special:AbuseFilter/tools'
|
|
] );
|
|
}
|
|
|
|
if ( AbuseFilter::canEdit( $user ) ) {
|
|
$linkDefs = array_merge( $linkDefs, [
|
|
'import' => 'Special:AbuseFilter/import'
|
|
] );
|
|
}
|
|
|
|
$links = [];
|
|
|
|
foreach ( $linkDefs as $name => $page ) {
|
|
// Give grep a chance to find the usages:
|
|
// abusefilter-topnav-home, abusefilter-topnav-recentchanges, abusefilter-topnav-test,
|
|
// abusefilter-topnav-log, abusefilter-topnav-tools, abusefilter-topnav-import
|
|
// abusefilter-topnav-examine
|
|
$msgName = "abusefilter-topnav-$name";
|
|
|
|
$msg = $this->msg( $msgName )->parse();
|
|
$title = Title::newFromText( $page );
|
|
|
|
if ( $name === $pageType ) {
|
|
$links[] = Xml::tags( 'strong', null, $msg );
|
|
} else {
|
|
$links[] = $this->getLinkRenderer()->makeLink( $title, new HtmlArmor( $msg ) );
|
|
}
|
|
}
|
|
|
|
$linkStr = $this->msg( 'parentheses' )
|
|
->rawParams( $this->getLanguage()->pipeList( $links ) )
|
|
->text();
|
|
$linkStr = $this->msg( 'abusefilter-topnav' )->parse() . " $linkStr";
|
|
|
|
$linkStr = Xml::tags( 'div', [ 'class' => 'mw-abusefilter-navigation' ], $linkStr );
|
|
|
|
$this->getOutput()->setSubtitle( $linkStr );
|
|
}
|
|
}
|