69 parent::__construct( $article,
$context );
70 $this->contentLanguage = $contentLanguage;
71 $this->repoGroup = $repoGroup;
96 $rights = [
'reupload' ];
97 if ( $user->
equals( $this->getFile()->getUploader() ) ) {
99 array_unshift( $rights,
'reupload-own' );
105 parent::checkCanExecute( $user );
107 $oldimage = $this->
getRequest()->getText(
'oldimage' );
108 if ( strlen( $oldimage ) < 16
109 || strpos( $oldimage,
'/' ) !==
false
110 || strpos( $oldimage,
'\\' ) !==
false
112 throw new ErrorPageError(
'internalerror',
'unexpected', [
'oldimage', $oldimage ] );
115 $this->oldFile = $this->repoGroup->getLocalRepo()
116 ->newFromArchiveName( $this->
getTitle(), $oldimage );
118 if ( !$this->oldFile->exists() ) {
137 $timestamp = $this->oldFile->getTimestamp();
141 $userDate = $lang->userDate( $timestamp, $user );
142 $userTime = $lang->userTime( $timestamp, $user );
143 $siteTs = MWTimestamp::getLocalInstance( $timestamp );
144 $ts = $siteTs->format(
'YmdHis' );
145 $contLang = $this->contentLanguage;
146 $siteDate = $contLang->date( $ts,
false,
false );
147 $siteTime = $contLang->time( $ts,
false,
false );
148 $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
154 'default' => $this->
msg(
'filerevert-intro',
155 $this->
getTitle()->getText(), $userDate, $userTime,
166 'label-message' =>
'filerevert-comment',
167 'default' => $this->
msg(
'filerevert-defaultcomment', $siteDate, $siteTime,
168 $tzMsg )->inContentLanguage()->text()
177 $old = $this->
getRequest()->getText(
'oldimage' );
179 $localFile = $this->getFile();
180 '@phan-var LocalFile $localFile';
181 $oldFile = OldLocalFile::newFromArchiveName( $this->
getTitle(), $localFile->getRepo(), $old );
183 $source = $localFile->getArchiveVirtualUrl( $old );
184 $comment = $data[
'comment'];
187 return Status::newFatal(
'filerevert-identical' );
191 return $localFile->upload(
207 $timestamp = $this->oldFile->getTimestamp();
210 $userDate = $lang->userDate( $timestamp, $user );
211 $userTime = $lang->userTime( $timestamp, $user );
213 $this->
getOutput()->addWikiMsg(
'filerevert-success', $this->
getTitle()->getText(),
214 $userDate, $userTime,
227 return $this->
msg(
'filerevert' )->plaintextParams( $this->
getTitle()->getText() );
232 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() )->escaped();
244 private function getFile():
File {
248 return $wikiPage->getFile();
253class_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.