Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
StrikePager | |
0.00% |
0 / 29 |
|
0.00% |
0 / 7 |
110 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getQueryInfo | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
formatValue | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |||
getDefaultSort | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getFieldNames | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
getTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isFieldSortable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\SecurePoll\Pages; |
4 | |
5 | use MediaWiki\Linker\Linker; |
6 | use MediaWiki\Pager\TablePager; |
7 | |
8 | /** |
9 | * Pager for the strike log. See TablePager documentation. |
10 | */ |
11 | class StrikePager extends TablePager { |
12 | /** |
13 | * @var DetailsPage |
14 | */ |
15 | public $detailsPage; |
16 | |
17 | /** @var int */ |
18 | public $voteId; |
19 | |
20 | public function __construct( $detailsPage, $voteId ) { |
21 | $this->detailsPage = $detailsPage; |
22 | $this->voteId = $voteId; |
23 | parent::__construct(); |
24 | } |
25 | |
26 | public function getQueryInfo() { |
27 | return [ |
28 | 'tables' => [ |
29 | 'user', |
30 | 'securepoll_strike' |
31 | ], |
32 | 'fields' => '*', |
33 | 'conds' => [ |
34 | 'st_vote' => $this->voteId, |
35 | 'st_user=user_id', |
36 | ], |
37 | 'options' => [] |
38 | ]; |
39 | } |
40 | |
41 | /** |
42 | * @param string $name |
43 | * @param string $value |
44 | * @return string HTML |
45 | */ |
46 | public function formatValue( $name, $value ) { |
47 | switch ( $name ) { |
48 | case 'st_user': |
49 | return Linker::userLink( (int)$value, $this->mCurrentRow->user_name ); |
50 | case 'st_timestamp': |
51 | return htmlspecialchars( $this->getLanguage()->timeanddate( $value ) ); |
52 | default: |
53 | return htmlspecialchars( $value ); |
54 | } |
55 | } |
56 | |
57 | public function getDefaultSort() { |
58 | return 'st_timestamp'; |
59 | } |
60 | |
61 | protected function getFieldNames() { |
62 | return [ |
63 | 'st_timestamp' => $this->msg( 'securepoll-header-timestamp' )->escaped(), |
64 | 'st_user' => $this->msg( 'securepoll-header-admin' )->escaped(), |
65 | 'st_action' => $this->msg( 'securepoll-header-action' )->escaped(), |
66 | 'st_reason' => $this->msg( 'securepoll-header-reason' )->escaped(), |
67 | ]; |
68 | } |
69 | |
70 | public function getTitle() { |
71 | return $this->detailsPage->getTitle(); |
72 | } |
73 | |
74 | protected function isFieldSortable( $field ) { |
75 | return $field === 'st_timestamp'; |
76 | } |
77 | } |