44 private readonly
Language $contentLanguage,
48 parent::__construct( $article,
$context );
73 $rights = [
'reupload' ];
74 if ( $user->
equals( $this->getFile()->getUploader() ) ) {
76 array_unshift( $rights,
'reupload-own' );
82 parent::checkCanExecute( $user );
84 $oldimage = $this->
getRequest()->getText(
'oldimage' );
85 if ( strlen( $oldimage ) < 16
86 || str_contains( $oldimage,
'/' )
87 || str_contains( $oldimage,
'\\' )
89 throw new ErrorPageError(
'internalerror',
'unexpected', [
'oldimage', $oldimage ] );
92 $this->oldFile = $this->repoGroup->getLocalRepo()
93 ->newFromArchiveName( $this->
getTitle(), $oldimage );
95 if ( !$this->oldFile->exists() ) {
114 $timestamp = $this->oldFile->getTimestamp();
118 $userDate = $lang->userDate( $timestamp, $user );
119 $userTime = $lang->userTime( $timestamp, $user );
120 $siteTs = MWTimestamp::getLocalInstance( $timestamp );
121 $ts = $siteTs->format(
'YmdHis' );
122 $contLang = $this->contentLanguage;
123 $siteDate = $contLang->date( $ts,
false,
false );
124 $siteTime = $contLang->time( $ts,
false,
false );
125 $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
131 'default' => $this->
msg(
'filerevert-intro',
132 $this->
getTitle()->getText(), $userDate, $userTime,
133 (
string)$this->urlUtils->expand(
136 $this->getRequest()->getText(
'oldimage' )
143 'label-message' =>
'filerevert-comment',
144 'default' => $this->
msg(
'filerevert-defaultcomment', $siteDate, $siteTime,
145 $tzMsg )->inContentLanguage()->text()
154 $old = $this->
getRequest()->getText(
'oldimage' );
156 $localFile = $this->getFile();
157 '@phan-var LocalFile $localFile';
158 $oldFile = OldLocalFile::newFromArchiveName( $this->
getTitle(), $localFile->getRepo(), $old );
160 $source = $localFile->getArchiveVirtualUrl( $old );
161 $comment = $data[
'comment'];
164 return Status::newFatal(
'filerevert-identical' );
168 return $localFile->upload(
184 $timestamp = $this->oldFile->getTimestamp();
187 $userDate = $lang->userDate( $timestamp, $user );
188 $userTime = $lang->userTime( $timestamp, $user );
190 $this->
getOutput()->addWikiMsg(
'filerevert-success', $this->
getTitle()->getText(),
191 $userDate, $userTime,
192 (
string)$this->urlUtils->expand(
195 $this->getRequest()->getText(
'oldimage' )
204 return $this->
msg(
'filerevert' )->plaintextParams( $this->
getTitle()->getText() );
209 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() )->escaped();
221 private function getFile():
File {
225 return $wikiPage->getFile();
230class_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.