Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
SpecialEditRecovery | |
0.00% |
0 / 19 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | /** |
3 | * @file |
4 | * @ingroup SpecialPage |
5 | */ |
6 | |
7 | namespace MediaWiki\Specials; |
8 | |
9 | use MediaWiki\Html\Html; |
10 | use MediaWiki\SpecialPage\SpecialPage; |
11 | use MediaWiki\User\Options\UserOptionsLookup; |
12 | |
13 | /** |
14 | * @ingroup SpecialPage |
15 | */ |
16 | class SpecialEditRecovery extends SpecialPage { |
17 | |
18 | /** @var UserOptionsLookup */ |
19 | private $userOptionsLookup; |
20 | |
21 | public function __construct( UserOptionsLookup $userOptionsLookup ) { |
22 | parent::__construct( 'EditRecovery' ); |
23 | $this->userOptionsLookup = $userOptionsLookup; |
24 | } |
25 | |
26 | protected function getGroupName() { |
27 | return 'changes'; |
28 | } |
29 | |
30 | /** |
31 | * @param string|null $subPage |
32 | */ |
33 | public function execute( $subPage ) { |
34 | parent::execute( $subPage ); |
35 | // Always add the help link, even for the error pages. |
36 | $this->addHelpLink( 'Help:Edit_Recovery' ); |
37 | |
38 | // Check that the user preference is enabled (the user is not necessarily logged in). |
39 | if ( !$this->userOptionsLookup->getOption( $this->getUser(), 'editrecovery' ) ) { |
40 | if ( !$this->getUser()->isNamed() ) { |
41 | // Pref is not enabled, and they aren't logged in. |
42 | $this->getOutput()->showErrorPage( 'editrecovery', 'edit-recovery-special-user-unnamed' ); |
43 | } else { |
44 | // Pref is not enabled, but they are logged in so can enable it themselves. |
45 | $this->getOutput()->showErrorPage( 'editrecovery', 'edit-recovery-special-user-not-enabled' ); |
46 | } |
47 | return; |
48 | } |
49 | |
50 | $this->getOutput()->addModuleStyles( 'mediawiki.special.editrecovery.styles' ); |
51 | $this->getOutput()->addModules( 'mediawiki.special.editrecovery' ); |
52 | $noJs = Html::element( |
53 | 'span', |
54 | [ 'class' => 'error mw-EditRecovery-special-nojs-notice' ], |
55 | $this->msg( 'edit-recovery-nojs-placeholder' ) |
56 | ); |
57 | $placeholder = Html::rawElement( 'div', [ 'class' => 'mw-EditRecovery-special' ], $noJs ); |
58 | $this->getOutput()->addHTML( $placeholder ); |
59 | } |
60 | } |