51 parent::checkCanExecute( $user );
53 $oldimage = $this->
getRequest()->getText(
'oldimage' );
54 if ( strlen( $oldimage ) < 16
55 || strpos( $oldimage,
'/' ) !==
false
56 || strpos( $oldimage,
'\\' ) !==
false
58 throw new ErrorPageError(
'internalerror',
'unexpected', [
'oldimage', $oldimage ] );
61 $this->oldFile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName(
66 if ( !$this->oldFile->exists() ) {
83 $timestamp = $this->oldFile->getTimestamp();
87 $userDate =
$lang->userDate( $timestamp, $user );
88 $userTime =
$lang->userTime( $timestamp, $user );
89 $siteTs = MWTimestamp::getLocalInstance( $timestamp );
90 $ts = $siteTs->format(
'YmdHis' );
91 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
92 $siteDate = $contLang->date( $ts,
false,
false );
93 $siteTime = $contLang->time( $ts,
false,
false );
94 $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
99 'vertical-label' =>
true,
101 'default' => $this->
msg(
'filerevert-intro',
102 $this->
getTitle()->getText(), $userDate, $userTime,
104 $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText(
'oldimage' ) ),
110 'label-message' =>
'filerevert-comment',
111 'default' => $this->
msg(
'filerevert-defaultcomment', $siteDate, $siteTime,
112 $tzMsg )->inContentLanguage()->text()
120 $old = $this->
getRequest()->getText(
'oldimage' );
122 $localFile = $this->page->getFile();
123 '@phan-var LocalFile $localFile';
126 $source = $localFile->getArchiveVirtualUrl( $old );
127 $comment = $data[
'comment'];
130 return Status::newFatal(
'filerevert-identical' );
134 return $localFile->upload(
149 $timestamp = $this->oldFile->getTimestamp();
152 $userDate =
$lang->userDate( $timestamp, $user );
153 $userTime =
$lang->userTime( $timestamp, $user );
155 $this->
getOutput()->addWikiMsg(
'filerevert-success', $this->
getTitle()->getText(),
156 $userDate, $userTime,
157 wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText(
'oldimage' ) ),
164 return $this->
msg(
'filerevert', $this->
getTitle()->getText() );
168 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() );
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
getTitle()
Shortcut to get the Title object from the page.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User being used for this instance.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getLanguage()
Shortcut to get the user Language being used for this instance.
getRequest()
Get the WebRequest being used for this instance.
An error page which can definitely be safely rendered using the OutputPage.
Class to represent a file in the oldimage table.
static newFromArchiveName( $title, $repo, $archiveName)
File reversion user interface.
usesOOUI()
Whether the form should use OOUI.
onSubmit( $data)
Process the form on POST submission.
getFormFields()
Get an HTMLForm descriptor array.
getPageTitle()
Returns the name that goes in the <h1> page title.
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
getDescription()
Returns the description that goes below the <h1> tag.
onSuccess()
Do something exciting on successful processing of the form.
doesWrites()
Indicates whether this action may perform database writes.
getName()
Return the name of the action this object responds to.
getRestriction()
Get the permission required to perform this action.
checkCanExecute(User $user)
Checks if the given user (identified by an object) can perform this action.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
if(!isset( $args[0])) $lang