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 / 1
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 / 17
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    public function __construct(
15        private readonly UserOptionsLookup $userOptionsLookup,
16    ) {
17        parent::__construct( 'EditRecovery' );
18    }
19
20    /** @inheritDoc */
21    protected function getGroupName() {
22        return 'changes';
23    }
24
25    /**
26     * @param string|null $subPage
27     */
28    public function execute( $subPage ) {
29        parent::execute( $subPage );
30        // Always add the help link, even for the error pages.
31        $this->addHelpLink( 'Help:Edit_Recovery' );
32
33        // Check that the user preference is enabled (the user is not necessarily logged in).
34        if ( !$this->userOptionsLookup->getOption( $this->getUser(), 'editrecovery' ) ) {
35            if ( !$this->getUser()->isNamed() ) {
36                // Pref is not enabled, and they aren't logged in.
37                $this->getOutput()->showErrorPage( 'editrecovery', 'edit-recovery-special-user-unnamed' );
38            } else {
39                // Pref is not enabled, but they are logged in so can enable it themselves.
40                $this->getOutput()->showErrorPage( 'editrecovery', 'edit-recovery-special-user-not-enabled' );
41            }
42            return;
43        }
44
45        $this->getOutput()->addModuleStyles( 'mediawiki.special.editrecovery.styles' );
46        $this->getOutput()->addModules( 'mediawiki.special.editrecovery' );
47        $this->getOutput()->addModuleStyles( 'mediawiki.codex.messagebox.styles' );
48        $noJs = Html::errorBox(
49            $this->msg( 'edit-recovery-nojs-placeholder' )->parse(),
50            '',
51            'mw-special-EditRecovery-nojs-notice'
52        );
53        $placeholder = Html::rawElement( 'div', [ 'class' => 'mw-special-EditRecovery-app' ], $noJs );
54        $this->getOutput()->addHTML( $placeholder );
55    }
56}