36 private $contentLanguage;
53 parent::__construct( $article, $context );
54 $this->contentLanguage = $contentLanguage;
55 $this->repoGroup = $repoGroup;
75 parent::checkCanExecute( $user );
77 $oldimage = $this->
getRequest()->getText(
'oldimage' );
78 if ( strlen( $oldimage ) < 16
79 || strpos( $oldimage,
'/' ) !==
false
80 || strpos( $oldimage,
'\\' ) !==
false
82 throw new ErrorPageError(
'internalerror',
'unexpected', [
'oldimage', $oldimage ] );
85 $this->oldFile = $this->repoGroup->getLocalRepo()
86 ->newFromArchiveName( $this->
getTitle(), $oldimage );
88 if ( !$this->oldFile->exists() ) {
105 $timestamp = $this->oldFile->getTimestamp();
109 $userDate =
$lang->userDate( $timestamp, $user );
110 $userTime =
$lang->userTime( $timestamp, $user );
111 $siteTs = MWTimestamp::getLocalInstance( $timestamp );
112 $ts = $siteTs->format(
'YmdHis' );
113 $contLang = $this->contentLanguage;
114 $siteDate = $contLang->date( $ts,
false,
false );
115 $siteTime = $contLang->time( $ts,
false,
false );
116 $tzMsg = $siteTs->getTimezoneMessage()->inContentLanguage()->text();
122 'default' => $this->
msg(
'filerevert-intro',
123 $this->
getTitle()->getText(), $userDate, $userTime,
134 'label-message' =>
'filerevert-comment',
135 'default' => $this->
msg(
'filerevert-defaultcomment', $siteDate, $siteTime,
136 $tzMsg )->inContentLanguage()->text()
144 $old = $this->
getRequest()->getText(
'oldimage' );
147 '@phan-var LocalFile $localFile';
148 $oldFile = OldLocalFile::newFromArchiveName( $this->
getTitle(), $localFile->getRepo(), $old );
150 $source = $localFile->getArchiveVirtualUrl( $old );
151 $comment = $data[
'comment'];
153 if ( $localFile->getSha1() === $oldFile->
getSha1() ) {
154 return Status::newFatal(
'filerevert-identical' );
158 return $localFile->upload(
173 $timestamp = $this->oldFile->getTimestamp();
176 $userDate =
$lang->userDate( $timestamp, $user );
177 $userTime =
$lang->userTime( $timestamp, $user );
179 $this->
getOutput()->addWikiMsg(
'filerevert-success', $this->
getTitle()->getText(),
180 $userDate, $userTime,
192 return $this->
msg(
'filerevert', $this->
getTitle()->getText() )->text();
196 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() )->escaped();
209 $wikiPage = $this->getWikiPage();
211 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.
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.
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.
if(!isset( $args[0])) $lang