2008-06-27 06:18:51 +00:00
|
|
|
<?php
|
|
|
|
|
2019-02-08 17:45:25 +00:00
|
|
|
class SpecialAbuseFilter extends AbuseFilterSpecialPage {
|
2020-10-03 13:05:20 +00:00
|
|
|
|
2020-10-03 17:13:32 +00:00
|
|
|
private const PAGE_NAME = 'AbuseFilter';
|
2013-10-15 13:22:05 +00:00
|
|
|
|
2019-02-08 17:45:25 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2009-10-07 13:57:06 +00:00
|
|
|
public function __construct() {
|
2019-08-27 14:07:52 +00:00
|
|
|
parent::__construct( self::PAGE_NAME, 'abusefilter-view' );
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
2019-02-08 17:45:25 +00:00
|
|
|
* @inheritDoc
|
2018-04-04 21:14:25 +00:00
|
|
|
*/
|
2016-05-11 17:20:49 +00:00
|
|
|
public function doesWrites() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-02-08 17:45:25 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
protected function getGroupName() {
|
|
|
|
return 'wiki';
|
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @param string|null $subpage
|
|
|
|
*/
|
2009-10-07 13:57:06 +00:00
|
|
|
public function execute( $subpage ) {
|
2011-11-16 05:34:24 +00:00
|
|
|
$out = $this->getOutput();
|
|
|
|
$request = $this->getRequest();
|
2009-01-15 19:04:36 +00:00
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->addModuleStyles( 'ext.abuseFilter' );
|
2008-06-27 06:18:51 +00:00
|
|
|
|
|
|
|
$this->setHeaders();
|
2019-07-03 15:43:44 +00:00
|
|
|
$this->addHelpLink( 'Extension:AbuseFilter' );
|
2008-06-27 06:18:51 +00:00
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$this->checkPermissions();
|
2009-01-23 19:23:19 +00:00
|
|
|
|
2018-08-26 08:34:42 +00:00
|
|
|
if ( $request->getVal( 'result' ) === 'success' ) {
|
2012-09-02 11:07:02 +00:00
|
|
|
$out->setSubtitle( $this->msg( 'abusefilter-edit-done-subtitle' ) );
|
2011-11-16 05:34:24 +00:00
|
|
|
$changedFilter = intval( $request->getVal( 'changedfilter' ) );
|
2013-10-06 02:30:37 +00:00
|
|
|
$changeId = intval( $request->getVal( 'changeid' ) );
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->wrapWikiMsg( '<p class="success">$1</p>',
|
2017-06-15 14:23:34 +00:00
|
|
|
[
|
2013-10-06 02:30:37 +00:00
|
|
|
'abusefilter-edit-done',
|
2014-06-28 19:23:43 +00:00
|
|
|
$changedFilter,
|
|
|
|
$changeId,
|
|
|
|
$this->getLanguage()->formatNum( $changedFilter )
|
2017-06-15 14:23:34 +00:00
|
|
|
]
|
2013-10-06 02:30:37 +00:00
|
|
|
);
|
2009-01-23 19:23:19 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
[ $view, $pageType, $params ] = $this->getViewClassAndPageType( $subpage );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
// Links at the top
|
|
|
|
$this->addNavigationLinks( $pageType );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
/** @var AbuseFilterView $v */
|
2020-10-16 22:36:15 +00:00
|
|
|
$v = new $view( $this->getContext(), $this->getLinkRenderer(), self::PAGE_NAME, $params );
|
2020-10-03 13:05:20 +00:00
|
|
|
$v->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine the view class to instantiate
|
|
|
|
*
|
|
|
|
* @param string|null $subpage
|
|
|
|
* @return array A tuple of three elements:
|
|
|
|
* - a subclass of AbuseFilterView
|
|
|
|
* - type of page for addNavigationLinks
|
|
|
|
* - array of parameters for the class
|
|
|
|
* @phan-return array{0:class-string,1:string,2:array}
|
|
|
|
*/
|
|
|
|
public function getViewClassAndPageType( $subpage ) : array {
|
2009-05-26 13:08:15 +00:00
|
|
|
// Filter by removing blanks.
|
2020-10-03 13:05:20 +00:00
|
|
|
$params = array_values( array_filter(
|
|
|
|
explode( '/', $subpage ?: '' ),
|
|
|
|
function ( $value ) {
|
|
|
|
return $value !== '';
|
2009-05-26 13:08:15 +00:00
|
|
|
}
|
2020-10-03 13:05:20 +00:00
|
|
|
) );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2018-08-26 08:34:42 +00:00
|
|
|
if ( $subpage === 'tools' ) {
|
2020-10-03 13:05:20 +00:00
|
|
|
return [ AbuseFilterViewTools::class, 'tools', [] ];
|
2008-07-17 13:40:45 +00:00
|
|
|
}
|
2009-01-28 00:10:35 +00:00
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
if ( $subpage === 'import' ) {
|
|
|
|
return [ AbuseFilterViewImport::class, 'import', [] ];
|
2009-01-28 00:10:35 +00:00
|
|
|
}
|
2009-01-28 23:54:41 +00:00
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
if ( is_numeric( $subpage ) || $subpage === 'new' ) {
|
2020-09-20 10:18:46 +00:00
|
|
|
return [
|
|
|
|
AbuseFilterViewEdit::class,
|
|
|
|
'edit',
|
|
|
|
[ 'filter' => is_numeric( $subpage ) ? (int)$subpage : null ]
|
|
|
|
];
|
2009-01-29 22:44:31 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
if ( $params ) {
|
|
|
|
if ( count( $params ) === 2 && $params[0] === 'revert' && is_numeric( $params[1] ) ) {
|
2020-09-20 10:18:46 +00:00
|
|
|
$params[1] = (int)$params[1];
|
2020-10-03 13:05:20 +00:00
|
|
|
return [ AbuseFilterViewRevert::class, 'revert', $params ];
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
if ( $params[0] === 'test' ) {
|
|
|
|
return [ AbuseFilterViewTestBatch::class, 'test', $params ];
|
2008-08-03 14:04:26 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
if ( $params[0] === 'examine' ) {
|
|
|
|
return [ AbuseFilterViewExamine::class, 'examine', $params ];
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
if ( $params[0] === 'history' || $params[0] === 'log' ) {
|
|
|
|
if ( count( $params ) <= 2 ) {
|
2020-10-09 13:28:05 +00:00
|
|
|
$params = isset( $params[1] ) ? [ 'filter' => (int)$params[1] ] : [];
|
2020-10-03 13:05:20 +00:00
|
|
|
return [ AbuseFilterViewHistory::class, 'recentchanges', $params ];
|
|
|
|
}
|
|
|
|
if ( count( $params ) === 4 && $params[2] === 'item' ) {
|
|
|
|
return [
|
|
|
|
AbuseFilterViewEdit::class,
|
|
|
|
'',
|
2020-09-20 10:18:46 +00:00
|
|
|
[ 'filter' => (int)$params[1], 'history' => (int)$params[3] ]
|
2020-10-03 13:05:20 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
if ( count( $params ) === 5 && $params[2] === 'diff' ) {
|
|
|
|
// Special:AbuseFilter/history/<filter>/diff/<oldid>/<newid>
|
|
|
|
return [ AbuseFilterViewDiff::class, '', $params ];
|
|
|
|
}
|
|
|
|
}
|
2009-04-23 04:23:56 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2020-10-03 13:05:20 +00:00
|
|
|
return [ AbuseFilterViewList::class, 'home', [] ];
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2020-10-03 17:13:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Static variant to get the associated Title.
|
|
|
|
*
|
|
|
|
* @param string|int $subpage
|
|
|
|
* @return Title
|
|
|
|
*/
|
|
|
|
public static function getTitleForSubpage( $subpage ) : Title {
|
|
|
|
return self::getTitleFor( self::PAGE_NAME, $subpage );
|
|
|
|
}
|
2009-02-07 09:34:11 +00:00
|
|
|
}
|