MediaWiki master
SpecialEditRecovery.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Specials;
4
8
13
15 private $userOptionsLookup;
16
17 public function __construct( UserOptionsLookup $userOptionsLookup ) {
18 parent::__construct( 'EditRecovery' );
19 $this->userOptionsLookup = $userOptionsLookup;
20 }
21
23 protected function getGroupName() {
24 return 'changes';
25 }
26
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}
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(UserOptionsLookup $userOptionsLookup)
Provides access to user options.