399fc1cad0d3c4855eaa95aefee5703d6b6de56b
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->mTitle
->getNamespace() == NS_IMAGE
&& $this->img
->getRedirected() ) {
48 if ( $this->mTitle
->getDBkey() == $this->img
->getName() ) {
49 // mTitle is the same as the redirect target so ask Article
50 // to perform the redirect for us.
51 return Article
::view();
53 // mTitle is not the same as the redirect target so it is
54 // probably the redirect page itself. Fake the redirect symbol
55 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
56 $this->viewRedirect( Title
::makeTitle( NS_IMAGE
, $this->img
->getName() ),
57 /* $overwriteSubtitle */ true, /* $forceKnown */ true );
63 $diff = $wgRequest->getVal( 'diff' );
64 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
66 if ( $this->mTitle
->getNamespace() != NS_IMAGE ||
( isset( $diff ) && $diffOnly ) )
67 return Article
::view();
69 if ($wgShowEXIF && $this->img
->exists()) {
70 // FIXME: bad interface, see note on MediaHandler::formatMetadata().
71 $formattedMetadata = $this->img
->formatMetadata();
72 $showmeta = $formattedMetadata !== false;
77 if ($this->img
->exists())
78 $wgOut->addHTML($this->showTOC($showmeta));
80 $this->openShowImage();
82 # No need to display noarticletext, we use our own message, output in openShowImage()
83 if ( $this->getID() ) {
86 # Just need to set the right headers
87 $wgOut->setArticleFlag( true );
88 $wgOut->setRobotpolicy( 'noindex,nofollow' );
89 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
93 # Show shared description, if needed
94 if ( $this->mExtraDescription
) {
95 $fol = wfMsgNoTrans( 'shareddescriptionfollows' );
96 if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
97 $wgOut->addWikiText( $fol );
99 $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription
. '</div>' );
101 $this->checkSharedConflict();
104 $this->closeShowImage();
105 $this->imageHistory();
107 if ( $this->img
->isLocal() ) $this->imageRedirects();
110 global $wgStylePath, $wgStyleVersion;
111 $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
112 $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
113 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ). "\n" );
114 $wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
115 $wgOut->addScriptFile( 'metadata.js' );
117 "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
121 public function getRedirectTarget() {
122 if ( $this->img
->isLocal() )
123 return parent
::getRedirectTarget();
125 // Foreign image page
126 $from = $this->img
->getRedirected();
127 $to = $this->img
->getName();
128 if ($from == $to) return null;
129 return $this->mRedirectTarget
= Title
::makeTitle( NS_IMAGE
, $to );
131 public function followRedirect() {
132 if ( $this->img
->isLocal() )
133 return parent
::followRedirect();
135 $from = $this->img
->getRedirected();
136 $to = $this->img
->getName();
137 if ($from == $to) return false;
138 return Title
::makeTitle( NS_IMAGE
, $to );
140 public function isRedirect( $text = false ) {
141 if ( $this->img
->isLocal() )
142 return parent
::isRedirect( $text );
144 return (bool)$this->img
->getRedirected();
147 public function isLocal() {
148 return $this->img
->isLocal();
151 public function getFile() {
160 * @param bool $metadata Whether or not to show the metadata link
163 function showTOC( $metadata ) {
165 $r = '<ul id="filetoc">
166 <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE
) . '</a></li>
167 <li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>
168 <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
169 ($metadata ?
' <li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
175 * Make a table with metadata to be shown in the output page.
177 * FIXME: bad interface, see note on MediaHandler::formatMetadata().
181 * @param array $exif The array containing the EXIF data
184 function makeMetadataTable( $metadata ) {
185 $r = wfMsg( 'metadata-help' ) . "\n\n";
186 $r .= "{| id=mw_metadata class=mw_metadata\n";
187 foreach ( $metadata as $type => $stuff ) {
188 foreach ( $stuff as $v ) {
189 $class = Sanitizer
::escapeId( $v['id'] );
190 if( $type == 'collapsed' ) {
191 $class .= ' collapsable';
193 $r .= "|- class=\"$class\"\n";
194 $r .= "!| {$v['name']}\n";
195 $r .= "|| {$v['value']}\n";
203 * Overloading Article's getContent method.
205 * Omit noarticletext if sharedupload; text will be fetched from the
206 * shared upload server if possible.
208 function getContent() {
209 if( $this->img
&& !$this->img
->isLocal() && 0 == $this->getID() ) {
212 return Article
::getContent();
215 function openShowImage() {
216 global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
218 $full_url = $this->img
->getURL();
219 $linkAttribs = false;
220 $sizeSel = intval( $wgUser->getOption( 'imagesize') );
221 if( !isset( $wgImageLimits[$sizeSel] ) ) {
222 $sizeSel = User
::getDefaultOption( 'imagesize' );
224 // The user offset might still be incorrect, specially if
225 // $wgImageLimits got changed (see bug #8858).
226 if( !isset( $wgImageLimits[$sizeSel] ) ) {
227 // Default to the first offset in $wgImageLimits
231 $max = $wgImageLimits[$sizeSel];
233 $maxHeight = $max[1];
234 $sk = $wgUser->getSkin();
235 $dirmark = $wgContLang->getDirMark();
237 if ( $this->img
->exists() ) {
239 $page = $wgRequest->getIntOrNull( 'page' );
240 if ( is_null( $page ) ) {
244 $params = array( 'page' => $page );
246 $width_orig = $this->img
->getWidth();
247 $width = $width_orig;
248 $height_orig = $this->img
->getHeight();
249 $height = $height_orig;
250 $mime = $this->img
->getMimeType();
252 $linkAttribs = array( 'href' => $full_url );
253 $longDesc = $this->img
->getLongDesc();
255 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
257 if ( $this->img
->allowInlineDisplay() ) {
260 # "Download high res version" link below the image
261 #$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->getSize() ), $mime );
262 # We'll show a thumbnail of this image
263 if ( $width > $maxWidth ||
$height > $maxHeight ) {
264 # Calculate the thumbnail size.
265 # First case, the limiting factor is the width, not the height.
266 if ( $width / $height >= $maxWidth / $maxHeight ) {
267 $height = round( $height * $maxWidth / $width);
269 # Note that $height <= $maxHeight now.
271 $newwidth = floor( $width * $maxHeight / $height);
272 $height = round( $height * $newwidth / $width );
274 # Note that $height <= $maxHeight now, but might not be identical
275 # because of rounding.
277 $msgbig = wfMsgHtml( 'show-big-image' );
278 $msgsmall = wfMsgExt( 'show-big-image-thumb',
279 array( 'parseinline' ), $wgLang->formatNum( $width ), $wgLang->formatNum( $height ) );
281 # Image is small enough to show full size on image page
282 $msgbig = htmlspecialchars( $this->img
->getName() );
283 $msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) );
286 $params['width'] = $width;
287 $thumbnail = $this->img
->transform( $params );
289 $anchorclose = "<br />";
290 if( $this->img
->mustRender() ) {
295 '<br />' . Xml
::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
298 if ( $this->img
->isMultipage() ) {
299 $wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
304 'alt' => $this->img
->getTitle()->getPrefixedText(),
307 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
308 $thumbnail->toHtml( $options ) .
309 $anchorclose . '</div>' );
312 if ( $this->img
->isMultipage() ) {
313 $count = $this->img
->pageCount();
316 $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
317 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page-1) );
318 $thumb1 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
319 array( 'page' => $page - 1 ) );
324 if ( $page < $count ) {
325 $label = wfMsg( 'imgmultipagenext' );
326 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page+
1) );
327 $thumb2 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
328 array( 'page' => $page +
1 ) );
336 'name' => 'pageselector',
337 'action' => $wgScript,
338 'onchange' => 'document.pageselector.submit();',
342 for ( $i=1; $i <= $count; $i++
) {
343 $options[] = Xml
::option( $wgLang->formatNum($i), $i, $i == $page );
345 $select = Xml
::tags( 'select',
346 array( 'id' => 'pageselector', 'name' => 'page' ),
347 implode( "\n", $options ) );
350 '</td><td><div class="multipageimagenavbox">' .
351 Xml
::openElement( 'form', $formParams ) .
352 Xml
::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
353 wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
354 Xml
::submitButton( wfMsg( 'imgmultigo' ) ) .
355 Xml
::closeElement( 'form' ) .
356 "<hr />$thumb1\n$thumb2<br clear=\"all\" /></div></td></tr></table>"
360 #if direct link is allowed but it's not a renderable image, show an icon.
361 if ($this->img
->isSafeFile()) {
362 $icon= $this->img
->iconThumb();
364 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
365 $icon->toHtml( array( 'desc-link' => true ) ) .
374 $filename = wfEscapeWikiText( $this->img
->getName() );
376 if (!$this->img
->isSafeFile()) {
377 $warning = wfMsgNoTrans( 'mediawarning' );
378 $wgOut->addWikiText( <<<EOT
379 <div class="fullMedia">
380 <span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
381 <span class="fileInfo"> $longDesc</span>
384 <div class="mediaWarning">$warning</div>
388 $wgOut->addWikiText( <<<EOT
389 <div class="fullMedia">
390 [[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $longDesc</span>
397 if(!$this->img
->isLocal()) {
398 $this->printSharedImageText();
401 # Image does not exist
403 $title = SpecialPage
::getTitleFor( 'Upload' );
404 $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
405 'wpDestFile=' . urlencode( $this->img
->getName() ) );
406 $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
411 * Show a notice that the file is from a shared repository
413 function printSharedImageText() {
414 global $wgOut, $wgUser;
416 $descUrl = $this->img
->getDescriptionUrl();
417 $descText = $this->img
->getDescriptionText();
418 $s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml( 'sharedupload' );
420 $sk = $wgUser->getSkin();
421 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) );
422 $msg = ( $descText ) ?
'shareduploadwiki-desc' : 'shareduploadwiki';
423 $msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
425 # Show message only if not voided by local sysops
430 $wgOut->addHTML( $s );
433 $this->mExtraDescription
= $descText;
437 function checkSharedConflict() {
438 global $wgOut, $wgUser;
439 $repoGroup = RepoGroup
::singleton();
440 if( !$repoGroup->hasForeignRepos() ) {
443 if( !$this->img
->isLocal() ) {
447 $this->dupFile
= null;
448 $repoGroup->forEachForeignRepo( array( $this, 'checkSharedConflictCallback' ) );
450 if( !$this->dupFile
)
452 $dupfile = $this->dupFile
;
454 ($this->img
->getSha1() == $dupfile->getSha1()) &&
455 ($this->img
->getSize() == $dupfile->getSize())
458 $sk = $wgUser->getSkin();
459 $descUrl = $dupfile->getDescriptionUrl();
461 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadduplicate-linktext' ) );
462 $wgOut->addHTML( '<div id="shared-image-dup">' . wfMsgWikiHtml( 'shareduploadduplicate', $link ) . '</div>' );
464 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadconflict-linktext' ) );
465 $wgOut->addHTML( '<div id="shared-image-conflict">' . wfMsgWikiHtml( 'shareduploadconflict', $link ) . '</div>' );
469 function checkSharedConflictCallback( $repo ) {
470 $dupfile = $repo->newFile( $this->img
->getTitle() );
471 if( $dupfile->exists() )
472 $this->dupFile
= $dupfile;
473 return $dupfile->exists();
476 function getUploadUrl() {
477 $uploadTitle = SpecialPage
::getTitleFor( 'Upload' );
478 return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img
->getName() ) );
482 * Print out the various links at the bottom of the image page, e.g. reupload,
483 * external editing (and instructions link) etc.
485 function uploadLinksBox() {
486 global $wgUser, $wgOut;
488 if( !$this->img
->isLocal() )
491 $sk = $wgUser->getSkin();
493 $wgOut->addHtml( '<br /><ul>' );
495 # "Upload a new version of this file" link
496 if( UploadForm
::userCanReUpload($wgUser,$this->img
->name
) ) {
497 $ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
498 $wgOut->addHtml( "<li><div class='plainlinks'>{$ulink}</div></li>" );
501 # Link to Special:FileDuplicateSearch
502 $dupeLink = $sk->makeKnownLinkObj( SpecialPage
::getTitleFor( 'FileDuplicateSearch', $this->mTitle
->getDBkey() ), wfMsgHtml( 'imagepage-searchdupe' ) );
503 $wgOut->addHtml( "<li>{$dupeLink}</li>" );
505 # External editing link
506 $elink = $sk->makeKnownLinkObj( $this->mTitle
, wfMsgHtml( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' );
507 $wgOut->addHtml( '<li>' . $elink . '<div>' . wfMsgWikiHtml( 'edit-externally-help' ) . '</div></li>' );
509 $wgOut->addHtml( '</ul>' );
512 function closeShowImage()
519 * If the page we've just displayed is in the "Image" namespace,
520 * we follow it with an upload history of the image and its usage.
522 function imageHistory()
524 global $wgUser, $wgOut, $wgUseExternalEditor;
526 $sk = $wgUser->getSkin();
528 if ( $this->img
->exists() ) {
529 $list = new ImageHistoryList( $sk, $this->current
);
530 $file = $this->current
;
531 $dims = $file->getDimensionsString();
532 $s = $list->beginImageHistoryList() .
533 $list->imageHistoryLine( true, $file );
534 // old image versions
535 $hist = $this->img
->getHistory();
536 foreach( $hist as $file ) {
537 $dims = $file->getDimensionsString();
538 $s .= $list->imageHistoryLine( false, $file );
540 $s .= $list->endImageHistoryList();
542 $wgOut->addHTML( $s );
544 $this->img
->resetHistory(); // free db resources
546 # Exist check because we don't want to show this on pages where an image
547 # doesn't exist along with the noimage message, that would suck. -ævar
548 if( $wgUseExternalEditor && $this->img
->exists() ) {
549 $this->uploadLinksBox();
554 function imageLinks()
556 global $wgUser, $wgOut;
560 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" );
562 $dbr = wfGetDB( DB_SLAVE
);
565 array( 'imagelinks', 'page' ),
566 array( 'page_namespace', 'page_title' ),
567 array( 'il_to' => $this->mTitle
->getDBkey(), 'il_from = page_id' ),
569 array( 'LIMIT' => $limit +
1)
572 if ( 0 == $dbr->numRows( $res ) ) {
573 $wgOut->addWikiMsg( 'nolinkstoimage' );
576 $wgOut->addWikiMsg( 'linkstoimage' );
577 $wgOut->addHTML( "<ul>\n" );
579 $sk = $wgUser->getSkin();
581 while ( $s = $res->fetchObject() ) {
583 if ( $count <= $limit ) {
584 // We have not yet reached the extra one that tells us there is more to fetch
585 $name = Title
::makeTitle( $s->page_namespace
, $s->page_title
);
586 $link = $sk->makeKnownLinkObj( $name, "" );
587 $wgOut->addHTML( "<li>{$link}</li>\n" );
590 $wgOut->addHTML( "</ul>\n" );
593 // Add a links to [[Special:Whatlinkshere]]
594 if ( $count > $limit )
595 $wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle
->getPrefixedDBkey() );
598 function imageRedirects()
600 global $wgUser, $wgOut;
602 $dbr = wfGetDB( DB_SLAVE
);
604 array( 'redirect', 'page' ),
605 array( 'page_title' ),
607 'rd_namespace' => NS_IMAGE
,
608 'rd_title' => $this->mTitle
->getDBkey(),
609 'page_namespace' => NS_IMAGE
,
616 if ( 0 == $dbr->numRows( $res ) )
619 $wgOut->addWikiMsg( 'redirectstofile' );
620 $wgOut->addHTML( "<ul>\n" );
622 $sk = $wgUser->getSkin();
623 while ( $row = $dbr->fetchObject( $res ) ) {
624 $name = Title
::makeTitle( NS_IMAGE
, $row->page_title
);
625 $link = $sk->makeKnownLinkObj( $name, "" );
626 wfDebug("Image redirect: {$row->page_title}\n");
627 $wgOut->addHTML( "<li>{$link}</li>\n" );
629 $wgOut->addHTML( "</ul>\n" );
635 * Delete the file, or an earlier version of it
637 public function delete() {
638 if( !$this->img
->exists() ||
!$this->img
->isLocal() ) {
639 // Standard article deletion
643 $deleter = new FileDeleteForm( $this->img
);
648 * Revert the file to an earlier version
650 public function revert() {
651 $reverter = new FileRevertForm( $this->img
);
652 $reverter->execute();
656 * Override handling of action=purge
659 if( $this->img
->exists() ) {
660 wfDebug( "ImagePage::doPurge purging " . $this->img
->getName() . "\n" );
661 $update = new HTMLCacheUpdate( $this->mTitle
, 'imagelinks' );
663 $this->img
->upgradeRow();
664 $this->img
->purgeCache();
666 wfDebug( "ImagePage::doPurge no image\n" );
672 * Display an error with a wikitext description
674 function showError( $description ) {
676 $wgOut->setPageTitle( wfMsg( "internalerror" ) );
677 $wgOut->setRobotpolicy( "noindex,nofollow" );
678 $wgOut->setArticleRelated( false );
679 $wgOut->enableClientCache( false );
680 $wgOut->addWikiText( $description );
686 * Builds the image revision log shown on image pages
690 class ImageHistoryList
{
692 protected $img, $skin, $title, $repo;
694 public function __construct( $skin, $img ) {
697 $this->title
= $img->getTitle();
700 public function beginImageHistoryList() {
701 global $wgOut, $wgUser;
702 $deleteColumn = $wgUser->isAllowed( 'delete' ) ||
$wgUser->isAllowed( 'deleterevision' );
703 return Xml
::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) )
704 . $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
705 . Xml
::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"
707 . ( $this->img
->isLocal() && $deleteColumn ?
'<td></td>' : '' )
708 . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
709 . '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
710 . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
711 . '<th class="mw-imagepage-filesize">' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
712 . '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
716 public function endImageHistoryList() {
720 public function imageHistoryLine( $iscur, $file ) {
721 global $wgUser, $wgLang, $wgContLang, $wgTitle;
723 $timestamp = wfTimestamp(TS_MW
, $file->getTimestamp());
724 $img = $iscur ?
$file->getName() : $file->getArchiveName();
725 $user = $file->getUser('id');
726 $usertext = $file->getUser('text');
727 $size = $file->getSize();
728 $description = $file->getDescription();
729 $dims = $file->getDimensionsString();
730 $sha1 = $file->getSha1();
732 $local = $this->img
->isLocal();
736 if( $local && ($wgUser->isAllowed('delete') ||
$wgUser->isAllowed('deleterevision') ) ) {
738 # Link to remove from history
739 if( $wgUser->isAllowed( 'delete' ) ) {
741 $q[] = 'action=delete';
743 $q[] = 'oldimage=' . urlencode( $img );
744 $row .= $this->skin
->makeKnownLinkObj(
746 wfMsgHtml( $iscur ?
'filehist-deleteall' : 'filehist-deleteone' ),
751 # Link to hide content
752 if( $wgUser->isAllowed( 'deleterevision' ) ) {
753 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
754 // If file is top revision or locked from this user, don't link
755 if( $iscur ||
!$file->userCan(File
::DELETED_RESTRICTED
) ) {
756 $del = wfMsgHtml( 'rev-delundel' );
758 // If the file was hidden, link to sha-1
759 list($ts,$name) = explode('!',$img,2);
760 $del = $this->skin
->makeKnownLinkObj( $revdel, wfMsg( 'rev-delundel' ),
761 'target=' . urlencode( $wgTitle->getPrefixedText() ) .
762 '&oldimage=' . urlencode( $ts ) );
763 // Bolden oversighted content
764 if( $file->isDeleted(File
::DELETED_RESTRICTED
) )
765 $del = "<strong>$del</strong>";
767 $row .= "<tt><small>$del</small></tt>";
772 // Reversion link/current indicator
775 $row .= wfMsgHtml( 'filehist-current' );
776 } elseif( $local && $wgUser->isLoggedIn() && $this->title
->userCan( 'edit' ) ) {
777 if( $file->isDeleted(File
::DELETED_FILE
) ) {
778 $row .= wfMsgHtml('filehist-revert');
781 $q[] = 'action=revert';
782 $q[] = 'oldimage=' . urlencode( $img );
783 $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
784 $row .= $this->skin
->makeKnownLinkObj( $this->title
,
785 wfMsgHtml( 'filehist-revert' ),
786 implode( '&', $q ) );
791 // Date/time and image link
793 if( !$file->userCan(File
::DELETED_FILE
) ) {
794 # Don't link to unviewable files
795 $row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
796 } else if( $file->isDeleted(File
::DELETED_FILE
) ) {
797 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
798 # Make a link to review the image
799 $url = $this->skin
->makeKnownLinkObj( $revdel, $wgLang->timeAndDate( $timestamp, true ),
800 "target=".$wgTitle->getPrefixedText()."&file=$sha1.".$this->img
->getExtension() );
801 $row .= '<span class="history-deleted">'.$url.'</span>';
803 $url = $iscur ?
$this->img
->getUrl() : $this->img
->getArchiveUrl( $img );
804 $row .= Xml
::element( 'a',
805 array( 'href' => $url ),
806 $wgLang->timeAndDate( $timestamp, true ) );
814 // Hide deleted usernames
815 if( $file->isDeleted(File
::DELETED_USER
) )
816 $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
818 $row .= $this->skin
->userLink( $user, $usertext ) .
819 $this->skin
->userToolLinks( $user, $usertext );
821 $row .= htmlspecialchars( $usertext );
826 $row .= '<td>' . htmlspecialchars( $dims ) . '</td>';
829 $row .= '<td class="mw-imagepage-filesize">' . $this->skin
->formatSize( $size ) . '</td>';
831 // Don't show deleted descriptions
832 if ( $file->isDeleted(File
::DELETED_COMMENT
) )
833 $row .= '<td><span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span></td>';
835 $row .= '<td>' . $this->skin
->commentBlock( $description, $this->title
) . '</td>';
837 return "<tr>{$row}</tr>\n";