diff options
Diffstat (limited to 'AbuseFilter/includes/special/SpecialAbuseFilter.php')
-rw-r--r-- | AbuseFilter/includes/special/SpecialAbuseFilter.php | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/AbuseFilter/includes/special/SpecialAbuseFilter.php b/AbuseFilter/includes/special/SpecialAbuseFilter.php index ccd2f8ee..03fc9d6b 100644 --- a/AbuseFilter/includes/special/SpecialAbuseFilter.php +++ b/AbuseFilter/includes/special/SpecialAbuseFilter.php @@ -1,20 +1,38 @@ <?php -class SpecialAbuseFilter extends SpecialPage { - public $mFilter, $mHistoryID; +class SpecialAbuseFilter extends AbuseFilterSpecialPage { + public const PAGE_NAME = 'AbuseFilter'; + /** + * @var int|string|null The current filter + */ + public $mFilter; + /** + * @var int|null The history ID of the current version + */ + public $mHistoryID; + /** + * @inheritDoc + */ public function __construct() { - parent::__construct( 'AbuseFilter', 'abusefilter-view' ); + parent::__construct( self::PAGE_NAME, 'abusefilter-view' ); } /** - * @return bool + * @inheritDoc */ public function doesWrites() { return true; } /** + * @inheritDoc + */ + protected function getGroupName() { + return 'wiki'; + } + + /** * @param string|null $subpage */ public function execute( $subpage ) { @@ -25,13 +43,13 @@ class SpecialAbuseFilter extends SpecialPage { $view = 'AbuseFilterViewList'; $this->setHeaders(); + $this->addHelpLink( 'Extension:AbuseFilter' ); $this->loadParameters( $subpage ); - $out->setPageTitle( $this->msg( 'abusefilter-management' ) ); $this->checkPermissions(); - if ( $request->getVal( 'result' ) == 'success' ) { + if ( $request->getVal( 'result' ) === 'success' ) { $out->setSubtitle( $this->msg( 'abusefilter-edit-done-subtitle' ) ); $changedFilter = intval( $request->getVal( 'changedfilter' ) ); $changeId = intval( $request->getVal( 'changeid' ) ); @@ -58,64 +76,63 @@ class SpecialAbuseFilter extends SpecialPage { } $params = array_values( $params ); - if ( $subpage == 'tools' ) { + if ( $subpage === 'tools' ) { $view = 'AbuseFilterViewTools'; $pageType = 'tools'; $out->addHelpLink( 'Extension:AbuseFilter/Rules format' ); } - if ( count( $params ) == 2 && $params[0] == 'revert' && is_numeric( $params[1] ) ) { + if ( count( $params ) === 2 && $params[0] === 'revert' && is_numeric( $params[1] ) ) { $this->mFilter = $params[1]; $view = 'AbuseFilterViewRevert'; $pageType = 'revert'; } - if ( count( $params ) && $params[0] == 'test' ) { + if ( count( $params ) && $params[0] === 'test' ) { $view = 'AbuseFilterViewTestBatch'; $pageType = 'test'; $out->addHelpLink( 'Extension:AbuseFilter/Rules format' ); } - if ( count( $params ) && $params[0] == 'examine' ) { + if ( count( $params ) && $params[0] === 'examine' ) { $view = 'AbuseFilterViewExamine'; $pageType = 'examine'; $out->addHelpLink( 'Extension:AbuseFilter/Rules format' ); } - if ( !empty( $params[0] ) && ( $params[0] == 'history' || $params[0] == 'log' ) ) { + if ( !empty( $params[0] ) && ( $params[0] === 'history' || $params[0] === 'log' ) ) { $pageType = ''; - if ( count( $params ) == 1 ) { + if ( count( $params ) === 1 ) { $view = 'AbuseFilterViewHistory'; $pageType = 'recentchanges'; - } elseif ( count( $params ) == 2 ) { + } elseif ( count( $params ) === 2 ) { // Second param is a filter ID $view = 'AbuseFilterViewHistory'; $pageType = 'recentchanges'; $this->mFilter = $params[1]; - } elseif ( count( $params ) == 4 && $params[2] == 'item' ) { + } elseif ( count( $params ) === 4 && $params[2] === 'item' ) { $this->mFilter = $params[1]; - $this->mHistoryID = $params[3]; + $this->mHistoryID = (int)$params[3]; $view = 'AbuseFilterViewEdit'; - } elseif ( count( $params ) == 5 && $params[2] == 'diff' ) { + } elseif ( count( $params ) === 5 && $params[2] === 'diff' ) { // Special:AbuseFilter/history/<filter>/diff/<oldid>/<newid> $view = 'AbuseFilterViewDiff'; } } - if ( is_numeric( $subpage ) || $subpage == 'new' ) { + if ( is_numeric( $subpage ) || $subpage === 'new' ) { $this->mFilter = $subpage; $view = 'AbuseFilterViewEdit'; $pageType = 'edit'; } - if ( $subpage == 'import' ) { + if ( $subpage === 'import' ) { $view = 'AbuseFilterViewImport'; $pageType = 'import'; } // Links at the top - AbuseFilter::addNavigationLinks( - $this->getContext(), $pageType, $this->getLinkRenderer() ); + $this->addNavigationLinks( $pageType ); /** @var AbuseFilterView $v */ $v = new $view( $this, $params ); @@ -123,21 +140,12 @@ class SpecialAbuseFilter extends SpecialPage { } /** - * @param string|null $subpage + * @param string|null $filter */ - public function loadParameters( $subpage ) { - $filter = $subpage; - - if ( !is_numeric( $filter ) && $filter != 'new' ) { + 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'; - } } |