mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-28 07:50:24 +00:00
Merge "Deduplicate instance variables in Pagers"
This commit is contained in:
commit
a816207f0b
|
@ -16,11 +16,6 @@ class AbuseFilterHistoryPager extends TablePager {
|
|||
*/
|
||||
public $mUser;
|
||||
|
||||
/**
|
||||
* @var LinkRenderer
|
||||
*/
|
||||
protected $linkRenderer;
|
||||
|
||||
/**
|
||||
* @param int $filter
|
||||
* @param AbuseFilterViewHistory $page
|
||||
|
@ -29,12 +24,11 @@ class AbuseFilterHistoryPager extends TablePager {
|
|||
*/
|
||||
public function __construct( int $filter, AbuseFilterViewHistory $page, $user,
|
||||
LinkRenderer $linkRenderer ) {
|
||||
parent::__construct( $page->getContext(), $linkRenderer );
|
||||
$this->mFilter = $filter;
|
||||
$this->mPage = $page;
|
||||
$this->mUser = $user;
|
||||
$this->mDefaultDirection = true;
|
||||
$this->linkRenderer = $linkRenderer;
|
||||
parent::__construct( $this->mPage->getContext() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,12 +71,13 @@ class AbuseFilterHistoryPager extends TablePager {
|
|||
*/
|
||||
public function formatValue( $name, $value ) {
|
||||
$lang = $this->getLanguage();
|
||||
$linkRenderer = $this->getLinkRenderer();
|
||||
|
||||
$row = $this->mCurrentRow;
|
||||
|
||||
switch ( $name ) {
|
||||
case 'afh_filter':
|
||||
$formatted = $this->linkRenderer->makeLink(
|
||||
$formatted = $linkRenderer->makeLink(
|
||||
SpecialPage::getTitleFor( 'AbuseFilter', $row->afh_filter ),
|
||||
$lang->formatNum( $row->afh_filter )
|
||||
);
|
||||
|
@ -90,7 +85,7 @@ class AbuseFilterHistoryPager extends TablePager {
|
|||
case 'afh_timestamp':
|
||||
$title = SpecialPage::getTitleFor( 'AbuseFilter',
|
||||
'history/' . $row->afh_filter . '/item/' . $row->afh_id );
|
||||
$formatted = $this->linkRenderer->makeLink(
|
||||
$formatted = $linkRenderer->makeLink(
|
||||
$title,
|
||||
$lang->timeanddate( $row->afh_timestamp, true )
|
||||
);
|
||||
|
@ -145,7 +140,7 @@ class AbuseFilterHistoryPager extends TablePager {
|
|||
) {
|
||||
$title = $this->mPage->getTitle(
|
||||
'history/' . $row->afh_filter . "/diff/prev/$value" );
|
||||
$formatted = $this->linkRenderer->makeLink(
|
||||
$formatted = $linkRenderer->makeLink(
|
||||
$title,
|
||||
new HtmlArmor( $this->msg( 'abusefilter-history-diff' )->parse() )
|
||||
);
|
||||
|
|
|
@ -8,11 +8,6 @@ use Wikimedia\AtEase\AtEase;
|
|||
*/
|
||||
class AbuseFilterPager extends TablePager {
|
||||
|
||||
/**
|
||||
* @var LinkRenderer
|
||||
*/
|
||||
protected $linkRenderer;
|
||||
|
||||
/**
|
||||
* @var AbuseFilterViewList The associated page
|
||||
*/
|
||||
|
@ -46,10 +41,11 @@ class AbuseFilterPager extends TablePager {
|
|||
) {
|
||||
$this->mPage = $page;
|
||||
$this->mConds = $conds;
|
||||
$this->linkRenderer = $linkRenderer;
|
||||
$this->mSearchPattern = $searchPattern;
|
||||
$this->mSearchMode = $searchMode;
|
||||
parent::__construct( $this->mPage->getContext() );
|
||||
// needs to be at the end, some attributes are needed by methods
|
||||
// called from ancestors' constructors
|
||||
parent::__construct( $page->getContext(), $linkRenderer );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,7 +150,7 @@ class AbuseFilterPager extends TablePager {
|
|||
'af_hidden' => 'abusefilter-list-visibility',
|
||||
];
|
||||
|
||||
$user = $this->mPage->getUser();
|
||||
$user = $this->getUser();
|
||||
if ( SpecialAbuseLog::canSeeDetails( $user ) ) {
|
||||
$headers['af_hit_count'] = 'abusefilter-list-hitcount';
|
||||
}
|
||||
|
@ -182,18 +178,19 @@ class AbuseFilterPager extends TablePager {
|
|||
public function formatValue( $name, $value ) {
|
||||
$lang = $this->getLanguage();
|
||||
$user = $this->getUser();
|
||||
$linkRenderer = $this->getLinkRenderer();
|
||||
$row = $this->mCurrentRow;
|
||||
|
||||
switch ( $name ) {
|
||||
case 'af_id':
|
||||
return $this->linkRenderer->makeLink(
|
||||
return $linkRenderer->makeLink(
|
||||
SpecialPage::getTitleFor( 'AbuseFilter', $value ),
|
||||
$lang->formatNum( intval( $value ) )
|
||||
);
|
||||
case 'af_pattern':
|
||||
return $this->getHighlightedPattern( $row );
|
||||
case 'af_public_comments':
|
||||
return $this->linkRenderer->makeLink(
|
||||
return $linkRenderer->makeLink(
|
||||
SpecialPage::getTitleFor( 'AbuseFilter', $row->af_id ),
|
||||
$value
|
||||
);
|
||||
|
@ -233,7 +230,7 @@ class AbuseFilterPager extends TablePager {
|
|||
if ( SpecialAbuseLog::canSeeDetails( $user, $row->af_id, $global, $row->af_hidden ) ) {
|
||||
$count_display = $this->msg( 'abusefilter-hitcount' )
|
||||
->numParams( $value )->text();
|
||||
$link = $this->linkRenderer->makeKnownLink(
|
||||
$link = $linkRenderer->makeKnownLink(
|
||||
SpecialPage::getTitleFor( 'AbuseLog' ),
|
||||
$count_display,
|
||||
[],
|
||||
|
@ -379,7 +376,7 @@ class AbuseFilterPager extends TablePager {
|
|||
'af_hidden',
|
||||
'af_group',
|
||||
];
|
||||
if ( SpecialAbuseLog::canSeeDetails( $this->mPage->getUser() ) ) {
|
||||
if ( SpecialAbuseLog::canSeeDetails( $this->getUser() ) ) {
|
||||
$sortable_fields[] = 'af_hit_count';
|
||||
$sortable_fields[] = 'af_public_comments';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue