MediaWiki master
SpecialEditRecovery.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
12
17
19 private $userOptionsLookup;
20
21 public function __construct( UserOptionsLookup $userOptionsLookup ) {
22 parent::__construct( 'EditRecovery' );
23 $this->userOptionsLookup = $userOptionsLookup;
24 }
25
26 protected function getGroupName() {
27 return 'changes';
28 }
29
33 public function execute( $subPage ) {
34 parent::execute( $subPage );
35 // Always add the help link, even for the error pages.
36 $this->addHelpLink( 'Help:Edit_Recovery' );
37
38 // Check that the user preference is enabled (the user is not necessarily logged in).
39 if ( !$this->userOptionsLookup->getOption( $this->getUser(), 'editrecovery' ) ) {
40 if ( !$this->getUser()->isNamed() ) {
41 // Pref is not enabled, and they aren't logged in.
42 $this->getOutput()->showErrorPage( 'editrecovery', 'edit-recovery-special-user-unnamed' );
43 } else {
44 // Pref is not enabled, but they are logged in so can enable it themselves.
45 $this->getOutput()->showErrorPage( 'editrecovery', 'edit-recovery-special-user-not-enabled' );
46 }
47 return;
48 }
49
50 $this->getOutput()->addModuleStyles( 'mediawiki.special.editrecovery.styles' );
51 $this->getOutput()->addModules( 'mediawiki.special.editrecovery' );
52 $noJs = Html::element(
53 'span',
54 [ 'class' => 'error mw-EditRecovery-special-nojs-notice' ],
55 $this->msg( 'edit-recovery-nojs-placeholder' )
56 );
57 $placeholder = Html::rawElement( 'div', [ 'class' => 'mw-EditRecovery-special' ], $noJs );
58 $this->getOutput()->addHTML( $placeholder );
59 }
60}
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)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...