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
22 protected function getGroupName() {
23 return 'changes';
24 }
25
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}
This class is a collection of static functions that serve two purposes:
Definition Html.php:56
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.
element(SerializerNode $parent, SerializerNode $node, $contents)