MediaWiki master
SpecialEditRecovery.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Specials;
4
8
13
14 public function __construct(
15 private readonly UserOptionsLookup $userOptionsLookup,
16 ) {
17 parent::__construct( 'EditRecovery' );
18 }
19
21 protected function getGroupName() {
22 return 'changes';
23 }
24
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}
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
Parent class for all special pages.
getUser()
Shortcut to get the User executing this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct(private readonly UserOptionsLookup $userOptionsLookup,)
Provides access to user options.