2008-06-27 06:18:51 +00:00
|
|
|
<?php
|
2009-10-07 13:57:06 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) )
|
2008-06-27 06:18:51 +00:00
|
|
|
die();
|
|
|
|
|
|
|
|
class SpecialAbuseFilter extends SpecialPage {
|
|
|
|
|
|
|
|
var $mSkin;
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
public function __construct() {
|
|
|
|
wfLoadExtensionMessages( 'AbuseFilter' );
|
2008-06-27 06:18:51 +00:00
|
|
|
parent::__construct( 'AbuseFilter', 'abusefilter-view' );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
public function execute( $subpage ) {
|
2009-01-27 17:32:30 +00:00
|
|
|
global $wgUser, $wgOut, $wgRequest, $wgAbuseFilterStyleVersion, $wgScriptPath;
|
2009-01-15 19:04:36 +00:00
|
|
|
|
2009-02-07 09:34:11 +00:00
|
|
|
$wgOut->addExtensionStyle( "{$wgScriptPath}/extensions/AbuseFilter/abusefilter.css?" .
|
|
|
|
$wgAbuseFilterStyleVersion );
|
2009-01-23 19:23:19 +00:00
|
|
|
$view = 'AbuseFilterViewList';
|
2008-06-27 06:18:51 +00:00
|
|
|
|
|
|
|
$this->setHeaders();
|
|
|
|
|
|
|
|
$this->loadParameters( $subpage );
|
|
|
|
$wgOut->setPageTitle( wfMsg( 'abusefilter-management' ) );
|
2009-01-26 22:31:02 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
// Are we allowed?
|
2008-09-05 14:27:18 +00:00
|
|
|
if ( !$wgUser->isAllowed( 'abusefilter-view' ) ) {
|
|
|
|
$this->displayRestrictionError();
|
2008-06-27 06:18:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-01-23 19:23:19 +00:00
|
|
|
|
|
|
|
if ( $wgRequest->getVal( 'result' ) == 'success' ) {
|
|
|
|
$wgOut->setSubtitle( wfMsg( 'abusefilter-edit-done-subtitle' ) );
|
2009-10-07 13:57:06 +00:00
|
|
|
$changedFilter = intval( $wgRequest->getVal( 'changedfilter' ) );
|
2009-02-07 09:34:11 +00:00
|
|
|
$wgOut->wrapWikiMsg( '<p class="success">$1</p>',
|
2009-10-07 13:57:06 +00:00
|
|
|
array( 'abusefilter-edit-done', $changedFilter ) );
|
2009-01-23 19:23:19 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$this->mSkin = $wgUser->getSkin();
|
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.
|
|
|
|
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';
|
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';
|
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';
|
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 ) {
|
2008-10-21 15:14:30 +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
|
|
|
|
AbuseFilter::addNavigationLinks( $wgOut, $this->mSkin, $pageType );
|
2008-06-27 09:26:54 +00:00
|
|
|
|
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 ) {
|
2008-06-27 09:26:54 +00:00
|
|
|
global $wgRequest;
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$filter = $subpage;
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
if ( !is_numeric( $filter ) && $filter != 'new' ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
$filter = $wgRequest->getIntOrNull( 'wpFilter' );
|
|
|
|
}
|
|
|
|
$this->mFilter = $filter;
|
|
|
|
}
|
2009-02-07 09:34:11 +00:00
|
|
|
}
|