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 if ( $this->mTitle
->getDBkey() == $this->img
->getName() ) {
49 return Article
::view();
51 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
52 $this->viewRedirect( Title
::makeTitle( NS_IMAGE
, $this->img
->getName() ),
53 /* $overwriteSubtitle */ true, /* $forceKnown */ true );
59 $diff = $wgRequest->getVal( 'diff' );
60 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
62 if ( $this->mTitle
->getNamespace() != NS_IMAGE ||
( isset( $diff ) && $diffOnly ) )
63 return Article
::view();
65 if ($wgShowEXIF && $this->img
->exists()) {
66 // FIXME: bad interface, see note on MediaHandler::formatMetadata().
67 $formattedMetadata = $this->img
->formatMetadata();
68 $showmeta = $formattedMetadata !== false;
73 if ($this->img
->exists())
74 $wgOut->addHTML($this->showTOC($showmeta));
76 $this->openShowImage();
78 # No need to display noarticletext, we use our own message, output in openShowImage()
79 if ( $this->getID() ) {
82 # Just need to set the right headers
83 $wgOut->setArticleFlag( true );
84 $wgOut->setRobotpolicy( 'noindex,nofollow' );
85 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
89 # Show shared description, if needed
90 if ( $this->mExtraDescription
) {
91 $fol = wfMsgNoTrans( 'shareddescriptionfollows' );
92 if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
93 $wgOut->addWikiText( $fol );
95 $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription
. '</div>' );
97 $this->checkSharedConflict();
100 $this->closeShowImage();
101 $this->imageHistory();
103 if ( $this->img
->isLocal() ) $this->imageRedirects();
106 global $wgStylePath, $wgStyleVersion;
107 $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
108 $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
109 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ). "\n" );
110 $wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
111 $wgOut->addScriptFile( 'metadata.js' );
113 "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
117 public function getRedirectTarget() {
118 if ( $this->img
->isLocal() )
119 return parent
::getRedirectTarget();
121 // Foreign image page
122 $from = $this->img
->getRedirected();
123 $to = $this->img
->getName();
124 if ($from == $to) return null;
125 return $this->mRedirectTarget
= Title
::makeTitle( NS_IMAGE
, $to );
127 public function followRedirect() {
128 if ( $this->img
->isLocal() )
129 return parent
::followRedirect();
131 $from = $this->img
->getRedirected();
132 $to = $this->img
->getName();
133 if ($from == $to) return false;
134 return Title
::makeTitle( NS_IMAGE
, $to );
136 public function isRedirect( $text = false ) {
137 if ( $this->img
->isLocal() )
138 return parent
::isRedirect( $text );
140 return (bool)$this->img
->getRedirected();
143 public function isLocal() {
144 return $this->img
->isLocal();
147 public function getFile() {
156 * @param bool $metadata Whether or not to show the metadata link
159 function showTOC( $metadata ) {
161 $r = '<ul id="filetoc">
162 <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE
) . '</a></li>
163 <li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>
164 <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
165 ($metadata ?
' <li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
171 * Make a table with metadata to be shown in the output page.
173 * FIXME: bad interface, see note on MediaHandler::formatMetadata().
177 * @param array $exif The array containing the EXIF data
180 function makeMetadataTable( $metadata ) {
181 $r = wfMsg( 'metadata-help' ) . "\n\n";
182 $r .= "{| id=mw_metadata class=mw_metadata\n";
183 foreach ( $metadata as $type => $stuff ) {
184 foreach ( $stuff as $v ) {
185 $class = Sanitizer
::escapeId( $v['id'] );
186 if( $type == 'collapsed' ) {
187 $class .= ' collapsable';
189 $r .= "|- class=\"$class\"\n";
190 $r .= "!| {$v['name']}\n";
191 $r .= "|| {$v['value']}\n";
199 * Overloading Article's getContent method.
201 * Omit noarticletext if sharedupload; text will be fetched from the
202 * shared upload server if possible.
204 function getContent() {
205 if( $this->img
&& !$this->img
->isLocal() && 0 == $this->getID() ) {
208 return Article
::getContent();
211 function openShowImage() {
212 global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
214 $full_url = $this->img
->getURL();
215 $linkAttribs = false;
216 $sizeSel = intval( $wgUser->getOption( 'imagesize') );
217 if( !isset( $wgImageLimits[$sizeSel] ) ) {
218 $sizeSel = User
::getDefaultOption( 'imagesize' );
220 // The user offset might still be incorrect, specially if
221 // $wgImageLimits got changed (see bug #8858).
222 if( !isset( $wgImageLimits[$sizeSel] ) ) {
223 // Default to the first offset in $wgImageLimits
227 $max = $wgImageLimits[$sizeSel];
229 $maxHeight = $max[1];
230 $sk = $wgUser->getSkin();
231 $dirmark = $wgContLang->getDirMark();
233 if ( $this->img
->exists() ) {
235 $page = $wgRequest->getIntOrNull( 'page' );
236 if ( is_null( $page ) ) {
240 $params = array( 'page' => $page );
242 $width_orig = $this->img
->getWidth();
243 $width = $width_orig;
244 $height_orig = $this->img
->getHeight();
245 $height = $height_orig;
246 $mime = $this->img
->getMimeType();
248 $linkAttribs = array( 'href' => $full_url );
249 $longDesc = $this->img
->getLongDesc();
251 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
253 if ( $this->img
->allowInlineDisplay() ) {
256 # "Download high res version" link below the image
257 #$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->getSize() ), $mime );
258 # We'll show a thumbnail of this image
259 if ( $width > $maxWidth ||
$height > $maxHeight ) {
260 # Calculate the thumbnail size.
261 # First case, the limiting factor is the width, not the height.
262 if ( $width / $height >= $maxWidth / $maxHeight ) {
263 $height = round( $height * $maxWidth / $width);
265 # Note that $height <= $maxHeight now.
267 $newwidth = floor( $width * $maxHeight / $height);
268 $height = round( $height * $newwidth / $width );
270 # Note that $height <= $maxHeight now, but might not be identical
271 # because of rounding.
273 $msgbig = wfMsgHtml( 'show-big-image' );
274 $msgsmall = wfMsgExt( 'show-big-image-thumb',
275 array( 'parseinline' ), $wgLang->formatNum( $width ), $wgLang->formatNum( $height ) );
277 # Image is small enough to show full size on image page
278 $msgbig = htmlspecialchars( $this->img
->getName() );
279 $msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) );
282 $params['width'] = $width;
283 $thumbnail = $this->img
->transform( $params );
285 $anchorclose = "<br />";
286 if( $this->img
->mustRender() ) {
291 '<br />' . Xml
::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
294 if ( $this->img
->isMultipage() ) {
295 $wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
300 'alt' => $this->img
->getTitle()->getPrefixedText(),
303 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
304 $thumbnail->toHtml( $options ) .
305 $anchorclose . '</div>' );
308 if ( $this->img
->isMultipage() ) {
309 $count = $this->img
->pageCount();
312 $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
313 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page-1) );
314 $thumb1 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
315 array( 'page' => $page - 1 ) );
320 if ( $page < $count ) {
321 $label = wfMsg( 'imgmultipagenext' );
322 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page+
1) );
323 $thumb2 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
324 array( 'page' => $page +
1 ) );
332 'name' => 'pageselector',
333 'action' => $wgScript,
334 'onchange' => 'document.pageselector.submit();',
338 for ( $i=1; $i <= $count; $i++
) {
339 $options[] = Xml
::option( $wgLang->formatNum($i), $i, $i == $page );
341 $select = Xml
::tags( 'select',
342 array( 'id' => 'pageselector', 'name' => 'page' ),
343 implode( "\n", $options ) );
346 '</td><td><div class="multipageimagenavbox">' .
347 Xml
::openElement( 'form', $formParams ) .
348 Xml
::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
349 wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
350 Xml
::submitButton( wfMsg( 'imgmultigo' ) ) .
351 Xml
::closeElement( 'form' ) .
352 "<hr />$thumb1\n$thumb2<br clear=\"all\" /></div></td></tr></table>"
356 #if direct link is allowed but it's not a renderable image, show an icon.
357 if ($this->img
->isSafeFile()) {
358 $icon= $this->img
->iconThumb();
360 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
361 $icon->toHtml( array( 'desc-link' => true ) ) .
370 $filename = wfEscapeWikiText( $this->img
->getName() );
372 if (!$this->img
->isSafeFile()) {
373 $warning = wfMsgNoTrans( 'mediawarning' );
374 $wgOut->addWikiText( <<<EOT
375 <div class="fullMedia">
376 <span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
377 <span class="fileInfo"> $longDesc</span>
380 <div class="mediaWarning">$warning</div>
384 $wgOut->addWikiText( <<<EOT
385 <div class="fullMedia">
386 [[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $longDesc</span>
393 if(!$this->img
->isLocal()) {
394 $this->printSharedImageText();
397 # Image does not exist
399 $title = SpecialPage
::getTitleFor( 'Upload' );
400 $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
401 'wpDestFile=' . urlencode( $this->img
->getName() ) );
402 $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
407 * Show a notice that the file is from a shared repository
409 function printSharedImageText() {
410 global $wgOut, $wgUser;
412 $descUrl = $this->img
->getDescriptionUrl();
413 $descText = $this->img
->getDescriptionText();
414 $s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml( 'sharedupload' );
416 $sk = $wgUser->getSkin();
417 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) );
418 $msg = ( $descText ) ?
'shareduploadwiki-desc' : 'shareduploadwiki';
419 $msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
421 # Show message only if not voided by local sysops
426 $wgOut->addHTML( $s );
429 $this->mExtraDescription
= $descText;
433 function checkSharedConflict() {
434 global $wgOut, $wgUser;
435 $repoGroup = RepoGroup
::singleton();
436 if( !$repoGroup->hasForeignRepos() ) {
439 if( !$this->img
->isLocal() ) {
443 $this->dupFile
= null;
444 $repoGroup->forEachForeignRepo( array( $this, 'checkSharedConflictCallback' ) );
446 if( !$this->dupFile
)
448 $dupfile = $this->dupFile
;
450 ($this->img
->getSha1() == $dupfile->getSha1()) &&
451 ($this->img
->getSize() == $dupfile->getSize())
454 $sk = $wgUser->getSkin();
455 $descUrl = $dupfile->getDescriptionUrl();
457 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadduplicate-linktext' ) );
458 $wgOut->addHTML( '<div id="shared-image-dup">' . wfMsgWikiHtml( 'shareduploadduplicate', $link ) . '</div>' );
460 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadconflict-linktext' ) );
461 $wgOut->addHTML( '<div id="shared-image-conflict">' . wfMsgWikiHtml( 'shareduploadconflict', $link ) . '</div>' );
465 function checkSharedConflictCallback( $repo ) {
466 $dupfile = $repo->newFile( $this->img
->getTitle() );
467 if( $dupfile->exists() )
468 $this->dupFile
= $dupfile;
469 return $dupfile->exists();
472 function getUploadUrl() {
473 $uploadTitle = SpecialPage
::getTitleFor( 'Upload' );
474 return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img
->getName() ) );
478 * Print out the various links at the bottom of the image page, e.g. reupload,
479 * external editing (and instructions link) etc.
481 function uploadLinksBox() {
482 global $wgUser, $wgOut;
484 if( !$this->img
->isLocal() )
487 $sk = $wgUser->getSkin();
489 $wgOut->addHtml( '<br /><ul>' );
491 # "Upload a new version of this file" link
492 if( UploadForm
::userCanReUpload($wgUser,$this->img
->name
) ) {
493 $ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
494 $wgOut->addHtml( "<li><div class='plainlinks'>{$ulink}</div></li>" );
497 # Link to Special:FileDuplicateSearch
498 $dupeLink = $sk->makeKnownLinkObj( SpecialPage
::getTitleFor( 'FileDuplicateSearch', $this->mTitle
->getDBkey() ), wfMsgHtml( 'imagepage-searchdupe' ) );
499 $wgOut->addHtml( "<li>{$dupeLink}</li>" );
501 # External editing link
502 $elink = $sk->makeKnownLinkObj( $this->mTitle
, wfMsgHtml( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' );
503 $wgOut->addHtml( '<li>' . $elink . '<div>' . wfMsgWikiHtml( 'edit-externally-help' ) . '</div></li>' );
505 $wgOut->addHtml( '</ul>' );
508 function closeShowImage()
515 * If the page we've just displayed is in the "Image" namespace,
516 * we follow it with an upload history of the image and its usage.
518 function imageHistory()
520 global $wgUser, $wgOut, $wgUseExternalEditor;
522 $sk = $wgUser->getSkin();
524 if ( $this->img
->exists() ) {
525 $list = new ImageHistoryList( $sk, $this->current
);
526 $file = $this->current
;
527 $dims = $file->getDimensionsString();
528 $s = $list->beginImageHistoryList() .
529 $list->imageHistoryLine( true, $file );
530 // old image versions
531 $hist = $this->img
->getHistory();
532 foreach( $hist as $file ) {
533 $dims = $file->getDimensionsString();
534 $s .= $list->imageHistoryLine( false, $file );
536 $s .= $list->endImageHistoryList();
538 $wgOut->addHTML( $s );
540 $this->img
->resetHistory(); // free db resources
542 # Exist check because we don't want to show this on pages where an image
543 # doesn't exist along with the noimage message, that would suck. -ævar
544 if( $wgUseExternalEditor && $this->img
->exists() ) {
545 $this->uploadLinksBox();
550 function imageLinks()
552 global $wgUser, $wgOut;
556 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" );
558 $dbr = wfGetDB( DB_SLAVE
);
561 array( 'imagelinks', 'page' ),
562 array( 'page_namespace', 'page_title' ),
563 array( 'il_to' => $this->mTitle
->getDBkey(), 'il_from = page_id' ),
565 array( 'LIMIT' => $limit +
1)
568 if ( 0 == $dbr->numRows( $res ) ) {
569 $wgOut->addWikiMsg( 'nolinkstoimage' );
572 $wgOut->addWikiMsg( 'linkstoimage' );
573 $wgOut->addHTML( "<ul>\n" );
575 $sk = $wgUser->getSkin();
577 while ( $s = $res->fetchObject() ) {
579 if ( $count <= $limit ) {
580 // We have not yet reached the extra one that tells us there is more to fetch
581 $name = Title
::makeTitle( $s->page_namespace
, $s->page_title
);
582 $link = $sk->makeKnownLinkObj( $name, "" );
583 $wgOut->addHTML( "<li>{$link}</li>\n" );
586 $wgOut->addHTML( "</ul>\n" );
589 // Add a links to [[Special:Whatlinkshere]]
590 if ( $count > $limit )
591 $wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle
->getPrefixedDBkey() );
594 function imageRedirects()
596 global $wgUser, $wgOut;
598 $dbr = wfGetDB( DB_SLAVE
);
600 array( 'redirect', 'page' ),
601 array( 'page_title' ),
603 'rd_namespace' => NS_IMAGE
,
604 'rd_title' => $this->mTitle
->getDBkey(),
605 'page_namespace' => NS_IMAGE
,
612 if ( 0 == $dbr->numRows( $res ) )
615 $wgOut->addWikiMsg( 'redirectstofile' );
616 $wgOut->addHTML( "<ul>\n" );
618 $sk = $wgUser->getSkin();
619 while ( $row = $dbr->fetchObject( $res ) ) {
620 $name = Title
::makeTitle( NS_IMAGE
, $row->page_title
);
621 $link = $sk->makeKnownLinkObj( $name, "" );
622 wfDebug("Image redirect: {$row->page_title}\n");
623 $wgOut->addHTML( "<li>{$link}</li>\n" );
625 $wgOut->addHTML( "</ul>\n" );
631 * Delete the file, or an earlier version of it
633 public function delete() {
634 if( !$this->img
->exists() ||
!$this->img
->isLocal() ) {
635 // Standard article deletion
639 $deleter = new FileDeleteForm( $this->img
);
644 * Revert the file to an earlier version
646 public function revert() {
647 $reverter = new FileRevertForm( $this->img
);
648 $reverter->execute();
652 * Override handling of action=purge
655 if( $this->img
->exists() ) {
656 wfDebug( "ImagePage::doPurge purging " . $this->img
->getName() . "\n" );
657 $update = new HTMLCacheUpdate( $this->mTitle
, 'imagelinks' );
659 $this->img
->upgradeRow();
660 $this->img
->purgeCache();
662 wfDebug( "ImagePage::doPurge no image\n" );
668 * Display an error with a wikitext description
670 function showError( $description ) {
672 $wgOut->setPageTitle( wfMsg( "internalerror" ) );
673 $wgOut->setRobotpolicy( "noindex,nofollow" );
674 $wgOut->setArticleRelated( false );
675 $wgOut->enableClientCache( false );
676 $wgOut->addWikiText( $description );
682 * Builds the image revision log shown on image pages
686 class ImageHistoryList
{
688 protected $img, $skin, $title, $repo;
690 public function __construct( $skin, $img ) {
693 $this->title
= $img->getTitle();
696 public function beginImageHistoryList() {
697 global $wgOut, $wgUser;
698 $deleteColumn = $wgUser->isAllowed( 'delete' ) ||
$wgUser->isAllowed( 'deleterevision' );
699 return Xml
::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) )
700 . $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
701 . Xml
::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"
703 . ( $this->img
->isLocal() && $deleteColumn ?
'<td></td>' : '' )
704 . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
705 . '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
706 . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
707 . '<th class="mw-imagepage-filesize">' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
708 . '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
712 public function endImageHistoryList() {
716 public function imageHistoryLine( $iscur, $file ) {
717 global $wgUser, $wgLang, $wgContLang, $wgTitle;
719 $timestamp = wfTimestamp(TS_MW
, $file->getTimestamp());
720 $img = $iscur ?
$file->getName() : $file->getArchiveName();
721 $user = $file->getUser('id');
722 $usertext = $file->getUser('text');
723 $size = $file->getSize();
724 $description = $file->getDescription();
725 $dims = $file->getDimensionsString();
726 $sha1 = $file->getSha1();
728 $local = $this->img
->isLocal();
732 if( $local && ($wgUser->isAllowed('delete') ||
$wgUser->isAllowed('deleterevision') ) ) {
734 # Link to remove from history
735 if( $wgUser->isAllowed( 'delete' ) ) {
737 $q[] = 'action=delete';
739 $q[] = 'oldimage=' . urlencode( $img );
740 $row .= $this->skin
->makeKnownLinkObj(
742 wfMsgHtml( $iscur ?
'filehist-deleteall' : 'filehist-deleteone' ),
747 # Link to hide content
748 if( $wgUser->isAllowed( 'deleterevision' ) ) {
749 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
750 // If file is top revision or locked from this user, don't link
751 if( $iscur ||
!$file->userCan(File
::DELETED_RESTRICTED
) ) {
752 $del = wfMsgHtml( 'rev-delundel' );
754 // If the file was hidden, link to sha-1
755 list($ts,$name) = explode('!',$img,2);
756 $del = $this->skin
->makeKnownLinkObj( $revdel, wfMsg( 'rev-delundel' ),
757 'target=' . urlencode( $wgTitle->getPrefixedText() ) .
758 '&oldimage=' . urlencode( $ts ) );
759 // Bolden oversighted content
760 if( $file->isDeleted(File
::DELETED_RESTRICTED
) )
761 $del = "<strong>$del</strong>";
763 $row .= "<tt><small>$del</small></tt>";
768 // Reversion link/current indicator
771 $row .= wfMsgHtml( 'filehist-current' );
772 } elseif( $local && $wgUser->isLoggedIn() && $this->title
->userCan( 'edit' ) ) {
773 if( $file->isDeleted(File
::DELETED_FILE
) ) {
774 $row .= wfMsgHtml('filehist-revert');
777 $q[] = 'action=revert';
778 $q[] = 'oldimage=' . urlencode( $img );
779 $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
780 $row .= $this->skin
->makeKnownLinkObj( $this->title
,
781 wfMsgHtml( 'filehist-revert' ),
782 implode( '&', $q ) );
787 // Date/time and image link
789 if( !$file->userCan(File
::DELETED_FILE
) ) {
790 # Don't link to unviewable files
791 $row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
792 } else if( $file->isDeleted(File
::DELETED_FILE
) ) {
793 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
794 # Make a link to review the image
795 $url = $this->skin
->makeKnownLinkObj( $revdel, $wgLang->timeAndDate( $timestamp, true ),
796 "target=".$wgTitle->getPrefixedText()."&file=$sha1.".$this->img
->getExtension() );
797 $row .= '<span class="history-deleted">'.$url.'</span>';
799 $url = $iscur ?
$this->img
->getUrl() : $this->img
->getArchiveUrl( $img );
800 $row .= Xml
::element( 'a',
801 array( 'href' => $url ),
802 $wgLang->timeAndDate( $timestamp, true ) );
810 // Hide deleted usernames
811 if( $file->isDeleted(File
::DELETED_USER
) )
812 $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
814 $row .= $this->skin
->userLink( $user, $usertext ) .
815 $this->skin
->userToolLinks( $user, $usertext );
817 $row .= htmlspecialchars( $usertext );
822 $row .= '<td>' . htmlspecialchars( $dims ) . '</td>';
825 $row .= '<td class="mw-imagepage-filesize">' . $this->skin
->formatSize( $size ) . '</td>';
827 // Don't show deleted descriptions
828 if ( $file->isDeleted(File
::DELETED_COMMENT
) )
829 $row .= '<td><span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span></td>';
831 $row .= '<td>' . $this->skin
->commentBlock( $description, $this->title
) . '</td>';
833 return "<tr>{$row}</tr>\n";