mediawiki-extensions-AbuseF.../includes/Pager/AbuseFilterExaminePager.php
Matěj Suchánek be247401bb Clean up AbuseFilterViewExamine and AbuseFilterExaminePager
Move most stuff from the pager to the view class to untangle
circular dependency. Declare class properties as private.
Leave input validation to the form.

Change-Id: Ia8b1a9d08af9c0cac23b34f6bbbe2c44d01f6c8c
2022-07-03 11:29:43 +02:00

102 lines
2.1 KiB
PHP

<?php
namespace MediaWiki\Extension\AbuseFilter\Pager;
use MediaWiki\Extension\AbuseFilter\AbuseFilterChangesList;
use MediaWiki\Linker\LinkRenderer;
use RecentChange;
use ReverseChronologicalPager;
use stdClass;
use Title;
use Wikimedia\Rdbms\IDatabase;
class AbuseFilterExaminePager extends ReverseChronologicalPager {
/**
* @var AbuseFilterChangesList Our changes list
*/
private $changesList;
/**
* @var Title
*/
private $title;
/**
* @var array Query conditions
*/
private $conds;
/**
* @var int Line number of the row, see RecentChange::$counter
*/
private $rcCounter;
/**
* @param AbuseFilterChangesList $changesList
* @param LinkRenderer $linkRenderer
* @param IDatabase $dbr
* @param Title $title
* @param array $conds
*/
public function __construct(
AbuseFilterChangesList $changesList,
LinkRenderer $linkRenderer,
IDatabase $dbr,
Title $title,
array $conds
) {
// Set database before parent constructor to avoid setting it there with wfGetDB
$this->mDb = $dbr;
parent::__construct( $changesList, $linkRenderer );
$this->changesList = $changesList;
$this->title = $title;
$this->conds = $conds;
$this->rcCounter = 1;
}
/**
* @return array
*/
public function getQueryInfo() {
$rcQuery = RecentChange::getQueryInfo();
$info = [
'tables' => $rcQuery['tables'],
'fields' => $rcQuery['fields'],
'conds' => $this->conds,
'join_conds' => $rcQuery['joins'],
];
return $info;
}
/**
* @param stdClass $row
* @return string
*/
public function formatRow( $row ) {
$rc = RecentChange::newFromRow( $row );
$rc->counter = $this->rcCounter++;
return $this->changesList->recentChangesLine( $rc, false );
}
/**
* @codeCoverageIgnore Merely declarative
* @inheritDoc
*/
public function getIndexField() {
return 'rc_id';
}
/**
* @codeCoverageIgnore Merely declarative
* @return Title
*/
public function getTitle() {
return $this->title;
}
/**
* @return string
*/
public function getEmptyBody() {
return $this->msg( 'abusefilter-examine-noresults' )->parseAsBlock();
}
}