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