diff --git a/extension.json b/extension.json index 487a99af3..6c7e3f1d5 100644 --- a/extension.json +++ b/extension.json @@ -116,6 +116,7 @@ "AbuseFilterHooks": "includes/AbuseFilterHooks.php", "AbuseFilterPreAuthenticationProvider": "includes/AbuseFilterPreAuthenticationProvider.php", "AbuseFilterRunner": "includes/AbuseFilterRunner.php", + "AbuseFilterSpecialPage": "includes/special/AbuseFilterSpecialPage.php", "SpecialAbuseLog": "includes/special/SpecialAbuseLog.php", "AbuseLogPager": "includes/pagers/AbuseLogPager.php", "SpecialAbuseFilter": "includes/special/SpecialAbuseFilter.php", diff --git a/includes/AbuseFilter.php b/includes/AbuseFilter.php index 059f0d114..cb57780ac 100644 --- a/includes/AbuseFilter.php +++ b/includes/AbuseFilter.php @@ -1,6 +1,5 @@ 'moved_to_id', ]; - /** - * @param IContextSource $context - * @param string $pageType - * @param LinkRenderer $linkRenderer - */ - public static function addNavigationLinks( - IContextSource $context, - $pageType, - LinkRenderer $linkRenderer - ) { - $linkDefs = [ - 'home' => 'Special:AbuseFilter', - 'recentchanges' => 'Special:AbuseFilter/history', - 'examine' => 'Special:AbuseFilter/examine', - ]; - - if ( $context->getUser()->isAllowed( 'abusefilter-log' ) ) { - $linkDefs = array_merge( $linkDefs, [ - 'log' => 'Special:AbuseLog' - ] ); - } - - if ( $context->getUser()->isAllowedAny( 'abusefilter-modify', 'abusefilter-view-private' ) ) { - $linkDefs = array_merge( $linkDefs, [ - 'test' => 'Special:AbuseFilter/test', - 'tools' => 'Special:AbuseFilter/tools' - ] ); - } - - if ( $context->getUser()->isAllowed( 'abusefilter-modify' ) ) { - $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 = $context->msg( $msgName )->parse(); - $title = Title::newFromText( $page ); - - if ( $name === $pageType ) { - $links[] = Xml::tags( 'strong', null, $msg ); - } else { - $links[] = $linkRenderer->makeLink( $title, new HtmlArmor( $msg ) ); - } - } - - $linkStr = $context->msg( 'parentheses' ) - ->rawParams( $context->getLanguage()->pipeList( $links ) ) - ->text(); - $linkStr = $context->msg( 'abusefilter-topnav' )->parse() . " $linkStr"; - - $linkStr = Xml::tags( 'div', [ 'class' => 'mw-abusefilter-navigation' ], $linkStr ); - - $context->getOutput()->setSubtitle( $linkStr ); - } - /** * @param User $user * @param null|stdClass $rcRow If the variables should be generated for an RC row, this is the row. diff --git a/includes/special/AbuseFilterSpecialPage.php b/includes/special/AbuseFilterSpecialPage.php new file mode 100644 index 000000000..09e56a0ef --- /dev/null +++ b/includes/special/AbuseFilterSpecialPage.php @@ -0,0 +1,66 @@ + 'Special:AbuseFilter', + 'recentchanges' => 'Special:AbuseFilter/history', + 'examine' => 'Special:AbuseFilter/examine', + ]; + + if ( $this->getUser()->isAllowed( 'abusefilter-log' ) ) { + $linkDefs = array_merge( $linkDefs, [ + 'log' => 'Special:AbuseLog' + ] ); + } + + if ( $this->getUser()->isAllowedAny( 'abusefilter-modify', 'abusefilter-view-private' ) ) { + $linkDefs = array_merge( $linkDefs, [ + 'test' => 'Special:AbuseFilter/test', + 'tools' => 'Special:AbuseFilter/tools' + ] ); + } + + if ( $this->getUser()->isAllowed( 'abusefilter-modify' ) ) { + $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 ); + } +} diff --git a/includes/special/SpecialAbuseFilter.php b/includes/special/SpecialAbuseFilter.php index 78634bedf..81cee8321 100644 --- a/includes/special/SpecialAbuseFilter.php +++ b/includes/special/SpecialAbuseFilter.php @@ -1,6 +1,6 @@ getContext(), $pageType, $this->getLinkRenderer() ); + $this->addNavigationLinks( $pageType ); /** @var AbuseFilterView $v */ $v = new $view( $this, $params ); @@ -131,21 +140,12 @@ class SpecialAbuseFilter extends SpecialPage { } /** - * @param string|null $subpage + * @param string|null $filter */ - public function loadParameters( $subpage ) { - $filter = $subpage; - + public function loadParameters( $filter ) { if ( !is_numeric( $filter ) && $filter !== 'new' ) { $filter = $this->getRequest()->getIntOrNull( 'wpFilter' ); } $this->mFilter = $filter; } - - /** - * @return string - */ - protected function getGroupName() { - return 'wiki'; - } } diff --git a/includes/special/SpecialAbuseLog.php b/includes/special/SpecialAbuseLog.php index 46b94d712..84a74a27e 100644 --- a/includes/special/SpecialAbuseLog.php +++ b/includes/special/SpecialAbuseLog.php @@ -1,6 +1,6 @@ getOutput(); $request = $this->getRequest(); - AbuseFilter::addNavigationLinks( - $this->getContext(), 'log', $this->getLinkRenderer() ); + $this->addNavigationLinks( 'log' ); $this->setHeaders(); $this->addHelpLink( 'Extension:AbuseFilter' ); @@ -1183,11 +1189,4 @@ class SpecialAbuseLog extends SpecialPage { return false; } - - /** - * @return string - */ - protected function getGroupName() { - return 'changes'; - } }