Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
21 / 21 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
SpecialGlobalWatchlist | |
100.00% |
21 / 21 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
1 | |||
getGroupName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isListed | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * Special:GlobalWatchlist is implemented in JavaScript; load the relevant ResourceLoader module. |
5 | * |
6 | * See docs/GlobalWatchlist.md for details of how the JavaScript works. |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU General Public License along |
19 | * with this program; if not, write to the Free Software Foundation, Inc., |
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21 | * http://www.gnu.org/copyleft/gpl.html |
22 | * |
23 | * @file |
24 | * @ingroup SpecialPage |
25 | */ |
26 | |
27 | namespace MediaWiki\Extension\GlobalWatchlist; |
28 | |
29 | use Html; |
30 | use IBufferingStatsdDataFactory; |
31 | use SpecialPage; |
32 | |
33 | /** |
34 | * @ingroup SpecialPage |
35 | * @author DannyS712 |
36 | */ |
37 | class SpecialGlobalWatchlist extends SpecialPage { |
38 | |
39 | /** @var IBufferingStatsdDataFactory */ |
40 | private $statsdDataFactory; |
41 | |
42 | /** |
43 | * @param IBufferingStatsdDataFactory $statsdDataFactory |
44 | */ |
45 | public function __construct( IBufferingStatsdDataFactory $statsdDataFactory ) { |
46 | parent::__construct( 'GlobalWatchlist', 'viewmywatchlist' ); |
47 | |
48 | $this->statsdDataFactory = $statsdDataFactory; |
49 | } |
50 | |
51 | /** |
52 | * @param string|null $par |
53 | */ |
54 | public function execute( $par ) { |
55 | $this->setHeaders(); |
56 | |
57 | $this->addHelpLink( 'Extension:GlobalWatchlist' ); |
58 | |
59 | $this->requireLogin( 'globalwatchlist-must-login' ); |
60 | |
61 | $config = $this->getConfig(); |
62 | |
63 | $out = $this->getOutput(); |
64 | $out->addModules( 'ext.globalwatchlist.specialglobalwatchlist' ); |
65 | |
66 | $out->addJsConfigVars( [ |
67 | 'wgGlobalWatchlistWikibaseSite' => $config->get( 'GlobalWatchlistWikibaseSite' ), |
68 | 'wgGlobalWatchlistDevMode' => $config->get( 'GlobalWatchlistDevMode' ) |
69 | ] ); |
70 | |
71 | // Until the JavaScript is loaded, show a message explaining that |
72 | // the page requires JavaScript. Once the JavaScript loads, the class is |
73 | // detected and the content is replaced by the actual global watchlist |
74 | $message = Html::rawElement( |
75 | 'div', |
76 | [ 'class' => 'ext-globalwatchlist-content' ], |
77 | $this->msg( 'globalwatchlist-javascript-required' ) |
78 | ); |
79 | $out->addHTML( $message ); |
80 | |
81 | $this->statsdDataFactory->increment( 'globalwatchlist.load_special_page' ); |
82 | } |
83 | |
84 | /** |
85 | * @return string |
86 | */ |
87 | protected function getGroupName() { |
88 | return 'changes'; |
89 | } |
90 | |
91 | /** |
92 | * Only shown for logged in users |
93 | * |
94 | * @return bool |
95 | */ |
96 | public function isListed() { |
97 | return $this->getUser()->isRegistered(); |
98 | } |
99 | |
100 | } |