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 ) );
103 "<script type=\"text/javascript\" src=\"$wgStylePath/common/metadata.js?$wgStyleVersion\"></script>\n" .
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();
143 * @param bool $metadata Whether or not to show the metadata link
146 function showTOC( $metadata ) {
148 $r = '<ul id="filetoc">
149 <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE
) . '</a></li>
150 <li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>
151 <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
152 ($metadata ?
' <li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
158 * Make a table with metadata to be shown in the output page.
160 * FIXME: bad interface, see note on MediaHandler::formatMetadata().
164 * @param array $exif The array containing the EXIF data
167 function makeMetadataTable( $metadata ) {
168 $r = wfMsg( 'metadata-help' ) . "\n\n";
169 $r .= "{| id=mw_metadata class=mw_metadata\n";
170 foreach ( $metadata as $type => $stuff ) {
171 foreach ( $stuff as $v ) {
172 $class = Sanitizer
::escapeId( $v['id'] );
173 if( $type == 'collapsed' ) {
174 $class .= ' collapsable';
176 $r .= "|- class=\"$class\"\n";
177 $r .= "!| {$v['name']}\n";
178 $r .= "|| {$v['value']}\n";
186 * Overloading Article's getContent method.
188 * Omit noarticletext if sharedupload; text will be fetched from the
189 * shared upload server if possible.
191 function getContent() {
192 if( $this->img
&& !$this->img
->isLocal() && 0 == $this->getID() ) {
195 return Article
::getContent();
198 function openShowImage() {
199 global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
201 $full_url = $this->img
->getURL();
202 $linkAttribs = false;
203 $sizeSel = intval( $wgUser->getOption( 'imagesize') );
204 if( !isset( $wgImageLimits[$sizeSel] ) ) {
205 $sizeSel = User
::getDefaultOption( 'imagesize' );
207 // The user offset might still be incorrect, specially if
208 // $wgImageLimits got changed (see bug #8858).
209 if( !isset( $wgImageLimits[$sizeSel] ) ) {
210 // Default to the first offset in $wgImageLimits
214 $max = $wgImageLimits[$sizeSel];
216 $maxHeight = $max[1];
217 $sk = $wgUser->getSkin();
218 $dirmark = $wgContLang->getDirMark();
220 if ( $this->img
->exists() ) {
222 $page = $wgRequest->getIntOrNull( 'page' );
223 if ( is_null( $page ) ) {
227 $params = array( 'page' => $page );
229 $width_orig = $this->img
->getWidth();
230 $width = $width_orig;
231 $height_orig = $this->img
->getHeight();
232 $height = $height_orig;
233 $mime = $this->img
->getMimeType();
235 $linkAttribs = array( 'href' => $full_url );
236 $longDesc = $this->img
->getLongDesc();
238 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
240 if ( $this->img
->allowInlineDisplay() ) {
243 # "Download high res version" link below the image
244 #$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->getSize() ), $mime );
245 # We'll show a thumbnail of this image
246 if ( $width > $maxWidth ||
$height > $maxHeight ) {
247 # Calculate the thumbnail size.
248 # First case, the limiting factor is the width, not the height.
249 if ( $width / $height >= $maxWidth / $maxHeight ) {
250 $height = round( $height * $maxWidth / $width);
252 # Note that $height <= $maxHeight now.
254 $newwidth = floor( $width * $maxHeight / $height);
255 $height = round( $height * $newwidth / $width );
257 # Note that $height <= $maxHeight now, but might not be identical
258 # because of rounding.
260 $msgbig = wfMsgHtml( 'show-big-image' );
261 $msgsmall = wfMsgExt( 'show-big-image-thumb',
262 array( 'parseinline' ), $wgLang->formatNum( $width ), $wgLang->formatNum( $height ) );
264 # Image is small enough to show full size on image page
265 $msgbig = htmlspecialchars( $this->img
->getName() );
266 $msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) );
269 $params['width'] = $width;
270 $thumbnail = $this->img
->transform( $params );
272 $anchorclose = "<br />";
273 if( $this->img
->mustRender() ) {
278 '<br />' . Xml
::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
281 if ( $this->img
->isMultipage() ) {
282 $wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
287 'alt' => $this->img
->getTitle()->getPrefixedText(),
290 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
291 $thumbnail->toHtml( $options ) .
292 $anchorclose . '</div>' );
295 if ( $this->img
->isMultipage() ) {
296 $count = $this->img
->pageCount();
299 $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
300 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page-1) );
301 $thumb1 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
302 array( 'page' => $page - 1 ) );
307 if ( $page < $count ) {
308 $label = wfMsg( 'imgmultipagenext' );
309 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page+
1) );
310 $thumb2 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
311 array( 'page' => $page +
1 ) );
317 $select = '<form name="pageselector" action="' .
318 htmlspecialchars( $wgScript ) .
319 '" method="get" onchange="document.pageselector.submit();">' .
320 Xml
::hidden( 'title', $this->getTitle()->getPrefixedDbKey() );
321 $select .= $wgOut->parse( wfMsg( 'imgmultigotopre' ), false ) .
322 ' <select id="pageselector" name="page">';
323 for ( $i=1; $i <= $count; $i++
) {
324 $select .= Xml
::option( $wgLang->formatNum( $i ), $i,
327 $select .= '</select>' . $wgOut->parse( wfMsg( 'imgmultigotopost' ), false ) .
328 '<input type="submit" value="' .
329 htmlspecialchars( wfMsg( 'imgmultigo' ) ) . '"></form>';
331 $wgOut->addHTML( '</td><td><div class="multipageimagenavbox">' .
332 "$select<hr />$thumb1\n$thumb2<br clear=\"all\" /></div></td></tr></table>" );
335 #if direct link is allowed but it's not a renderable image, show an icon.
336 if ($this->img
->isSafeFile()) {
337 $icon= $this->img
->iconThumb();
339 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
340 $icon->toHtml( array( 'desc-link' => true ) ) .
349 $filename = wfEscapeWikiText( $this->img
->getName() );
351 if (!$this->img
->isSafeFile()) {
352 $warning = wfMsgNoTrans( 'mediawarning' );
353 $wgOut->addWikiText( <<<EOT
354 <div class="fullMedia">
355 <span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
356 <span class="fileInfo"> $longDesc</span>
359 <div class="mediaWarning">$warning</div>
363 $wgOut->addWikiText( <<<EOT
364 <div class="fullMedia">
365 [[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $longDesc</span>
372 if(!$this->img
->isLocal()) {
373 $this->printSharedImageText();
376 # Image does not exist
378 $title = SpecialPage
::getTitleFor( 'Upload' );
379 $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
380 'wpDestFile=' . urlencode( $this->img
->getName() ) );
381 $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
386 * Show a notice that the file is from a shared repository
388 function printSharedImageText() {
389 global $wgOut, $wgUser;
391 $descUrl = $this->img
->getDescriptionUrl();
392 $descText = $this->img
->getDescriptionText();
393 $s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml( 'sharedupload' );
395 $sk = $wgUser->getSkin();
396 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) );
397 $msg = ( $descText ) ?
'shareduploadwiki-desc' : 'shareduploadwiki';
398 $msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
400 # Show message only if not voided by local sysops
405 $wgOut->addHTML( $s );
408 $this->mExtraDescription
= $descText;
412 function checkSharedConflict() {
413 global $wgOut, $wgUser;
414 $repoGroup = RepoGroup
::singleton();
415 if( !$repoGroup->hasForeignRepos() ) {
418 if( !$this->img
->isLocal() ) {
422 $this->dupFile
= null;
423 $repoGroup->forEachForeignRepo( array( $this, 'checkSharedConflictCallback' ) );
425 if( !$this->dupFile
)
427 $dupfile = $this->dupFile
;
429 ($this->img
->getSha1() == $dupfile->getSha1()) &&
430 ($this->img
->getSize() == $dupfile->getSize())
433 $sk = $wgUser->getSkin();
434 $descUrl = $dupfile->getDescriptionUrl();
436 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadduplicate-linktext' ) );
437 $wgOut->addHTML( '<div id="shared-image-dup">' . wfMsgWikiHtml( 'shareduploadduplicate', $link ) . '</div>' );
439 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadconflict-linktext' ) );
440 $wgOut->addHTML( '<div id="shared-image-conflict">' . wfMsgWikiHtml( 'shareduploadconflict', $link ) . '</div>' );
444 function checkSharedConflictCallback( $repo ) {
445 $dupfile = $repo->newFile( $this->img
->getTitle() );
446 if( $dupfile->exists() )
447 $this->dupFile
= $dupfile;
448 return $dupfile->exists();
451 function getUploadUrl() {
452 $uploadTitle = SpecialPage
::getTitleFor( 'Upload' );
453 return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img
->getName() ) );
457 * Print out the various links at the bottom of the image page, e.g. reupload,
458 * external editing (and instructions link) etc.
460 function uploadLinksBox() {
461 global $wgUser, $wgOut;
463 if( !$this->img
->isLocal() )
466 $sk = $wgUser->getSkin();
468 $wgOut->addHtml( '<br /><ul>' );
470 # "Upload a new version of this file" link
471 if( UploadForm
::userCanReUpload($wgUser,$this->img
->name
) ) {
472 $ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
473 $wgOut->addHtml( "<li><div class='plainlinks'>{$ulink}</div></li>" );
476 # Link to Special:FileDuplicateSearch
477 $dupeLink = $sk->makeKnownLinkObj( SpecialPage
::getTitleFor( 'FileDuplicateSearch', $this->mTitle
->getDBkey() ), wfMsgHtml( 'imagepage-searchdupe' ) );
478 $wgOut->addHtml( "<li>{$dupeLink}</li>" );
480 # External editing link
481 $elink = $sk->makeKnownLinkObj( $this->mTitle
, wfMsgHtml( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' );
482 $wgOut->addHtml( '<li>' . $elink . '<div>' . wfMsgWikiHtml( 'edit-externally-help' ) . '</div></li>' );
484 $wgOut->addHtml( '</ul>' );
487 function closeShowImage()
494 * If the page we've just displayed is in the "Image" namespace,
495 * we follow it with an upload history of the image and its usage.
497 function imageHistory()
499 global $wgUser, $wgOut, $wgUseExternalEditor;
501 $sk = $wgUser->getSkin();
503 if ( $this->img
->exists() ) {
504 $list = new ImageHistoryList( $sk, $this->current
);
505 $file = $this->current
;
506 $dims = $file->getDimensionsString();
507 $s = $list->beginImageHistoryList() .
508 $list->imageHistoryLine( true, $file );
509 // old image versions
510 $hist = $this->img
->getHistory();
511 foreach( $hist as $file ) {
512 $dims = $file->getDimensionsString();
513 $s .= $list->imageHistoryLine( false, $file );
515 $s .= $list->endImageHistoryList();
517 $wgOut->addHTML( $s );
519 $this->img
->resetHistory(); // free db resources
521 # Exist check because we don't want to show this on pages where an image
522 # doesn't exist along with the noimage message, that would suck. -ævar
523 if( $wgUseExternalEditor && $this->img
->exists() ) {
524 $this->uploadLinksBox();
529 function imageLinks()
531 global $wgUser, $wgOut;
535 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" );
537 $dbr = wfGetDB( DB_SLAVE
);
540 array( 'imagelinks', 'page' ),
541 array( 'page_namespace', 'page_title' ),
542 array( 'il_to' => $this->mTitle
->getDBkey(), 'il_from = page_id' ),
544 array( 'LIMIT' => $limit +
1)
547 if ( 0 == $dbr->numRows( $res ) ) {
548 $wgOut->addWikiMsg( 'nolinkstoimage' );
551 $wgOut->addWikiMsg( 'linkstoimage' );
552 $wgOut->addHTML( "<ul>\n" );
554 $sk = $wgUser->getSkin();
556 while ( $s = $res->fetchObject() ) {
558 if ( $count <= $limit ) {
559 // We have not yet reached the extra one that tells us there is more to fetch
560 $name = Title
::makeTitle( $s->page_namespace
, $s->page_title
);
561 $link = $sk->makeKnownLinkObj( $name, "" );
562 $wgOut->addHTML( "<li>{$link}</li>\n" );
565 $wgOut->addHTML( "</ul>\n" );
568 // Add a links to [[Special:Whatlinkshere]]
569 if ( $count > $limit )
570 $wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle
->getPrefixedDBkey() );
573 function imageRedirects()
575 global $wgUser, $wgOut;
577 $dbr = wfGetDB( DB_SLAVE
);
579 array( 'redirect', 'page' ),
580 array( 'page_title' ),
582 'rd_namespace' => NS_IMAGE
,
583 'rd_title' => $this->mTitle
->getDBkey(),
584 'page_namespace' => NS_IMAGE
,
591 if ( 0 == $dbr->numRows( $res ) )
594 $wgOut->addWikiMsg( 'redirectstofile' );
595 $wgOut->addHTML( "<ul>\n" );
597 $sk = $wgUser->getSkin();
598 while ( $row = $dbr->fetchObject( $res ) ) {
599 $name = Title
::makeTitle( NS_IMAGE
, $row->page_title
);
600 $link = $sk->makeKnownLinkObj( $name, "" );
601 wfDebug("Image redirect: {$row->page_title}\n");
602 $wgOut->addHTML( "<li>{$link}</li>\n" );
604 $wgOut->addHTML( "</ul>\n" );
610 * Delete the file, or an earlier version of it
612 public function delete() {
613 if( !$this->img
->exists() ||
!$this->img
->isLocal() ) {
614 // Standard article deletion
618 $deleter = new FileDeleteForm( $this->img
);
623 * Revert the file to an earlier version
625 public function revert() {
626 $reverter = new FileRevertForm( $this->img
);
627 $reverter->execute();
631 * Override handling of action=purge
634 if( $this->img
->exists() ) {
635 wfDebug( "ImagePage::doPurge purging " . $this->img
->getName() . "\n" );
636 $update = new HTMLCacheUpdate( $this->mTitle
, 'imagelinks' );
638 $this->img
->upgradeRow();
639 $this->img
->purgeCache();
641 wfDebug( "ImagePage::doPurge no image\n" );
647 * Display an error with a wikitext description
649 function showError( $description ) {
651 $wgOut->setPageTitle( wfMsg( "internalerror" ) );
652 $wgOut->setRobotpolicy( "noindex,nofollow" );
653 $wgOut->setArticleRelated( false );
654 $wgOut->enableClientCache( false );
655 $wgOut->addWikiText( $description );
661 * Builds the image revision log shown on image pages
665 class ImageHistoryList
{
667 protected $img, $skin, $title, $repo;
669 public function __construct( $skin, $img ) {
672 $this->title
= $img->getTitle();
675 public function beginImageHistoryList() {
676 global $wgOut, $wgUser;
677 $deleteColumn = $wgUser->isAllowed( 'delete' ) ||
$wgUser->isAllowed( 'deleterevision' );
678 return Xml
::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) )
679 . $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
680 . Xml
::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"
682 . ( $this->img
->isLocal() && $deleteColumn ?
'<td></td>' : '' )
683 . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
684 . '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
685 . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
686 . '<th class="mw-imagepage-filesize">' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
687 . '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
691 public function endImageHistoryList() {
695 public function imageHistoryLine( $iscur, $file ) {
696 global $wgUser, $wgLang, $wgContLang, $wgTitle;
698 $timestamp = wfTimestamp(TS_MW
, $file->getTimestamp());
699 $img = $iscur ?
$file->getName() : $file->getArchiveName();
700 $user = $file->getUser('id');
701 $usertext = $file->getUser('text');
702 $size = $file->getSize();
703 $description = $file->getDescription();
704 $dims = $file->getDimensionsString();
705 $sha1 = $file->getSha1();
707 $local = $this->img
->isLocal();
711 if( $local && ($wgUser->isAllowed('delete') ||
$wgUser->isAllowed('deleterevision') ) ) {
713 # Link to remove from history
714 if( $wgUser->isAllowed( 'delete' ) ) {
716 $q[] = 'action=delete';
718 $q[] = 'oldimage=' . urlencode( $img );
719 $row .= $this->skin
->makeKnownLinkObj(
721 wfMsgHtml( $iscur ?
'filehist-deleteall' : 'filehist-deleteone' ),
726 # Link to hide content
727 if( $wgUser->isAllowed( 'deleterevision' ) ) {
728 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
729 // If file is top revision or locked from this user, don't link
730 if( $iscur ||
!$file->userCan(File
::DELETED_RESTRICTED
) ) {
731 $del = wfMsgHtml( 'rev-delundel' );
733 // If the file was hidden, link to sha-1
734 list($ts,$name) = explode('!',$img,2);
735 $del = $this->skin
->makeKnownLinkObj( $revdel, wfMsg( 'rev-delundel' ),
736 'target=' . urlencode( $wgTitle->getPrefixedText() ) .
737 '&oldimage=' . urlencode( $ts ) );
738 // Bolden oversighted content
739 if( $file->isDeleted(File
::DELETED_RESTRICTED
) )
740 $del = "<strong>$del</strong>";
742 $row .= "<tt><small>$del</small></tt>";
747 // Reversion link/current indicator
750 $row .= wfMsgHtml( 'filehist-current' );
751 } elseif( $local && $wgUser->isLoggedIn() && $this->title
->userCan( 'edit' ) ) {
752 if( $file->isDeleted(File
::DELETED_FILE
) ) {
753 $row .= wfMsgHtml('filehist-revert');
756 $q[] = 'action=revert';
757 $q[] = 'oldimage=' . urlencode( $img );
758 $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
759 $row .= $this->skin
->makeKnownLinkObj( $this->title
,
760 wfMsgHtml( 'filehist-revert' ),
761 implode( '&', $q ) );
766 // Date/time and image link
768 if( !$file->userCan(File
::DELETED_FILE
) ) {
769 # Don't link to unviewable files
770 $row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
771 } else if( $file->isDeleted(File
::DELETED_FILE
) ) {
772 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
773 # Make a link to review the image
774 $url = $this->skin
->makeKnownLinkObj( $revdel, $wgLang->timeAndDate( $timestamp, true ),
775 "target=".$wgTitle->getPrefixedText()."&file=$sha1.".$this->img
->getExtension() );
776 $row .= '<span class="history-deleted">'.$url.'</span>';
778 $url = $iscur ?
$this->img
->getUrl() : $this->img
->getArchiveUrl( $img );
779 $row .= Xml
::element( 'a',
780 array( 'href' => $url ),
781 $wgLang->timeAndDate( $timestamp, true ) );
789 // Hide deleted usernames
790 if( $file->isDeleted(File
::DELETED_USER
) )
791 $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
793 $row .= $this->skin
->userLink( $user, $usertext ) .
794 $this->skin
->userToolLinks( $user, $usertext );
796 $row .= htmlspecialchars( $usertext );
801 $row .= '<td>' . htmlspecialchars( $dims ) . '</td>';
804 $row .= '<td class="mw-imagepage-filesize">' . $this->skin
->formatSize( $size ) . '</td>';
806 // Don't show deleted descriptions
807 if ( $file->isDeleted(File
::DELETED_COMMENT
) )
808 $row .= '<td><span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span></td>';
810 $row .= '<td>' . $this->skin
->commentBlock( $description, $this->title
) . '</td>';
812 return "<tr>{$row}</tr>\n";