2023-11-09 06:45:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Specials;
|
|
|
|
|
|
|
|
|
|
use MediaWiki\Html\Html;
|
|
|
|
|
use MediaWiki\SpecialPage\SpecialPage;
|
2024-04-15 11:58:19 +00:00
|
|
|
use MediaWiki\User\Options\UserOptionsLookup;
|
2023-11-09 06:45:31 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup SpecialPage
|
|
|
|
|
*/
|
|
|
|
|
class SpecialEditRecovery extends SpecialPage {
|
|
|
|
|
|
2024-04-15 11:58:19 +00:00
|
|
|
/** @var UserOptionsLookup */
|
|
|
|
|
private $userOptionsLookup;
|
|
|
|
|
|
|
|
|
|
public function __construct( UserOptionsLookup $userOptionsLookup ) {
|
2023-11-09 06:45:31 +00:00
|
|
|
parent::__construct( 'EditRecovery' );
|
2024-04-15 11:58:19 +00:00
|
|
|
$this->userOptionsLookup = $userOptionsLookup;
|
2023-11-09 06:45:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getGroupName() {
|
|
|
|
|
return 'changes';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string|null $subPage
|
|
|
|
|
*/
|
|
|
|
|
public function execute( $subPage ) {
|
|
|
|
|
parent::execute( $subPage );
|
2024-04-15 11:58:19 +00:00
|
|
|
// Always add the help link, even for the error pages.
|
2023-11-09 06:45:31 +00:00
|
|
|
$this->addHelpLink( 'Help:Edit_Recovery' );
|
2024-04-15 11:58:19 +00:00
|
|
|
|
|
|
|
|
// Check that the user preference is enabled (the user is not necessarily logged in).
|
|
|
|
|
if ( !$this->userOptionsLookup->getOption( $this->getUser(), 'editrecovery' ) ) {
|
|
|
|
|
if ( !$this->getUser()->isNamed() ) {
|
|
|
|
|
// Pref is not enabled, and they aren't logged in.
|
|
|
|
|
$this->getOutput()->showErrorPage( 'editrecovery', 'edit-recovery-special-user-unnamed' );
|
|
|
|
|
} else {
|
|
|
|
|
// Pref is not enabled, but they are logged in so can enable it themselves.
|
|
|
|
|
$this->getOutput()->showErrorPage( 'editrecovery', 'edit-recovery-special-user-not-enabled' );
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-09 06:45:31 +00:00
|
|
|
$this->getOutput()->addModuleStyles( 'mediawiki.special.editrecovery.styles' );
|
|
|
|
|
$this->getOutput()->addModules( 'mediawiki.special.editrecovery' );
|
|
|
|
|
$noJs = Html::element(
|
|
|
|
|
'span',
|
|
|
|
|
[ 'class' => 'error mw-EditRecovery-special-nojs-notice' ],
|
|
|
|
|
$this->msg( 'edit-recovery-nojs-placeholder' )
|
|
|
|
|
);
|
|
|
|
|
$placeholder = Html::rawElement( 'div', [ 'class' => 'mw-EditRecovery-special' ], $noJs );
|
|
|
|
|
$this->getOutput()->addHTML( $placeholder );
|
|
|
|
|
}
|
|
|
|
|
}
|