2017-12-16 00:26:25 +00:00
|
|
|
<?php
|
|
|
|
|
2020-12-03 14:11:19 +00:00
|
|
|
namespace MediaWiki\Extension\AbuseFilter\Pager;
|
|
|
|
|
2021-04-17 16:57:38 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\CentralDBManager;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\SpecsFormatter;
|
2020-11-29 10:53:29 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewList;
|
2018-04-29 17:52:45 +00:00
|
|
|
use MediaWiki\Linker\LinkRenderer;
|
|
|
|
|
2017-12-16 00:26:25 +00:00
|
|
|
/**
|
|
|
|
* Class to build paginated filter list for wikis using global abuse filters
|
|
|
|
*/
|
|
|
|
class GlobalAbuseFilterPager extends AbuseFilterPager {
|
2021-04-17 16:57:38 +00:00
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @param AbuseFilterViewList $page
|
|
|
|
* @param LinkRenderer $linkRenderer
|
2021-04-17 16:57:38 +00:00
|
|
|
* @param AbuseFilterPermissionManager $afPermManager
|
|
|
|
* @param SpecsFormatter $specsFormatter
|
|
|
|
* @param CentralDBManager $centralDBManager
|
|
|
|
* @param array $conds
|
2018-04-04 21:14:25 +00:00
|
|
|
*/
|
2021-04-17 16:57:38 +00:00
|
|
|
public function __construct(
|
|
|
|
AbuseFilterViewList $page,
|
|
|
|
LinkRenderer $linkRenderer,
|
|
|
|
AbuseFilterPermissionManager $afPermManager,
|
|
|
|
SpecsFormatter $specsFormatter,
|
|
|
|
CentralDBManager $centralDBManager,
|
|
|
|
array $conds
|
|
|
|
) {
|
|
|
|
parent::__construct( $page, $linkRenderer, $afPermManager, $specsFormatter, $conds, null, null );
|
|
|
|
$this->mDb = $centralDBManager->getConnection( DB_REPLICA );
|
2017-12-16 00:26:25 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @param string $name
|
2021-10-01 06:46:54 +00:00
|
|
|
* @param string|null $value
|
2018-04-04 21:14:25 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function formatValue( $name, $value ) {
|
2017-12-16 00:26:25 +00:00
|
|
|
$lang = $this->getLanguage();
|
|
|
|
$row = $this->mCurrentRow;
|
|
|
|
|
|
|
|
switch ( $name ) {
|
|
|
|
case 'af_id':
|
|
|
|
return $lang->formatNum( intval( $value ) );
|
|
|
|
case 'af_public_comments':
|
2018-10-26 17:32:17 +00:00
|
|
|
return $this->getOutput()->parseInlineAsInterface( $value );
|
2017-12-16 00:26:25 +00:00
|
|
|
case 'af_enabled':
|
|
|
|
$statuses = [];
|
|
|
|
if ( $row->af_deleted ) {
|
|
|
|
$statuses[] = $this->msg( 'abusefilter-deleted' )->parse();
|
|
|
|
} elseif ( $row->af_enabled ) {
|
|
|
|
$statuses[] = $this->msg( 'abusefilter-enabled' )->parse();
|
|
|
|
} else {
|
|
|
|
$statuses[] = $this->msg( 'abusefilter-disabled' )->parse();
|
|
|
|
}
|
|
|
|
if ( $row->af_global ) {
|
|
|
|
$statuses[] = $this->msg( 'abusefilter-status-global' )->parse();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $lang->commaList( $statuses );
|
|
|
|
case 'af_hit_count':
|
|
|
|
// If the rule is hidden, don't show it, even to priviledged local admins
|
|
|
|
if ( $row->af_hidden ) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return $this->msg( 'abusefilter-hitcount' )->numParams( $value )->parse();
|
|
|
|
case 'af_timestamp':
|
2021-03-08 23:54:03 +00:00
|
|
|
$user = $this->getUser();
|
2017-12-16 00:26:25 +00:00
|
|
|
return $this->msg(
|
|
|
|
'abusefilter-edit-lastmod-text',
|
2021-03-08 23:54:03 +00:00
|
|
|
$lang->userTimeAndDate( $value, $user ),
|
|
|
|
$row->af_user_text,
|
|
|
|
$lang->userDate( $value, $user ),
|
|
|
|
$lang->userTime( $value, $user ),
|
|
|
|
$row->af_user_text
|
2017-12-16 00:26:25 +00:00
|
|
|
)->parse();
|
|
|
|
case 'af_group':
|
|
|
|
// If this is global, local name probably doesn't exist, but try
|
2021-04-17 16:57:38 +00:00
|
|
|
return $this->specsFormatter->nameGroup( $value );
|
2017-12-16 00:26:25 +00:00
|
|
|
default:
|
2020-10-07 10:45:09 +00:00
|
|
|
return parent::formatValue( $name, $value );
|
2017-12-16 00:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|