56 parent::__construct( $article, $context );
57 $this->contentLanguage = $contentLanguage;
58 $this->repoGroup = $repoGroup;
78 parent::checkCanExecute( $user );
80 $oldimage = $this->
getRequest()->getText(
'oldimage' );
81 if ( strlen( $oldimage ) < 16
82 || strpos( $oldimage,
'/' ) !==
false
83 || strpos( $oldimage,
'\\' ) !==
false
85 throw new ErrorPageError(
'internalerror',
'unexpected', [
'oldimage', $oldimage ] );
88 $this->oldFile = $this->repoGroup->getLocalRepo()
89 ->newFromArchiveName( $this->
getTitle(), $oldimage );
91 if ( !$this->oldFile->exists() ) {
108 $timestamp = $this->oldFile->getTimestamp();
112 $userDate = $lang->userDate( $timestamp, $user );
113 $userTime = $lang->userTime( $timestamp, $user );
114 $siteTs = MWTimestamp::getLocalInstance( $timestamp );
115 $ts = $siteTs->format(
'YmdHis' );
116 $contLang = $this->contentLanguage;
117 $siteDate = $contLang->date( $ts,
false,
false );
118 $siteTime = $contLang->time( $ts,
false,
false );
119 $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
125 'default' => $this->
msg(
'filerevert-intro',
126 $this->
getTitle()->getText(), $userDate, $userTime,
127 (
string)MediaWikiServices::getInstance()->getUrlUtils()->expand(
137 'label-message' =>
'filerevert-comment',
138 'default' => $this->
msg(
'filerevert-defaultcomment', $siteDate, $siteTime,
139 $tzMsg )->inContentLanguage()->text()
147 $old = $this->
getRequest()->getText(
'oldimage' );
150 '@phan-var LocalFile $localFile';
151 $oldFile = OldLocalFile::newFromArchiveName( $this->
getTitle(), $localFile->getRepo(), $old );
153 $source = $localFile->getArchiveVirtualUrl( $old );
154 $comment = $data[
'comment'];
156 if ( $localFile->getSha1() === $oldFile->
getSha1() ) {
157 return Status::newFatal(
'filerevert-identical' );
161 return $localFile->upload(
176 $timestamp = $this->oldFile->getTimestamp();
179 $userDate = $lang->userDate( $timestamp, $user );
180 $userTime = $lang->userTime( $timestamp, $user );
182 $this->
getOutput()->addWikiMsg(
'filerevert-success', $this->
getTitle()->getText(),
183 $userDate, $userTime,
184 (
string)MediaWikiServices::getInstance()->getUrlUtils()->expand(
195 return $this->
msg(
'filerevert' )->plaintextParams( $this->
getTitle()->getText() );
199 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() )->escaped();
212 $wikiPage = $this->getWikiPage();
214 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.
getRequest()
Get the WebRequest 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...
Base class for language-specific code.
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.