43 private Language $contentLanguage;
55 Language $contentLanguage,
58 parent::__construct( $article, $context );
59 $this->contentLanguage = $contentLanguage;
60 $this->repoGroup = $repoGroup;
80 parent::checkCanExecute( $user );
82 $oldimage = $this->
getRequest()->getText(
'oldimage' );
83 if ( strlen( $oldimage ) < 16
84 || strpos( $oldimage,
'/' ) !==
false
85 || strpos( $oldimage,
'\\' ) !==
false
87 throw new ErrorPageError(
'internalerror',
'unexpected', [
'oldimage', $oldimage ] );
90 $this->oldFile = $this->repoGroup->getLocalRepo()
91 ->newFromArchiveName( $this->
getTitle(), $oldimage );
93 if ( !$this->oldFile->exists() ) {
110 $timestamp = $this->oldFile->getTimestamp();
114 $userDate = $lang->userDate( $timestamp, $user );
115 $userTime = $lang->userTime( $timestamp, $user );
116 $siteTs = MWTimestamp::getLocalInstance( $timestamp );
117 $ts = $siteTs->format(
'YmdHis' );
118 $contLang = $this->contentLanguage;
119 $siteDate = $contLang->date( $ts,
false,
false );
120 $siteTime = $contLang->time( $ts,
false,
false );
121 $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
127 'default' => $this->
msg(
'filerevert-intro',
128 $this->
getTitle()->getText(), $userDate, $userTime,
129 (
string)MediaWikiServices::getInstance()->getUrlUtils()->expand(
139 'label-message' =>
'filerevert-comment',
140 'default' => $this->
msg(
'filerevert-defaultcomment', $siteDate, $siteTime,
141 $tzMsg )->inContentLanguage()->text()
149 $old = $this->
getRequest()->getText(
'oldimage' );
152 '@phan-var LocalFile $localFile';
153 $oldFile = OldLocalFile::newFromArchiveName( $this->
getTitle(), $localFile->getRepo(), $old );
155 $source = $localFile->getArchiveVirtualUrl( $old );
156 $comment = $data[
'comment'];
158 if ( $localFile->getSha1() === $oldFile->
getSha1() ) {
159 return Status::newFatal(
'filerevert-identical' );
163 return $localFile->upload(
178 $timestamp = $this->oldFile->getTimestamp();
181 $userDate = $lang->userDate( $timestamp, $user );
182 $userTime = $lang->userTime( $timestamp, $user );
184 $this->
getOutput()->addWikiMsg(
'filerevert-success', $this->
getTitle()->getText(),
185 $userDate, $userTime,
186 (
string)MediaWikiServices::getInstance()->getUrlUtils()->expand(
197 return $this->
msg(
'filerevert' )->plaintextParams( $this->
getTitle()->getText() );
201 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() )->escaped();
214 $wikiPage = $this->getWikiPage();
216 return $wikiPage->getFile();
getFile()
Get the file for this page, if one exists.
getOutput()
Get the OutputPage 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.
Legacy class representing an editable page and handling UI for some page actions.
An error page which can definitely be safely rendered using the OutputPage.
Implements some public methods and some protected utility functions which are required by multiple ch...
This is one of the Core classes and should be read at least once by any new developers.
Old file in the oldimage table.
Prioritized list of file repositories.
File reversion user interface WikiPage must contain getFile method: \WikiFilePage Article::getFile is...
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.
__construct(Article $article, IContextSource $context, Language $contentLanguage, RepoGroup $repoGroup)
getDescription()
Returns the description that goes below the <h1> element.
onSuccess()
Do something exciting on successful processing of the form.
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.
Interface for objects which can provide a MediaWiki context on request.