8 if( !defined( 'MEDIAWIKI' ) )
12 * Special handling for image description pages
16 class ImagePage
extends Article
{
18 /* private */ var $img; // Image object this page is shown for
19 /* private */ var $repo;
20 var $mExtraDescription = false;
22 function __construct( $title, $time = false ) {
23 parent
::__construct( $title );
24 $this->img
= wfFindFile( $this->mTitle
, $time );
26 $this->img
= wfLocalFile( $this->mTitle
);
27 $this->current
= $this->img
;
29 $this->current
= $time ?
wfLocalFile( $this->mTitle
) : $this->img
;
31 $this->repo
= $this->img
->repo
;
35 * Handler for action=render
36 * Include body text only; none of the image extras
40 $wgOut->setArticleBodyOnly( true );
45 global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
47 if ( $this->img
->getRedirected() )
48 return Article
::view();
50 $diff = $wgRequest->getVal( 'diff' );
51 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
53 if ( $this->mTitle
->getNamespace() != NS_IMAGE ||
( isset( $diff ) && $diffOnly ) )
54 return Article
::view();
56 if ($wgShowEXIF && $this->img
->exists()) {
57 // FIXME: bad interface, see note on MediaHandler::formatMetadata().
58 $formattedMetadata = $this->img
->formatMetadata();
59 $showmeta = $formattedMetadata !== false;
64 if ($this->img
->exists())
65 $wgOut->addHTML($this->showTOC($showmeta));
67 $this->openShowImage();
69 # No need to display noarticletext, we use our own message, output in openShowImage()
70 if ( $this->getID() ) {
73 # Just need to set the right headers
74 $wgOut->setArticleFlag( true );
75 $wgOut->setRobotpolicy( 'noindex,nofollow' );
76 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
80 # Show shared description, if needed
81 if ( $this->mExtraDescription
) {
82 $fol = wfMsgNoTrans( 'shareddescriptionfollows' );
83 if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
84 $wgOut->addWikiText( $fol );
86 $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription
. '</div>' );
88 $this->checkSharedConflict();
91 $this->closeShowImage();
92 $this->imageHistory();
94 if ( $this->img
->isLocal() ) $this->imageRedirects();
97 global $wgStylePath, $wgStyleVersion;
98 $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
99 $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
100 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ). "\n" );
101 $wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
102 $wgOut->addScriptFile( 'metadata.js' );
104 "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
108 public function getRedirectTarget() {
109 if ( $this->img
->isLocal() )
110 return parent
::getRedirectTarget();
112 // Foreign image page
113 $from = $this->img
->getRedirected();
114 $to = $this->img
->getName();
115 if ($from == $to) return null;
116 return $this->mRedirectTarget
= Title
::makeTitle( NS_IMAGE
, $to );
118 public function followRedirect() {
119 if ( $this->img
->isLocal() )
120 return parent
::followRedirect();
122 $from = $this->img
->getRedirected();
123 $to = $this->img
->getName();
124 if ($from == $to) return false;
125 return Title
::makeTitle( NS_IMAGE
, $to );
127 public function isRedirect( $text = false ) {
128 if ( $this->img
->isLocal() )
129 return parent
::isRedirect( $text );
131 return (bool)$this->img
->getRedirected();
134 public function isLocal() {
135 return $this->img
->isLocal();
138 public function getFile() {
147 * @param bool $metadata Whether or not to show the metadata link
150 function showTOC( $metadata ) {
152 $r = '<ul id="filetoc">
153 <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE
) . '</a></li>
154 <li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>
155 <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
156 ($metadata ?
' <li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
162 * Make a table with metadata to be shown in the output page.
164 * FIXME: bad interface, see note on MediaHandler::formatMetadata().
168 * @param array $exif The array containing the EXIF data
171 function makeMetadataTable( $metadata ) {
172 $r = wfMsg( 'metadata-help' ) . "\n\n";
173 $r .= "{| id=mw_metadata class=mw_metadata\n";
174 foreach ( $metadata as $type => $stuff ) {
175 foreach ( $stuff as $v ) {
176 $class = Sanitizer
::escapeId( $v['id'] );
177 if( $type == 'collapsed' ) {
178 $class .= ' collapsable';
180 $r .= "|- class=\"$class\"\n";
181 $r .= "!| {$v['name']}\n";
182 $r .= "|| {$v['value']}\n";
190 * Overloading Article's getContent method.
192 * Omit noarticletext if sharedupload; text will be fetched from the
193 * shared upload server if possible.
195 function getContent() {
196 if( $this->img
&& !$this->img
->isLocal() && 0 == $this->getID() ) {
199 return Article
::getContent();
202 function openShowImage() {
203 global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
205 $full_url = $this->img
->getURL();
206 $linkAttribs = false;
207 $sizeSel = intval( $wgUser->getOption( 'imagesize') );
208 if( !isset( $wgImageLimits[$sizeSel] ) ) {
209 $sizeSel = User
::getDefaultOption( 'imagesize' );
211 // The user offset might still be incorrect, specially if
212 // $wgImageLimits got changed (see bug #8858).
213 if( !isset( $wgImageLimits[$sizeSel] ) ) {
214 // Default to the first offset in $wgImageLimits
218 $max = $wgImageLimits[$sizeSel];
220 $maxHeight = $max[1];
221 $sk = $wgUser->getSkin();
222 $dirmark = $wgContLang->getDirMark();
224 if ( $this->img
->exists() ) {
226 $page = $wgRequest->getIntOrNull( 'page' );
227 if ( is_null( $page ) ) {
231 $params = array( 'page' => $page );
233 $width_orig = $this->img
->getWidth();
234 $width = $width_orig;
235 $height_orig = $this->img
->getHeight();
236 $height = $height_orig;
237 $mime = $this->img
->getMimeType();
239 $linkAttribs = array( 'href' => $full_url );
240 $longDesc = $this->img
->getLongDesc();
242 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
244 if ( $this->img
->allowInlineDisplay() ) {
247 # "Download high res version" link below the image
248 #$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->getSize() ), $mime );
249 # We'll show a thumbnail of this image
250 if ( $width > $maxWidth ||
$height > $maxHeight ) {
251 # Calculate the thumbnail size.
252 # First case, the limiting factor is the width, not the height.
253 if ( $width / $height >= $maxWidth / $maxHeight ) {
254 $height = round( $height * $maxWidth / $width);
256 # Note that $height <= $maxHeight now.
258 $newwidth = floor( $width * $maxHeight / $height);
259 $height = round( $height * $newwidth / $width );
261 # Note that $height <= $maxHeight now, but might not be identical
262 # because of rounding.
264 $msgbig = wfMsgHtml( 'show-big-image' );
265 $msgsmall = wfMsgExt( 'show-big-image-thumb',
266 array( 'parseinline' ), $wgLang->formatNum( $width ), $wgLang->formatNum( $height ) );
268 # Image is small enough to show full size on image page
269 $msgbig = htmlspecialchars( $this->img
->getName() );
270 $msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) );
273 $params['width'] = $width;
274 $thumbnail = $this->img
->transform( $params );
276 $anchorclose = "<br />";
277 if( $this->img
->mustRender() ) {
282 '<br />' . Xml
::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
285 if ( $this->img
->isMultipage() ) {
286 $wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
291 'alt' => $this->img
->getTitle()->getPrefixedText(),
294 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
295 $thumbnail->toHtml( $options ) .
296 $anchorclose . '</div>' );
299 if ( $this->img
->isMultipage() ) {
300 $count = $this->img
->pageCount();
303 $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
304 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page-1) );
305 $thumb1 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
306 array( 'page' => $page - 1 ) );
311 if ( $page < $count ) {
312 $label = wfMsg( 'imgmultipagenext' );
313 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page+
1) );
314 $thumb2 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
315 array( 'page' => $page +
1 ) );
323 'name' => 'pageselector',
324 'action' => $wgScript,
325 'onchange' => 'document.pageselector.submit();',
329 for ( $i=1; $i <= $count; $i++
) {
330 $options[] = Xml
::option( $wgLang->formatNum($i), $i, $i == $page );
332 $select = Xml
::tags( 'select',
333 array( 'id' => 'pageselector', 'name' => 'page' ),
334 implode( "\n", $options ) );
337 '</td><td><div class="multipageimagenavbox">' .
338 Xml
::openElement( 'form', $formParams ) .
339 Xml
::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
340 wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
341 Xml
::submitButton( wfMsg( 'imgmultigo' ) ) .
342 Xml
::closeElement( 'form' ) .
343 "<hr />$thumb1\n$thumb2<br clear=\"all\" /></div></td></tr></table>"
347 #if direct link is allowed but it's not a renderable image, show an icon.
348 if ($this->img
->isSafeFile()) {
349 $icon= $this->img
->iconThumb();
351 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
352 $icon->toHtml( array( 'desc-link' => true ) ) .
361 $filename = wfEscapeWikiText( $this->img
->getName() );
363 if (!$this->img
->isSafeFile()) {
364 $warning = wfMsgNoTrans( 'mediawarning' );
365 $wgOut->addWikiText( <<<EOT
366 <div class="fullMedia">
367 <span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
368 <span class="fileInfo"> $longDesc</span>
371 <div class="mediaWarning">$warning</div>
375 $wgOut->addWikiText( <<<EOT
376 <div class="fullMedia">
377 [[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $longDesc</span>
384 if(!$this->img
->isLocal()) {
385 $this->printSharedImageText();
388 # Image does not exist
390 $title = SpecialPage
::getTitleFor( 'Upload' );
391 $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
392 'wpDestFile=' . urlencode( $this->img
->getName() ) );
393 $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
398 * Show a notice that the file is from a shared repository
400 function printSharedImageText() {
401 global $wgOut, $wgUser;
403 $descUrl = $this->img
->getDescriptionUrl();
404 $descText = $this->img
->getDescriptionText();
405 $s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml( 'sharedupload' );
407 $sk = $wgUser->getSkin();
408 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) );
409 $msg = ( $descText ) ?
'shareduploadwiki-desc' : 'shareduploadwiki';
410 $msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
412 # Show message only if not voided by local sysops
417 $wgOut->addHTML( $s );
420 $this->mExtraDescription
= $descText;
424 function checkSharedConflict() {
425 global $wgOut, $wgUser;
426 $repoGroup = RepoGroup
::singleton();
427 if( !$repoGroup->hasForeignRepos() ) {
430 if( !$this->img
->isLocal() ) {
434 $this->dupFile
= null;
435 $repoGroup->forEachForeignRepo( array( $this, 'checkSharedConflictCallback' ) );
437 if( !$this->dupFile
)
439 $dupfile = $this->dupFile
;
441 ($this->img
->getSha1() == $dupfile->getSha1()) &&
442 ($this->img
->getSize() == $dupfile->getSize())
445 $sk = $wgUser->getSkin();
446 $descUrl = $dupfile->getDescriptionUrl();
448 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadduplicate-linktext' ) );
449 $wgOut->addHTML( '<div id="shared-image-dup">' . wfMsgWikiHtml( 'shareduploadduplicate', $link ) . '</div>' );
451 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadconflict-linktext' ) );
452 $wgOut->addHTML( '<div id="shared-image-conflict">' . wfMsgWikiHtml( 'shareduploadconflict', $link ) . '</div>' );
456 function checkSharedConflictCallback( $repo ) {
457 $dupfile = $repo->newFile( $this->img
->getTitle() );
458 if( $dupfile->exists() )
459 $this->dupFile
= $dupfile;
460 return $dupfile->exists();
463 function getUploadUrl() {
464 $uploadTitle = SpecialPage
::getTitleFor( 'Upload' );
465 return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img
->getName() ) );
469 * Print out the various links at the bottom of the image page, e.g. reupload,
470 * external editing (and instructions link) etc.
472 function uploadLinksBox() {
473 global $wgUser, $wgOut;
475 if( !$this->img
->isLocal() )
478 $sk = $wgUser->getSkin();
480 $wgOut->addHtml( '<br /><ul>' );
482 # "Upload a new version of this file" link
483 if( UploadForm
::userCanReUpload($wgUser,$this->img
->name
) ) {
484 $ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
485 $wgOut->addHtml( "<li><div class='plainlinks'>{$ulink}</div></li>" );
488 # Link to Special:FileDuplicateSearch
489 $dupeLink = $sk->makeKnownLinkObj( SpecialPage
::getTitleFor( 'FileDuplicateSearch', $this->mTitle
->getDBkey() ), wfMsgHtml( 'imagepage-searchdupe' ) );
490 $wgOut->addHtml( "<li>{$dupeLink}</li>" );
492 # External editing link
493 $elink = $sk->makeKnownLinkObj( $this->mTitle
, wfMsgHtml( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' );
494 $wgOut->addHtml( '<li>' . $elink . '<div>' . wfMsgWikiHtml( 'edit-externally-help' ) . '</div></li>' );
496 $wgOut->addHtml( '</ul>' );
499 function closeShowImage()
506 * If the page we've just displayed is in the "Image" namespace,
507 * we follow it with an upload history of the image and its usage.
509 function imageHistory()
511 global $wgUser, $wgOut, $wgUseExternalEditor;
513 $sk = $wgUser->getSkin();
515 if ( $this->img
->exists() ) {
516 $list = new ImageHistoryList( $sk, $this->current
);
517 $file = $this->current
;
518 $dims = $file->getDimensionsString();
519 $s = $list->beginImageHistoryList() .
520 $list->imageHistoryLine( true, $file );
521 // old image versions
522 $hist = $this->img
->getHistory();
523 foreach( $hist as $file ) {
524 $dims = $file->getDimensionsString();
525 $s .= $list->imageHistoryLine( false, $file );
527 $s .= $list->endImageHistoryList();
529 $wgOut->addHTML( $s );
531 $this->img
->resetHistory(); // free db resources
533 # Exist check because we don't want to show this on pages where an image
534 # doesn't exist along with the noimage message, that would suck. -ævar
535 if( $wgUseExternalEditor && $this->img
->exists() ) {
536 $this->uploadLinksBox();
541 function imageLinks()
543 global $wgUser, $wgOut;
547 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" );
549 $dbr = wfGetDB( DB_SLAVE
);
552 array( 'imagelinks', 'page' ),
553 array( 'page_namespace', 'page_title' ),
554 array( 'il_to' => $this->mTitle
->getDBkey(), 'il_from = page_id' ),
556 array( 'LIMIT' => $limit +
1)
559 if ( 0 == $dbr->numRows( $res ) ) {
560 $wgOut->addWikiMsg( 'nolinkstoimage' );
563 $wgOut->addWikiMsg( 'linkstoimage' );
564 $wgOut->addHTML( "<ul>\n" );
566 $sk = $wgUser->getSkin();
568 while ( $s = $res->fetchObject() ) {
570 if ( $count <= $limit ) {
571 // We have not yet reached the extra one that tells us there is more to fetch
572 $name = Title
::makeTitle( $s->page_namespace
, $s->page_title
);
573 $link = $sk->makeKnownLinkObj( $name, "" );
574 $wgOut->addHTML( "<li>{$link}</li>\n" );
577 $wgOut->addHTML( "</ul>\n" );
580 // Add a links to [[Special:Whatlinkshere]]
581 if ( $count > $limit )
582 $wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle
->getPrefixedDBkey() );
585 function imageRedirects()
587 global $wgUser, $wgOut;
589 $dbr = wfGetDB( DB_SLAVE
);
591 array( 'redirect', 'page' ),
592 array( 'page_title' ),
594 'rd_namespace' => NS_IMAGE
,
595 'rd_title' => $this->mTitle
->getDBkey(),
596 'page_namespace' => NS_IMAGE
,
603 if ( 0 == $dbr->numRows( $res ) )
606 $wgOut->addWikiMsg( 'redirectstofile' );
607 $wgOut->addHTML( "<ul>\n" );
609 $sk = $wgUser->getSkin();
610 while ( $row = $dbr->fetchObject( $res ) ) {
611 $name = Title
::makeTitle( NS_IMAGE
, $row->page_title
);
612 $link = $sk->makeKnownLinkObj( $name, "" );
613 wfDebug("Image redirect: {$row->page_title}\n");
614 $wgOut->addHTML( "<li>{$link}</li>\n" );
616 $wgOut->addHTML( "</ul>\n" );
622 * Delete the file, or an earlier version of it
624 public function delete() {
625 if( !$this->img
->exists() ||
!$this->img
->isLocal() ) {
626 // Standard article deletion
630 $deleter = new FileDeleteForm( $this->img
);
635 * Revert the file to an earlier version
637 public function revert() {
638 $reverter = new FileRevertForm( $this->img
);
639 $reverter->execute();
643 * Override handling of action=purge
646 if( $this->img
->exists() ) {
647 wfDebug( "ImagePage::doPurge purging " . $this->img
->getName() . "\n" );
648 $update = new HTMLCacheUpdate( $this->mTitle
, 'imagelinks' );
650 $this->img
->upgradeRow();
651 $this->img
->purgeCache();
653 wfDebug( "ImagePage::doPurge no image\n" );
659 * Display an error with a wikitext description
661 function showError( $description ) {
663 $wgOut->setPageTitle( wfMsg( "internalerror" ) );
664 $wgOut->setRobotpolicy( "noindex,nofollow" );
665 $wgOut->setArticleRelated( false );
666 $wgOut->enableClientCache( false );
667 $wgOut->addWikiText( $description );
673 * Builds the image revision log shown on image pages
677 class ImageHistoryList
{
679 protected $img, $skin, $title, $repo;
681 public function __construct( $skin, $img ) {
684 $this->title
= $img->getTitle();
687 public function beginImageHistoryList() {
688 global $wgOut, $wgUser;
689 $deleteColumn = $wgUser->isAllowed( 'delete' ) ||
$wgUser->isAllowed( 'deleterevision' );
690 return Xml
::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) )
691 . $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
692 . Xml
::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"
694 . ( $this->img
->isLocal() && $deleteColumn ?
'<td></td>' : '' )
695 . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
696 . '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
697 . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
698 . '<th class="mw-imagepage-filesize">' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
699 . '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
703 public function endImageHistoryList() {
707 public function imageHistoryLine( $iscur, $file ) {
708 global $wgUser, $wgLang, $wgContLang, $wgTitle;
710 $timestamp = wfTimestamp(TS_MW
, $file->getTimestamp());
711 $img = $iscur ?
$file->getName() : $file->getArchiveName();
712 $user = $file->getUser('id');
713 $usertext = $file->getUser('text');
714 $size = $file->getSize();
715 $description = $file->getDescription();
716 $dims = $file->getDimensionsString();
717 $sha1 = $file->getSha1();
719 $local = $this->img
->isLocal();
723 if( $local && ($wgUser->isAllowed('delete') ||
$wgUser->isAllowed('deleterevision') ) ) {
725 # Link to remove from history
726 if( $wgUser->isAllowed( 'delete' ) ) {
728 $q[] = 'action=delete';
730 $q[] = 'oldimage=' . urlencode( $img );
731 $row .= $this->skin
->makeKnownLinkObj(
733 wfMsgHtml( $iscur ?
'filehist-deleteall' : 'filehist-deleteone' ),
738 # Link to hide content
739 if( $wgUser->isAllowed( 'deleterevision' ) ) {
740 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
741 // If file is top revision or locked from this user, don't link
742 if( $iscur ||
!$file->userCan(File
::DELETED_RESTRICTED
) ) {
743 $del = wfMsgHtml( 'rev-delundel' );
745 // If the file was hidden, link to sha-1
746 list($ts,$name) = explode('!',$img,2);
747 $del = $this->skin
->makeKnownLinkObj( $revdel, wfMsg( 'rev-delundel' ),
748 'target=' . urlencode( $wgTitle->getPrefixedText() ) .
749 '&oldimage=' . urlencode( $ts ) );
750 // Bolden oversighted content
751 if( $file->isDeleted(File
::DELETED_RESTRICTED
) )
752 $del = "<strong>$del</strong>";
754 $row .= "<tt><small>$del</small></tt>";
759 // Reversion link/current indicator
762 $row .= wfMsgHtml( 'filehist-current' );
763 } elseif( $local && $wgUser->isLoggedIn() && $this->title
->userCan( 'edit' ) ) {
764 if( $file->isDeleted(File
::DELETED_FILE
) ) {
765 $row .= wfMsgHtml('filehist-revert');
768 $q[] = 'action=revert';
769 $q[] = 'oldimage=' . urlencode( $img );
770 $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
771 $row .= $this->skin
->makeKnownLinkObj( $this->title
,
772 wfMsgHtml( 'filehist-revert' ),
773 implode( '&', $q ) );
778 // Date/time and image link
780 if( !$file->userCan(File
::DELETED_FILE
) ) {
781 # Don't link to unviewable files
782 $row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
783 } else if( $file->isDeleted(File
::DELETED_FILE
) ) {
784 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
785 # Make a link to review the image
786 $url = $this->skin
->makeKnownLinkObj( $revdel, $wgLang->timeAndDate( $timestamp, true ),
787 "target=".$wgTitle->getPrefixedText()."&file=$sha1.".$this->img
->getExtension() );
788 $row .= '<span class="history-deleted">'.$url.'</span>';
790 $url = $iscur ?
$this->img
->getUrl() : $this->img
->getArchiveUrl( $img );
791 $row .= Xml
::element( 'a',
792 array( 'href' => $url ),
793 $wgLang->timeAndDate( $timestamp, true ) );
801 // Hide deleted usernames
802 if( $file->isDeleted(File
::DELETED_USER
) )
803 $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
805 $row .= $this->skin
->userLink( $user, $usertext ) .
806 $this->skin
->userToolLinks( $user, $usertext );
808 $row .= htmlspecialchars( $usertext );
813 $row .= '<td>' . htmlspecialchars( $dims ) . '</td>';
816 $row .= '<td class="mw-imagepage-filesize">' . $this->skin
->formatSize( $size ) . '</td>';
818 // Don't show deleted descriptions
819 if ( $file->isDeleted(File
::DELETED_COMMENT
) )
820 $row .= '<td><span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span></td>';
822 $row .= '<td>' . $this->skin
->commentBlock( $description, $this->title
) . '</td>';
824 return "<tr>{$row}</tr>\n";