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