21 use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
34 use ProtectedHookAccessorTrait;
68 $this->showThumb = $context->getConfig()->get( MainConfigNames::ShowArchiveThumbnails ) &&
69 $this->img->canRender();
92 $this->
getOutput()->addModuleStyles(
'mediawiki.interface.helpers.styles' );
95 $canDelete = $this->current->isLocal() &&
96 $this->
getAuthority()->isAllowedAny(
'delete',
'deletedhistory' );
100 $canDelete ?
'' :
null,
102 $this->showThumb ?
'filehist-thumb' :
null,
103 'filehist-dimensions',
107 if ( $key !==
null ) {
108 $html .= Html::element(
'th', [], $key ? $this->
msg( $key )->text() :
'' );
112 return Html::openElement(
'table', [
'class' =>
'wikitable filehistory' ] ) .
"\n"
113 . Html::rawElement(
'tr', [], $html ) .
"\n";
120 return Html::closeElement(
'table' ) .
"\n";
133 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
139 $local = $this->current->isLocal();
143 if ( $local && ( $this->
getAuthority()->isAllowedAny(
'delete',
'deletedhistory' ) ) ) {
144 $row .= Html::openElement(
'td' );
145 # Link to hide content. Don't show useless link to people who cannot hide revisions.
146 if ( !$iscur && $this->
getAuthority()->isAllowed(
'deleterevision' ) ) {
149 $row .= Html::check(
'deleterevisions',
false, [
'disabled' =>
'disabled' ] );
151 $row .= Html::check(
'ids[' . explode(
'!',
$img, 2 )[0] .
']',
false );
157 # Link to remove from history
159 if (
$file->exists() ) {
160 $row .= $linkRenderer->makeKnownLink(
162 $this->
msg( $iscur ?
'filehist-deleteall' :
'filehist-deleteone' )->text(),
164 [
'action' =>
'delete',
'oldimage' => $iscur ?
null :
$img ]
168 $row .= $this->
msg(
'filehist-missing' )->escaped();
172 $row .= Html::closeElement(
'td' );
176 $row .= Html::openElement(
'td' );
178 $row .= $this->
msg(
'filehist-current' )->escaped();
179 } elseif ( $local && $this->
getAuthority()->probablyCan(
'edit', $this->title )
180 && $this->
getAuthority()->probablyCan(
'upload', $this->title )
183 $row .= $this->
msg(
'filehist-revert' )->escaped();
184 } elseif ( !
$file->exists() ) {
186 $row .= $this->
msg(
'filehist-missing' )->escaped();
188 $row .= $linkRenderer->makeKnownLink(
190 $this->
msg(
'filehist-revert' )->text(),
193 'action' =>
'revert',
199 $row .= Html::closeElement(
'td' );
202 $selected =
$file->getTimestamp() === $this->img->getTimestamp();
203 $row .= Html::openElement(
'td', [
204 'class' => $selected ?
'filehistory-selected' :
null,
205 'style' =>
'white-space: nowrap;'
208 # Don't link to unviewable files
209 $row .= Html::element(
'span', [
'class' =>
'history-deleted' ],
210 $lang->userTimeAndDate( $timestamp, $user )
213 $timeAndDate =
$lang->userTimeAndDate( $timestamp, $user );
216 # Make a link to review the image
217 $url = $linkRenderer->makeKnownLink(
222 'target' => $this->title->getPrefixedText(),
224 'token' => $user->getEditToken(
$img )
228 $url = htmlspecialchars( $timeAndDate );
230 $row .= Html::rawElement(
'span', [
'class' =>
'history-deleted' ], $url );
231 } elseif ( !
$file->exists() ) {
232 $row .= Html::element(
'span', [
'class' =>
'mw-file-missing' ],
233 $lang->userTimeAndDate( $timestamp, $user )
236 $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl(
$img );
237 $row .= Html::element(
'a', [
'href' => $url ],
238 $lang->userTimeAndDate( $timestamp, $user )
241 $row .= Html::closeElement(
'td' );
244 if ( $this->showThumb ) {
245 $row .= Html::rawElement(
'td', [],
251 $row .= Html::openElement(
'td' );
252 $row .= htmlspecialchars(
$file->getDimensionsString() );
253 $row .= $this->
msg(
'word-separator' )->escaped();
254 $row .= Html::element(
'span', [
'style' =>
'white-space: nowrap;' ],
255 $this->
msg(
'parentheses' )->sizeParams(
$file->getSize() )->text()
257 $row .= Html::closeElement(
'td' );
260 $row .= Html::openElement(
'td' );
262 if ( $uploader && $local ) {
263 $row .= Linker::userLink( $uploader->getId(), $uploader->getName() );
264 $row .= Html::rawElement(
'span', [
'style' =>
'white-space: nowrap;' ],
265 Linker::userToolLinks( $uploader->getId(), $uploader->getName() )
267 } elseif ( $uploader ) {
268 $row .= htmlspecialchars( $uploader->getName() );
270 $row .= Html::element(
'span', [
'class' =>
'history-deleted' ],
271 $this->
msg(
'rev-deleted-user' )->text()
274 $row .= Html::closeElement(
'td' );
278 $row .= Html::rawElement(
'td', [],
279 Html::element(
'span', [
'class' =>
'history-deleted' ],
280 $this->
msg(
'rev-deleted-comment' )->text()
284 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
285 $row .= Html::rawElement(
'td', [
'dir' => $contLang->getDir() ], $formattedComment );
289 $this->getHookRunner()->onImagePageFileHistoryLine( $this,
$file, $row, $rowClass );
291 return Html::rawElement(
'tr', [
'class' => $rowClass ], $row ) .
"\n";
301 if ( !
$file->allowInlineDisplay() ||
308 $thumbnail =
$file->transform(
313 'isFilePageThumb' => $iscur
323 'filehist-thumbtext',
324 $lang->userTimeAndDate( $timestamp, $user ),
325 $lang->userDate( $timestamp, $user ),
326 $lang->userTime( $timestamp, $user )
328 return $thumbnail->toHtml( [
'alt' => $alt,
'file-link' =>
true ] );
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getContext()
Gets the context this Article is executed in.
getTitle()
Get the title object of the article.
getPage()
Get the WikiPage object of this instance.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
setContext(IContextSource $context)
Builds the image revision log shown on image pages.
preventClickjacking( $enable=true)
getThumbForLine( $file, $iscur)
setPreventClickjacking(bool $enable)
imageHistoryLine( $iscur, $file, $formattedComment)
A class containing constants representing the names of configuration variables.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!isset( $args[0])) $lang