2008-06-27 06:18:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class SpecialAbuseFilter extends SpecialPage {
|
2013-10-15 13:22:05 +00:00
|
|
|
public $mFilter, $mHistoryID;
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
public function __construct() {
|
2008-06-27 06:18:51 +00:00
|
|
|
parent::__construct( 'AbuseFilter', 'abusefilter-view' );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2016-05-11 17:20:49 +00:00
|
|
|
public function doesWrites() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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' );
|
2009-01-23 19:23:19 +00:00
|
|
|
$view = 'AbuseFilterViewList';
|
2008-06-27 06:18:51 +00:00
|
|
|
|
|
|
|
$this->setHeaders();
|
|
|
|
|
|
|
|
$this->loadParameters( $subpage );
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->setPageTitle( $this->msg( 'abusefilter-management' ) );
|
2009-01-26 22:31:02 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
// Are we allowed?
|
2011-11-16 05:34:24 +00:00
|
|
|
$this->checkPermissions();
|
2009-01-23 19:23:19 +00:00
|
|
|
|
2011-11-16 05:34:24 +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>',
|
2013-10-06 02:30:37 +00:00
|
|
|
array(
|
|
|
|
'abusefilter-edit-done',
|
2014-06-28 19:23:43 +00:00
|
|
|
$changedFilter,
|
|
|
|
$changeId,
|
|
|
|
$this->getLanguage()->formatNum( $changedFilter )
|
2013-10-06 02:30:37 +00:00
|
|
|
)
|
|
|
|
);
|
2009-01-23 19:23:19 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-01-23 19:23:19 +00:00
|
|
|
$this->mHistoryID = null;
|
2009-03-11 05:55:06 +00:00
|
|
|
$pageType = 'home';
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-26 13:08:15 +00:00
|
|
|
$params = explode( '/', $subpage );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-26 13:08:15 +00:00
|
|
|
// Filter by removing blanks.
|
2010-02-13 14:10:36 +00:00
|
|
|
foreach ( $params as $index => $param ) {
|
2009-10-07 13:57:06 +00:00
|
|
|
if ( $param === '' ) {
|
2009-05-26 13:08:15 +00:00
|
|
|
unset( $params[$index] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$params = array_values( $params );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
if ( $subpage == 'tools' ) {
|
2009-01-23 19:23:19 +00:00
|
|
|
$view = 'AbuseFilterViewTools';
|
2009-03-11 05:55:06 +00:00
|
|
|
$pageType = 'tools';
|
2015-06-11 14:21:15 +00:00
|
|
|
$out->addHelpLink( 'Extension:AbuseFilter/Rules format' );
|
2008-07-17 13:40:45 +00:00
|
|
|
}
|
2009-01-28 00:10:35 +00:00
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
if ( count( $params ) == 2 && $params[0] == 'revert' && is_numeric( $params[1] ) ) {
|
2009-01-28 00:10:35 +00:00
|
|
|
$this->mFilter = $params[1];
|
|
|
|
$view = 'AbuseFilterViewRevert';
|
2009-03-11 05:55:06 +00:00
|
|
|
$pageType = 'revert';
|
2009-01-28 00:10:35 +00:00
|
|
|
}
|
2009-01-28 23:54:41 +00:00
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
if ( count( $params ) && $params[0] == 'test' ) {
|
2009-01-29 22:44:31 +00:00
|
|
|
$view = 'AbuseFilterViewTestBatch';
|
2009-03-11 05:55:06 +00:00
|
|
|
$pageType = 'test';
|
2015-06-11 14:21:15 +00:00
|
|
|
$out->addHelpLink( 'Extension:AbuseFilter/Rules format' );
|
2009-01-29 22:44:31 +00:00
|
|
|
}
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
if ( count( $params ) && $params[0] == 'examine' ) {
|
2009-01-29 22:44:31 +00:00
|
|
|
$view = 'AbuseFilterViewExamine';
|
2009-03-11 05:55:06 +00:00
|
|
|
$pageType = 'examine';
|
2015-06-11 14:21:15 +00:00
|
|
|
$out->addHelpLink( 'Extension:AbuseFilter/Rules format' );
|
2009-01-28 23:54:41 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
if ( !empty( $params[0] ) && ( $params[0] == 'history' || $params[0] == 'log' ) ) {
|
2009-03-12 05:04:39 +00:00
|
|
|
$pageType = '';
|
2009-10-07 13:57:06 +00:00
|
|
|
if ( count( $params ) == 1 ) {
|
2009-01-26 18:50:20 +00:00
|
|
|
$view = 'AbuseFilterViewHistory';
|
2009-03-11 05:55:06 +00:00
|
|
|
$pageType = 'recentchanges';
|
2009-10-07 13:57:06 +00:00
|
|
|
} elseif ( count( $params ) == 2 ) {
|
2010-08-19 21:12:09 +00:00
|
|
|
# Second param is a filter ID
|
2009-01-23 19:23:19 +00:00
|
|
|
$view = 'AbuseFilterViewHistory';
|
|
|
|
$this->mFilter = $params[1];
|
2009-10-07 13:57:06 +00:00
|
|
|
} elseif ( count( $params ) == 4 && $params[2] == 'item' ) {
|
2009-01-23 19:23:19 +00:00
|
|
|
$this->mFilter = $params[1];
|
|
|
|
$this->mHistoryID = $params[3];
|
|
|
|
$view = 'AbuseFilterViewEdit';
|
2009-10-07 13:57:06 +00:00
|
|
|
} elseif ( count( $params ) == 5 && $params[2] == 'diff' ) {
|
2009-03-12 05:04:39 +00:00
|
|
|
// Special:AbuseFilter/history/<filter>/diff/<oldid>/<newid>
|
|
|
|
$view = 'AbuseFilterViewDiff';
|
2008-08-03 14:04:26 +00:00
|
|
|
}
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
if ( is_numeric( $subpage ) || $subpage == 'new' ) {
|
2009-01-23 19:23:19 +00:00
|
|
|
$this->mFilter = $subpage;
|
|
|
|
$view = 'AbuseFilterViewEdit';
|
2009-03-17 14:09:17 +00:00
|
|
|
$pageType = 'edit';
|
2008-08-04 14:27:48 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-04-23 04:23:56 +00:00
|
|
|
if ( $subpage == 'import' ) {
|
|
|
|
$view = 'AbuseFilterViewImport';
|
|
|
|
$pageType = 'import';
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-03-11 05:55:06 +00:00
|
|
|
// Links at the top
|
2011-11-17 00:55:53 +00:00
|
|
|
AbuseFilter::addNavigationLinks( $this->getContext(), $pageType );
|
2008-06-27 09:26:54 +00:00
|
|
|
|
2013-10-15 13:22:05 +00:00
|
|
|
/** @var AbuseFilterView $v */
|
2009-01-23 19:23:19 +00:00
|
|
|
$v = new $view( $this, $params );
|
2009-10-07 13:57:06 +00:00
|
|
|
$v->show();
|
2008-10-21 15:14:30 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
function loadParameters( $subpage ) {
|
|
|
|
$filter = $subpage;
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
if ( !is_numeric( $filter ) && $filter != 'new' ) {
|
2011-11-16 05:34:24 +00:00
|
|
|
$filter = $this->getRequest()->getIntOrNull( 'wpFilter' );
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
|
|
|
$this->mFilter = $filter;
|
|
|
|
}
|
2015-05-15 19:42:44 +00:00
|
|
|
|
|
|
|
protected function getGroupName() {
|
|
|
|
return 'wiki';
|
|
|
|
}
|
2009-02-07 09:34:11 +00:00
|
|
|
}
|