Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
EntryPage | |
0.00% |
0 / 27 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
6 | |||
getTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\SecurePoll\Pages; |
4 | |
5 | use MediaWiki\Extension\SecurePoll\SpecialSecurePoll; |
6 | use MediaWiki\Linker\LinkRenderer; |
7 | use MediaWiki\SpecialPage\SpecialPage; |
8 | use MediaWiki\Title\Title; |
9 | use Wikimedia\Rdbms\ILoadBalancer; |
10 | |
11 | /** |
12 | * The entry page for SecurePoll. Shows a list of elections. |
13 | */ |
14 | class EntryPage extends ActionPage { |
15 | /** @var LinkRenderer */ |
16 | private $linkRenderer; |
17 | /** @var ILoadBalancer */ |
18 | private $loadBalancer; |
19 | |
20 | /** |
21 | * @param SpecialSecurePoll $specialPage |
22 | * @param LinkRenderer $linkRenderer |
23 | * @param ILoadBalancer $loadBalancer |
24 | */ |
25 | public function __construct( |
26 | SpecialSecurePoll $specialPage, |
27 | LinkRenderer $linkRenderer, |
28 | ILoadBalancer $loadBalancer |
29 | ) { |
30 | parent::__construct( $specialPage ); |
31 | $this->linkRenderer = $linkRenderer; |
32 | $this->loadBalancer = $loadBalancer; |
33 | } |
34 | |
35 | /** |
36 | * Execute the subpage. |
37 | * @param array $params Array of subpage parameters. |
38 | */ |
39 | public function execute( $params ) { |
40 | $pager = new MainElectionsPager( $this, $this->linkRenderer, $this->loadBalancer ); |
41 | $out = $this->specialPage->getOutput(); |
42 | $out->addWikiMsg( 'securepoll-entry-text' ); |
43 | $out->addParserOutputContent( |
44 | $pager->getBodyOutput(), |
45 | $this->context->getParserOptions() |
46 | ); |
47 | $out->addHTML( $pager->getNavigationBar() ); |
48 | |
49 | $links = [ |
50 | $this->linkRenderer->makeLink( |
51 | SpecialPage::getTitleFor( 'SecurePoll', 'archived' ), |
52 | $this->msg( 'securepoll-entry-archived' )->text() |
53 | ), |
54 | ]; |
55 | |
56 | if ( $this->specialPage->getUser()->isAllowed( 'securepoll-create-poll' ) ) { |
57 | $links[] = $this->linkRenderer->makeLink( |
58 | SpecialPage::getTitleFor( 'SecurePoll', 'create' ), |
59 | $this->msg( 'securepoll-entry-createpoll' )->text() |
60 | ); |
61 | } |
62 | |
63 | $subtitle = implode( ' | ', array_filter( $links, static function ( $link ) { |
64 | return (bool)$link; |
65 | } ) ); |
66 | |
67 | $out->setSubtitle( $subtitle ); |
68 | } |
69 | |
70 | /** |
71 | * @return Title |
72 | */ |
73 | public function getTitle() { |
74 | return $this->specialPage->getPageTitle( 'entry' ); |
75 | } |
76 | } |