Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 74 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
StablePages | |
0.00% |
0 / 74 |
|
0.00% |
0 / 6 |
156 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
showForm | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
12 | |||
showPageList | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
formatRow | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
20 | |||
getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | use MediaWiki\Html\Html; |
4 | use MediaWiki\MainConfigNames; |
5 | use MediaWiki\SpecialPage\SpecialPage; |
6 | use MediaWiki\Title\Title; |
7 | |
8 | // Assumes $wgFlaggedRevsProtection is on |
9 | class StablePages extends SpecialPage { |
10 | /** @var StablePagesPager */ |
11 | private $pager = null; |
12 | |
13 | /** @var int|null */ |
14 | private $namespace; |
15 | |
16 | /** @var string|null */ |
17 | private $autoreview; |
18 | |
19 | /** @var bool */ |
20 | private $indef; |
21 | |
22 | public function __construct() { |
23 | parent::__construct( 'StablePages' ); |
24 | } |
25 | |
26 | /** |
27 | * @inheritDoc |
28 | */ |
29 | public function execute( $par ) { |
30 | $request = $this->getRequest(); |
31 | |
32 | $this->setHeaders(); |
33 | $this->addHelpLink( 'Help:Extension:FlaggedRevs' ); |
34 | |
35 | $this->namespace = $request->getIntOrNull( 'namespace' ); |
36 | $this->autoreview = $request->getVal( 'restriction', '' ); |
37 | $this->indef = $request->getBool( 'indef' ); |
38 | |
39 | $this->pager = new StablePagesPager( $this, [], |
40 | $this->namespace, $this->autoreview, $this->indef ); |
41 | |
42 | $this->showForm(); |
43 | $this->showPageList(); |
44 | } |
45 | |
46 | private function showForm() { |
47 | $this->getOutput()->addWikiMsg( 'stablepages-list', |
48 | $this->getLanguage()->formatNum( $this->pager->getNumRows() ) ); |
49 | |
50 | $fields = []; |
51 | // Namespace selector |
52 | if ( count( FlaggedRevs::getReviewNamespaces() ) > 1 ) { |
53 | $fields[] = FlaggedRevsHTML::getNamespaceMenu( $this->namespace, '' ); |
54 | } |
55 | // Restriction level selector |
56 | if ( FlaggedRevs::getRestrictionLevels() ) { |
57 | $fields[] = FlaggedRevsHTML::getRestrictionFilterMenu( $this->autoreview ); |
58 | } |
59 | $fields[] = Html::element( 'input', [ |
60 | 'type' => 'checkbox', 'name' => 'indef', 'value' => '1', |
61 | 'checked' => $this->indef, |
62 | 'id' => 'stablepages-indef', |
63 | ] ) |
64 | . ' ' |
65 | . Html::label( $this->msg( 'stablepages-indef' )->text(), 'stablepages-indef' ); |
66 | |
67 | $form = Html::openElement( 'form', [ |
68 | 'name' => 'stablepages', |
69 | 'action' => $this->getConfig()->get( MainConfigNames::Script ), |
70 | 'method' => 'get', |
71 | ] ); |
72 | $form .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedDBkey() ); |
73 | $form .= "<fieldset><legend>" . $this->msg( 'stablepages' )->escaped() . "</legend>\n"; |
74 | $form .= implode( ' ', $fields ) . ' '; |
75 | $form .= ' ' . Html::submitButton( $this->msg( 'go' )->text() ); |
76 | $form .= "</fieldset>\n"; |
77 | $form .= Html::closeElement( 'form' ) . "\n"; |
78 | |
79 | $this->getOutput()->addHTML( $form ); |
80 | } |
81 | |
82 | private function showPageList() { |
83 | $out = $this->getOutput(); |
84 | if ( $this->pager->getNumRows() ) { |
85 | $out->addHTML( $this->pager->getNavigationBar() ); |
86 | $out->addHTML( $this->pager->getBody() ); |
87 | $out->addHTML( $this->pager->getNavigationBar() ); |
88 | } else { |
89 | $out->addWikiMsg( 'stablepages-none' ); |
90 | } |
91 | } |
92 | |
93 | /** |
94 | * @param stdClass $row |
95 | * @return string HTML |
96 | */ |
97 | public function formatRow( $row ) { |
98 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
99 | $linkRenderer = $this->getLinkRenderer(); |
100 | // Link to page |
101 | $link = $linkRenderer->makeLink( $title ); |
102 | // Helpful utility links |
103 | $utilLinks = []; |
104 | $utilLinks[] = $linkRenderer->makeKnownLink( |
105 | $title, |
106 | $this->msg( 'stablepages-config' )->text(), |
107 | [], [ 'action' => 'protect' ] ); |
108 | $utilLinks[] = $linkRenderer->makeKnownLink( |
109 | $title, |
110 | $this->msg( 'history' )->text(), |
111 | [], [ 'action' => 'history' ] ); |
112 | $utilLinks[] = $linkRenderer->makeKnownLink( |
113 | SpecialPage::getTitleFor( 'Log', 'stable' ), |
114 | $this->msg( 'stable-logpage' )->text(), |
115 | [], [ 'page' => $title->getPrefixedText() ] ); |
116 | // Autoreview/review restriction level |
117 | $restr = ''; |
118 | if ( $row->fpc_level != '' ) { |
119 | $restr = 'autoreview=' . htmlspecialchars( $row->fpc_level ); |
120 | $restr = "[$restr]"; |
121 | } |
122 | // When these configuration settings expire |
123 | if ( $row->fpc_expiry != 'infinity' && strlen( $row->fpc_expiry ) ) { |
124 | $expiry_description = " (" . $this->msg( |
125 | 'protect-expiring', |
126 | $this->getLanguage()->timeanddate( $row->fpc_expiry ), |
127 | $this->getLanguage()->date( $row->fpc_expiry ), |
128 | $this->getLanguage()->time( $row->fpc_expiry ) |
129 | )->inContentLanguage()->text() . ")"; |
130 | } else { |
131 | $expiry_description = ""; |
132 | } |
133 | $utilLinks = $this->getLanguage()->pipeList( $utilLinks ); |
134 | return "<li>{$link} ({$utilLinks}) {$restr}<i>{$expiry_description}</i></li>"; |
135 | } |
136 | |
137 | /** |
138 | * @return string |
139 | */ |
140 | protected function getGroupName() { |
141 | return 'quality'; |
142 | } |
143 | } |