36 private $contentLanguage;
53 parent::__construct( $page, $context );
54 $this->contentLanguage = $contentLanguage;
55 $this->repoGroup = $repoGroup;
77 $rights = [
'reupload' ];
78 if ( $user->
equals( $this->getFile()->getUploader() ) ) {
80 array_unshift( $rights,
'reupload-own' );
86 parent::checkCanExecute( $user );
88 $oldimage = $this->
getRequest()->getText(
'oldimage' );
89 if ( strlen( $oldimage ) < 16
90 || strpos( $oldimage,
'/' ) !==
false
91 || strpos( $oldimage,
'\\' ) !==
false
93 throw new ErrorPageError(
'internalerror',
'unexpected', [
'oldimage', $oldimage ] );
96 $this->oldFile = $this->repoGroup->getLocalRepo()
97 ->newFromArchiveName( $this->
getTitle(), $oldimage );
99 if ( !$this->oldFile->exists() ) {
116 $timestamp = $this->oldFile->getTimestamp();
120 $userDate =
$lang->userDate( $timestamp, $user );
121 $userTime =
$lang->userTime( $timestamp, $user );
122 $siteTs = MWTimestamp::getLocalInstance( $timestamp );
123 $ts = $siteTs->format(
'YmdHis' );
124 $contLang = $this->contentLanguage;
125 $siteDate = $contLang->date( $ts,
false,
false );
126 $siteTime = $contLang->time( $ts,
false,
false );
127 $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
133 'default' => $this->
msg(
'filerevert-intro',
134 $this->
getTitle()->getText(), $userDate, $userTime,
145 'label-message' =>
'filerevert-comment',
146 'default' => $this->
msg(
'filerevert-defaultcomment', $siteDate, $siteTime,
147 $tzMsg )->inContentLanguage()->text()
155 $old = $this->
getRequest()->getText(
'oldimage' );
158 '@phan-var LocalFile $localFile';
159 $oldFile = OldLocalFile::newFromArchiveName( $this->
getTitle(), $localFile->getRepo(), $old );
161 $source = $localFile->getArchiveVirtualUrl( $old );
162 $comment = $data[
'comment'];
164 if ( $localFile->getSha1() === $oldFile->
getSha1() ) {
165 return Status::newFatal(
'filerevert-identical' );
169 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,
203 return $this->
msg(
'filerevert', $this->
getTitle()->getText() )->text();
207 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() )->escaped();
220 $wikiPage = $this->getWikiPage();
222 return $wikiPage->getFile();
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
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.
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.
Old file in the oldimage table.
Show an error when a user tries to do something they do not have the necessary permissions for.
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(Page $page, 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.
equals(?UserIdentity $user)
Checks if two user objects point to the same user.
isAllowedAny(... $permissions)
Checks whether this authority has any of the given permissions in general.
Interface for objects which can provide a MediaWiki context on request.
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
if(!isset( $args[0])) $lang