69 parent::__construct( $article,
$context );
70 $this->contentLanguage = $contentLanguage;
71 $this->repoGroup = $repoGroup;
93 $rights = [
'reupload' ];
94 if ( $user->
equals( $this->getFile()->getUploader() ) ) {
96 array_unshift( $rights,
'reupload-own' );
102 parent::checkCanExecute( $user );
104 $oldimage = $this->
getRequest()->getText(
'oldimage' );
105 if ( strlen( $oldimage ) < 16
106 || strpos( $oldimage,
'/' ) !==
false
107 || strpos( $oldimage,
'\\' ) !==
false
109 throw new ErrorPageError(
'internalerror',
'unexpected', [
'oldimage', $oldimage ] );
112 $this->oldFile = $this->repoGroup->getLocalRepo()
113 ->newFromArchiveName( $this->
getTitle(), $oldimage );
115 if ( !$this->oldFile->exists() ) {
132 $timestamp = $this->oldFile->getTimestamp();
136 $userDate = $lang->userDate( $timestamp, $user );
137 $userTime = $lang->userTime( $timestamp, $user );
138 $siteTs = MWTimestamp::getLocalInstance( $timestamp );
139 $ts = $siteTs->format(
'YmdHis' );
140 $contLang = $this->contentLanguage;
141 $siteDate = $contLang->date( $ts,
false,
false );
142 $siteTime = $contLang->time( $ts,
false,
false );
143 $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
149 'default' => $this->
msg(
'filerevert-intro',
150 $this->
getTitle()->getText(), $userDate, $userTime,
161 'label-message' =>
'filerevert-comment',
162 'default' => $this->
msg(
'filerevert-defaultcomment', $siteDate, $siteTime,
163 $tzMsg )->inContentLanguage()->text()
171 $old = $this->
getRequest()->getText(
'oldimage' );
173 $localFile = $this->getFile();
174 '@phan-var LocalFile $localFile';
175 $oldFile = OldLocalFile::newFromArchiveName( $this->
getTitle(), $localFile->getRepo(), $old );
177 $source = $localFile->getArchiveVirtualUrl( $old );
178 $comment = $data[
'comment'];
181 return Status::newFatal(
'filerevert-identical' );
185 return $localFile->upload(
200 $timestamp = $this->oldFile->getTimestamp();
203 $userDate = $lang->userDate( $timestamp, $user );
204 $userTime = $lang->userTime( $timestamp, $user );
206 $this->
getOutput()->addWikiMsg(
'filerevert-success', $this->
getTitle()->getText(),
207 $userDate, $userTime,
219 return $this->
msg(
'filerevert' )->plaintextParams( $this->
getTitle()->getText() );
223 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() )->escaped();
234 private function getFile():
File {
238 return $wikiPage->getFile();
243class_alias( RevertAction::class,
'RevertAction' );
An error page which can definitely be safely rendered using the OutputPage.
This is one of the Core classes and should be read at least once by any new developers.
Legacy class representing an editable page and handling UI for some page actions.
Special handling for representing file pages.
Interface for objects which can provide a MediaWiki context on request.