2019-02-08 17:45:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parent class for AbuseFilter special pages.
|
|
|
|
*/
|
|
|
|
abstract class AbuseFilterSpecialPage extends SpecialPage {
|
|
|
|
/**
|
|
|
|
* Add topbar navigation links
|
|
|
|
*
|
|
|
|
* @param string $pageType
|
|
|
|
*/
|
|
|
|
protected function addNavigationLinks( $pageType ) {
|
2019-08-27 10:08:17 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
2019-02-08 17:45:25 +00:00
|
|
|
$linkDefs = [
|
|
|
|
'home' => 'Special:AbuseFilter',
|
|
|
|
'recentchanges' => 'Special:AbuseFilter/history',
|
|
|
|
'examine' => 'Special:AbuseFilter/examine',
|
|
|
|
];
|
|
|
|
|
2019-08-27 10:08:17 +00:00
|
|
|
if ( $user->isAllowed( 'abusefilter-log' ) ) {
|
2019-02-08 17:45:25 +00:00
|
|
|
$linkDefs = array_merge( $linkDefs, [
|
|
|
|
'log' => 'Special:AbuseLog'
|
|
|
|
] );
|
|
|
|
}
|
|
|
|
|
2019-08-27 10:08:17 +00:00
|
|
|
if ( AbuseFilter::canViewPrivate( $user ) ) {
|
2019-02-08 17:45:25 +00:00
|
|
|
$linkDefs = array_merge( $linkDefs, [
|
|
|
|
'test' => 'Special:AbuseFilter/test',
|
|
|
|
'tools' => 'Special:AbuseFilter/tools'
|
|
|
|
] );
|
|
|
|
}
|
|
|
|
|
2019-08-27 10:08:17 +00:00
|
|
|
if ( AbuseFilter::canEdit( $user ) ) {
|
2019-02-08 17:45:25 +00:00
|
|
|
$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 );
|
|
|
|
}
|
|
|
|
}
|