Merge "Register AbuseFilter menu as standard tabs"

This commit is contained in:
jenkins-bot 2022-11-17 17:45:26 +00:00 committed by Gerrit Code Review
commit 6c34801068
2 changed files with 57 additions and 5 deletions

View file

@ -31,11 +31,31 @@ abstract class AbuseFilterSpecialPage extends SpecialPage {
}
/**
* Add topbar navigation links
*
* @param string $pageType
* @inheritDoc
*/
protected function addNavigationLinks( $pageType ) {
public function getShortDescription( string $path = '' ): string {
switch ( $path ) {
case 'AbuseFilter':
return $this->msg( 'abusefilter-topnav-home' )->text();
case 'AbuseFilter/history':
return $this->msg( 'abusefilter-topnav-recentchanges' )->text();
case 'AbuseFilter/examine':
return $this->msg( 'abusefilter-topnav-examine' )->text();
case 'AbuseFilter/test':
return $this->msg( 'abusefilter-topnav-test' )->text();
case 'AbuseFilter/tools':
return $this->msg( 'abusefilter-topnav-tools' )->text();
default:
return parent::getShortDescription( $path );
}
}
/**
* Get topbar navigation links definitions
*
* @return array
*/
private function getNavigationLinksInternal(): array {
$performer = $this->getAuthority();
$linkDefs = [
@ -57,8 +77,33 @@ abstract class AbuseFilterSpecialPage extends SpecialPage {
];
}
$links = [];
return $linkDefs;
}
/**
* Return an array of strings representing page titles that are discoverable to end users via UI.
*
* @inheritDoc
*/
public function getAssociatedNavigationLinks(): array {
$links = $this->getNavigationLinksInternal();
return array_map( static function ( $name ) {
return 'Special:' . $name;
}, array_values( $links ) );
}
/**
* Add topbar navigation links
*
* @param string $pageType
*/
protected function addNavigationLinks( $pageType ) {
// If the current skin supports sub menus nothing to do here.
if ( $this->getSkin()->supportsMenu( 'associated-pages' ) ) {
return;
}
$linkDefs = $this->getNavigationLinksInternal();
$links = [];
foreach ( $linkDefs as $name => $page ) {
// Give grep a chance to find the usages:
// abusefilter-topnav-home, abusefilter-topnav-recentchanges, abusefilter-topnav-test,

View file

@ -232,6 +232,13 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
}
}
/**
* @inheritDoc
*/
public function getShortDescription( string $path = '' ): string {
return $this->msg( 'abusefilter-topnav-log' )->text();
}
/**
* Loads parameters from request
*/