mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-24 22:15:26 +00:00
f7ed4cffee
Change-Id: Ibcc48b519271645f85f186ecb20fc6d2854aee06 Follows-Up: I67701856297927b94aa443a78376bae7d7860def
128 lines
3.3 KiB
PHP
128 lines
3.3 KiB
PHP
<?php
|
|
|
|
class SpecialAbuseFilter extends SpecialPage {
|
|
public $mFilter, $mHistoryID;
|
|
|
|
public function __construct() {
|
|
parent::__construct( 'AbuseFilter', 'abusefilter-view' );
|
|
}
|
|
|
|
/**
|
|
* Back-compat function for pre-1.23 MediaWiki versions
|
|
* @param bool|string $subpage
|
|
* @return Title
|
|
*/
|
|
public function getPageTitle( $subpage = false ) {
|
|
return self::getTitleFor( $this->getName(), $subpage );
|
|
}
|
|
|
|
public function execute( $subpage ) {
|
|
$out = $this->getOutput();
|
|
$request = $this->getRequest();
|
|
|
|
$out->addModuleStyles( 'ext.abuseFilter' );
|
|
$view = 'AbuseFilterViewList';
|
|
|
|
$this->setHeaders();
|
|
|
|
$this->loadParameters( $subpage );
|
|
$out->setPageTitle( $this->msg( 'abusefilter-management' ) );
|
|
|
|
// Are we allowed?
|
|
$this->checkPermissions();
|
|
|
|
if ( $request->getVal( 'result' ) == 'success' ) {
|
|
$out->setSubtitle( $this->msg( 'abusefilter-edit-done-subtitle' ) );
|
|
$changedFilter = intval( $request->getVal( 'changedfilter' ) );
|
|
$changeId = intval( $request->getVal( 'changeid' ) );
|
|
$out->wrapWikiMsg( '<p class="success">$1</p>',
|
|
array(
|
|
'abusefilter-edit-done',
|
|
$this->getLanguage()->formatNum( $changedFilter ),
|
|
$changeId
|
|
)
|
|
);
|
|
}
|
|
|
|
$this->mHistoryID = null;
|
|
$pageType = 'home';
|
|
|
|
$params = explode( '/', $subpage );
|
|
|
|
// Filter by removing blanks.
|
|
foreach ( $params as $index => $param ) {
|
|
if ( $param === '' ) {
|
|
unset( $params[$index] );
|
|
}
|
|
}
|
|
$params = array_values( $params );
|
|
|
|
if ( $subpage == 'tools' ) {
|
|
$view = 'AbuseFilterViewTools';
|
|
$pageType = 'tools';
|
|
}
|
|
|
|
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' ) {
|
|
$view = 'AbuseFilterViewTestBatch';
|
|
$pageType = 'test';
|
|
}
|
|
|
|
if ( count( $params ) && $params[0] == 'examine' ) {
|
|
$view = 'AbuseFilterViewExamine';
|
|
$pageType = 'examine';
|
|
}
|
|
|
|
if ( !empty( $params[0] ) && ( $params[0] == 'history' || $params[0] == 'log' ) ) {
|
|
$pageType = '';
|
|
if ( count( $params ) == 1 ) {
|
|
$view = 'AbuseFilterViewHistory';
|
|
$pageType = 'recentchanges';
|
|
} elseif ( count( $params ) == 2 ) {
|
|
# Second param is a filter ID
|
|
$view = 'AbuseFilterViewHistory';
|
|
$this->mFilter = $params[1];
|
|
} elseif ( count( $params ) == 4 && $params[2] == 'item' ) {
|
|
$this->mFilter = $params[1];
|
|
$this->mHistoryID = $params[3];
|
|
$view = 'AbuseFilterViewEdit';
|
|
} elseif ( count( $params ) == 5 && $params[2] == 'diff' ) {
|
|
// Special:AbuseFilter/history/<filter>/diff/<oldid>/<newid>
|
|
$view = 'AbuseFilterViewDiff';
|
|
}
|
|
}
|
|
|
|
if ( is_numeric( $subpage ) || $subpage == 'new' ) {
|
|
$this->mFilter = $subpage;
|
|
$view = 'AbuseFilterViewEdit';
|
|
$pageType = 'edit';
|
|
}
|
|
|
|
if ( $subpage == 'import' ) {
|
|
$view = 'AbuseFilterViewImport';
|
|
$pageType = 'import';
|
|
}
|
|
|
|
// Links at the top
|
|
AbuseFilter::addNavigationLinks( $this->getContext(), $pageType );
|
|
|
|
/** @var AbuseFilterView $v */
|
|
$v = new $view( $this, $params );
|
|
$v->show();
|
|
}
|
|
|
|
function loadParameters( $subpage ) {
|
|
$filter = $subpage;
|
|
|
|
if ( !is_numeric( $filter ) && $filter != 'new' ) {
|
|
$filter = $this->getRequest()->getIntOrNull( 'wpFilter' );
|
|
}
|
|
$this->mFilter = $filter;
|
|
}
|
|
}
|