57 parent::__construct( $article, $context );
58 $this->contentLanguage = $contentLanguage;
59 $this->repoGroup = $repoGroup;
79 parent::checkCanExecute( $user );
81 $oldimage = $this->
getRequest()->getText(
'oldimage' );
82 if ( strlen( $oldimage ) < 16
83 || strpos( $oldimage,
'/' ) !==
false
84 || strpos( $oldimage,
'\\' ) !==
false
86 throw new ErrorPageError(
'internalerror',
'unexpected', [
'oldimage', $oldimage ] );
89 $this->oldFile = $this->repoGroup->getLocalRepo()
90 ->newFromArchiveName( $this->
getTitle(), $oldimage );
92 if ( !$this->oldFile->exists() ) {
102 $form->setWrapperLegendMsg(
'filerevert-legend' );
103 $form->setSubmitTextMsg(
'filerevert-submit' );
104 $form->addHiddenField(
'oldimage', $this->
getRequest()->getText(
'oldimage' ) );
105 $form->setTokenSalt( [
'revert', $this->
getTitle()->getPrefixedDBkey() ] );
109 $timestamp = $this->oldFile->getTimestamp();
113 $userDate = $lang->userDate( $timestamp, $user );
114 $userTime = $lang->userTime( $timestamp, $user );
115 $siteTs = MWTimestamp::getLocalInstance( $timestamp );
116 $ts = $siteTs->format(
'YmdHis' );
117 $contLang = $this->contentLanguage;
118 $siteDate = $contLang->date( $ts,
false,
false );
119 $siteTime = $contLang->time( $ts,
false,
false );
120 $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
126 'default' => $this->
msg(
'filerevert-intro',
127 $this->
getTitle()->getText(), $userDate, $userTime,
128 (
string)MediaWikiServices::getInstance()->getUrlUtils()->expand(
138 'label-message' =>
'filerevert-comment',
139 'default' => $this->
msg(
'filerevert-defaultcomment', $siteDate, $siteTime,
140 $tzMsg )->inContentLanguage()->text()
148 $old = $this->
getRequest()->getText(
'oldimage' );
151 '@phan-var LocalFile $localFile';
152 $oldFile = OldLocalFile::newFromArchiveName( $this->
getTitle(), $localFile->getRepo(), $old );
154 $source = $localFile->getArchiveVirtualUrl( $old );
155 $comment = $data[
'comment'];
157 if ( $localFile->getSha1() === $oldFile->
getSha1() ) {
158 return Status::newFatal(
'filerevert-identical' );
162 return $localFile->upload(
177 $timestamp = $this->oldFile->getTimestamp();
180 $userDate = $lang->userDate( $timestamp, $user );
181 $userTime = $lang->userTime( $timestamp, $user );
183 $this->
getOutput()->addWikiMsg(
'filerevert-success', $this->
getTitle()->getText(),
184 $userDate, $userTime,
185 (
string)MediaWikiServices::getInstance()->getUrlUtils()->expand(
196 return $this->
msg(
'filerevert' )->plaintextParams( $this->
getTitle()->getText() );
200 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() )->escaped();
213 $wikiPage = $this->getWikiPage();
215 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...
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.