53 parent::__construct( $page, $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';
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() );
196 return OutputPage::buildBacklinkSubtitle( $this->
getTitle() );
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.
getWikiPage()
Get a WikiPage object.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User 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...
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Class to represent a file in the oldimage table.
static newFromArchiveName( $title, $repo, $archiveName)
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> tag.
onSuccess()
Do something exciting on successful processing of the form.
getName()
Return the name of the action this object responds to.
Language $contentLanguage
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.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
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