Debian Codegraph @

includes/specials/SpecialEditRecovery.php

raw symbols SCIP
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 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 }