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;
23 function __construct( $title, $time = false ) {
24 parent
::__construct( $title );
25 $this->img
= wfFindFile( $this->mTitle
, $time );
27 $this->img
= wfLocalFile( $this->mTitle
);
28 $this->current
= $this->img
;
30 $this->current
= $time ?
wfLocalFile( $this->mTitle
) : $this->img
;
32 $this->repo
= $this->img
->getRepo();
37 * Handler for action=render
38 * Include body text only; none of the image extras
42 $wgOut->setArticleBodyOnly( true );
47 global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
49 if ( $this->mTitle
->getNamespace() == NS_IMAGE
&& $this->img
->getRedirected() ) {
50 if ( $this->mTitle
->getDBkey() == $this->img
->getName() ) {
51 // mTitle is the same as the redirect target so ask Article
52 // to perform the redirect for us.
53 return Article
::view();
55 // mTitle is not the same as the redirect target so it is
56 // probably the redirect page itself. Fake the redirect symbol
57 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
58 $this->viewRedirect( Title
::makeTitle( NS_IMAGE
, $this->img
->getName() ),
59 /* $overwriteSubtitle */ true, /* $forceKnown */ true );
65 $diff = $wgRequest->getVal( 'diff' );
66 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
68 if ( $this->mTitle
->getNamespace() != NS_IMAGE ||
( isset( $diff ) && $diffOnly ) )
69 return Article
::view();
71 if ($wgShowEXIF && $this->img
->exists()) {
72 // FIXME: bad interface, see note on MediaHandler::formatMetadata().
73 $formattedMetadata = $this->img
->formatMetadata();
74 $showmeta = $formattedMetadata !== false;
79 if ($this->img
->exists())
80 $wgOut->addHTML($this->showTOC($showmeta));
82 $this->openShowImage();
84 # No need to display noarticletext, we use our own message, output in openShowImage()
85 if ( $this->getID() ) {
88 # Just need to set the right headers
89 $wgOut->setArticleFlag( true );
90 $wgOut->setRobotpolicy( 'noindex,nofollow' );
91 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
95 # Show shared description, if needed
96 if ( $this->mExtraDescription
) {
97 $fol = wfMsgNoTrans( 'shareddescriptionfollows' );
98 if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
99 $wgOut->addWikiText( $fol );
101 $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription
. '</div>' );
103 $this->checkSharedConflict();
106 $this->closeShowImage();
107 $this->imageHistory();
108 // TODO: Cleanup the following
110 $wgOut->addHTML( Xml
::element( 'h2',
111 array( 'id' => 'filelinks' ),
112 wfMsg( 'imagelinks' ) ) . "\n" );
114 // TODO: We may want to find local images redirecting to a foreign
115 // file: "The following local files redirect to this file"
116 if ( $this->img
->isLocal() ) $this->imageRedirects();
120 global $wgStylePath, $wgStyleVersion;
121 $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
122 $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
123 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ). "\n" );
124 $wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
125 $wgOut->addScriptFile( 'metadata.js' );
127 "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
131 public function getRedirectTarget() {
132 if ( $this->img
->isLocal() )
133 return parent
::getRedirectTarget();
135 // Foreign image page
136 $from = $this->img
->getRedirected();
137 $to = $this->img
->getName();
138 if ($from == $to) return null;
139 return $this->mRedirectTarget
= Title
::makeTitle( NS_IMAGE
, $to );
141 public function followRedirect() {
142 if ( $this->img
->isLocal() )
143 return parent
::followRedirect();
145 $from = $this->img
->getRedirected();
146 $to = $this->img
->getName();
147 if ($from == $to) return false;
148 return Title
::makeTitle( NS_IMAGE
, $to );
150 public function isRedirect( $text = false ) {
151 if ( $this->img
->isLocal() )
152 return parent
::isRedirect( $text );
154 return (bool)$this->img
->getRedirected();
157 public function isLocal() {
158 return $this->img
->isLocal();
161 public function getFile() {
165 public function getDuplicates() {
166 if ( !is_null($this->dupes
) ) return $this->dupes
;
168 if ( !( $hash = $this->img
->getSha1() ) )
169 return $this->dupes
= array();
170 $dupes = RepoGroup
::singleton()->findBySha1( $hash );
172 // Remove duplicates with self and non matching file sizes
173 $self = $this->img
->getRepoName().':'.$this->img
->getName();
174 $size = $this->img
->getSize();
175 foreach ( $dupes as $index => $file ) {
176 $key = $file->getRepoName().':'.$file->getName();
178 unset( $dupes[$index] );
179 if ( $file->getSize() != $size )
180 unset( $dupes[$index] );
182 return $this->dupes
= $dupes;
192 * @param bool $metadata Whether or not to show the metadata link
195 function showTOC( $metadata ) {
197 $r = '<ul id="filetoc">
198 <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE
) . '</a></li>
199 <li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>
200 <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
201 ($metadata ?
' <li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
207 * Make a table with metadata to be shown in the output page.
209 * FIXME: bad interface, see note on MediaHandler::formatMetadata().
213 * @param array $exif The array containing the EXIF data
216 function makeMetadataTable( $metadata ) {
217 $r = wfMsg( 'metadata-help' ) . "\n\n";
218 $r .= "{| id=mw_metadata class=mw_metadata\n";
219 foreach ( $metadata as $type => $stuff ) {
220 foreach ( $stuff as $v ) {
221 $class = Sanitizer
::escapeId( $v['id'] );
222 if( $type == 'collapsed' ) {
223 $class .= ' collapsable';
225 $r .= "|- class=\"$class\"\n";
226 $r .= "!| {$v['name']}\n";
227 $r .= "|| {$v['value']}\n";
235 * Overloading Article's getContent method.
237 * Omit noarticletext if sharedupload; text will be fetched from the
238 * shared upload server if possible.
240 function getContent() {
241 if( $this->img
&& !$this->img
->isLocal() && 0 == $this->getID() ) {
244 return Article
::getContent();
247 function openShowImage() {
248 global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
250 $full_url = $this->img
->getURL();
251 $linkAttribs = false;
252 $sizeSel = intval( $wgUser->getOption( 'imagesize') );
253 if( !isset( $wgImageLimits[$sizeSel] ) ) {
254 $sizeSel = User
::getDefaultOption( 'imagesize' );
256 // The user offset might still be incorrect, specially if
257 // $wgImageLimits got changed (see bug #8858).
258 if( !isset( $wgImageLimits[$sizeSel] ) ) {
259 // Default to the first offset in $wgImageLimits
263 $max = $wgImageLimits[$sizeSel];
265 $maxHeight = $max[1];
266 $sk = $wgUser->getSkin();
267 $dirmark = $wgContLang->getDirMark();
269 if ( $this->img
->exists() ) {
271 $page = $wgRequest->getIntOrNull( 'page' );
272 if ( is_null( $page ) ) {
276 $params = array( 'page' => $page );
278 $width_orig = $this->img
->getWidth();
279 $width = $width_orig;
280 $height_orig = $this->img
->getHeight();
281 $height = $height_orig;
282 $mime = $this->img
->getMimeType();
284 $linkAttribs = array( 'href' => $full_url );
285 $longDesc = $this->img
->getLongDesc();
287 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
289 if ( $this->img
->allowInlineDisplay() ) {
292 # "Download high res version" link below the image
293 #$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->getSize() ), $mime );
294 # We'll show a thumbnail of this image
295 if ( $width > $maxWidth ||
$height > $maxHeight ) {
296 # Calculate the thumbnail size.
297 # First case, the limiting factor is the width, not the height.
298 if ( $width / $height >= $maxWidth / $maxHeight ) {
299 $height = round( $height * $maxWidth / $width);
301 # Note that $height <= $maxHeight now.
303 $newwidth = floor( $width * $maxHeight / $height);
304 $height = round( $height * $newwidth / $width );
306 # Note that $height <= $maxHeight now, but might not be identical
307 # because of rounding.
309 $msgbig = wfMsgHtml( 'show-big-image' );
310 $msgsmall = wfMsgExt( 'show-big-image-thumb',
311 array( 'parseinline' ), $wgLang->formatNum( $width ), $wgLang->formatNum( $height ) );
313 # Image is small enough to show full size on image page
314 $msgbig = htmlspecialchars( $this->img
->getName() );
315 $msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) );
318 $params['width'] = $width;
319 $thumbnail = $this->img
->transform( $params );
321 $anchorclose = "<br />";
322 if( $this->img
->mustRender() ) {
327 '<br />' . Xml
::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
330 if ( $this->img
->isMultipage() ) {
331 $wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
336 'alt' => $this->img
->getTitle()->getPrefixedText(),
339 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
340 $thumbnail->toHtml( $options ) .
341 $anchorclose . '</div>' );
344 if ( $this->img
->isMultipage() ) {
345 $count = $this->img
->pageCount();
348 $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
349 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page-1) );
350 $thumb1 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
351 array( 'page' => $page - 1 ) );
356 if ( $page < $count ) {
357 $label = wfMsg( 'imgmultipagenext' );
358 $link = $sk->makeKnownLinkObj( $this->mTitle
, $label, 'page='. ($page+
1) );
359 $thumb2 = $sk->makeThumbLinkObj( $this->mTitle
, $this->img
, $link, $label, 'none',
360 array( 'page' => $page +
1 ) );
368 'name' => 'pageselector',
369 'action' => $wgScript,
370 'onchange' => 'document.pageselector.submit();',
374 for ( $i=1; $i <= $count; $i++
) {
375 $options[] = Xml
::option( $wgLang->formatNum($i), $i, $i == $page );
377 $select = Xml
::tags( 'select',
378 array( 'id' => 'pageselector', 'name' => 'page' ),
379 implode( "\n", $options ) );
382 '</td><td><div class="multipageimagenavbox">' .
383 Xml
::openElement( 'form', $formParams ) .
384 Xml
::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
385 wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
386 Xml
::submitButton( wfMsg( 'imgmultigo' ) ) .
387 Xml
::closeElement( 'form' ) .
388 "<hr />$thumb1\n$thumb2<br clear=\"all\" /></div></td></tr></table>"
392 #if direct link is allowed but it's not a renderable image, show an icon.
393 if ($this->img
->isSafeFile()) {
394 $icon= $this->img
->iconThumb();
396 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
397 $icon->toHtml( array( 'desc-link' => true ) ) .
406 $filename = wfEscapeWikiText( $this->img
->getName() );
408 if (!$this->img
->isSafeFile()) {
409 $warning = wfMsgNoTrans( 'mediawarning' );
410 $wgOut->addWikiText( <<<EOT
411 <div class="fullMedia">
412 <span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
413 <span class="fileInfo"> $longDesc</span>
416 <div class="mediaWarning">$warning</div>
420 $wgOut->addWikiText( <<<EOT
421 <div class="fullMedia">
422 [[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $longDesc</span>
429 if(!$this->img
->isLocal()) {
430 $this->printSharedImageText();
433 # Image does not exist
435 $title = SpecialPage
::getTitleFor( 'Upload' );
436 $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
437 'wpDestFile=' . urlencode( $this->img
->getName() ) );
438 $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
443 * Show a notice that the file is from a shared repository
445 function printSharedImageText() {
446 global $wgOut, $wgUser;
448 $descUrl = $this->img
->getDescriptionUrl();
449 $descText = $this->img
->getDescriptionText();
450 $s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml( 'sharedupload' );
452 $sk = $wgUser->getSkin();
453 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) );
454 $msg = ( $descText ) ?
'shareduploadwiki-desc' : 'shareduploadwiki';
455 $msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
457 # Show message only if not voided by local sysops
462 $wgOut->addHTML( $s );
465 $this->mExtraDescription
= $descText;
470 * Check for files with the same name on the foreign repos.
472 function checkSharedConflict() {
473 global $wgOut, $wgUser;
474 $repoGroup = RepoGroup
::singleton();
475 if( !$repoGroup->hasForeignRepos() ) {
478 if( !$this->img
->isLocal() ) {
482 $this->dupFile
= null;
483 $repoGroup->forEachForeignRepo( array( $this, 'checkSharedConflictCallback' ) );
485 if( !$this->dupFile
)
487 $dupfile = $this->dupFile
;
489 ($this->img
->getSha1() == $dupfile->getSha1()) &&
490 ($this->img
->getSize() == $dupfile->getSize())
493 $sk = $wgUser->getSkin();
494 $descUrl = $dupfile->getDescriptionUrl();
496 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadduplicate-linktext' ) );
497 $wgOut->addHTML( '<div id="shared-image-dup">' . wfMsgWikiHtml( 'shareduploadduplicate', $link ) . '</div>' );
499 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadconflict-linktext' ) );
500 $wgOut->addHTML( '<div id="shared-image-conflict">' . wfMsgWikiHtml( 'shareduploadconflict', $link ) . '</div>' );
504 function checkSharedConflictCallback( $repo ) {
505 $dupfile = $repo->newFile( $this->img
->getTitle() );
506 if( $dupfile->exists() )
507 $this->dupFile
= $dupfile;
508 return $dupfile->exists();
511 function getUploadUrl() {
512 $uploadTitle = SpecialPage
::getTitleFor( 'Upload' );
513 return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img
->getName() ) );
517 * Print out the various links at the bottom of the image page, e.g. reupload,
518 * external editing (and instructions link) etc.
520 function uploadLinksBox() {
521 global $wgUser, $wgOut;
523 if( !$this->img
->isLocal() )
526 $sk = $wgUser->getSkin();
528 $wgOut->addHtml( '<br /><ul>' );
530 # "Upload a new version of this file" link
531 if( UploadForm
::userCanReUpload($wgUser,$this->img
->name
) ) {
532 $ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
533 $wgOut->addHtml( "<li><div class='plainlinks'>{$ulink}</div></li>" );
536 # Link to Special:FileDuplicateSearch
537 $dupeLink = $sk->makeKnownLinkObj( SpecialPage
::getTitleFor( 'FileDuplicateSearch', $this->mTitle
->getDBkey() ), wfMsgHtml( 'imagepage-searchdupe' ) );
538 $wgOut->addHtml( "<li>{$dupeLink}</li>" );
540 # External editing link
541 $elink = $sk->makeKnownLinkObj( $this->mTitle
, wfMsgHtml( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' );
542 $wgOut->addHtml( '<li>' . $elink . '<div>' . wfMsgWikiHtml( 'edit-externally-help' ) . '</div></li>' );
544 $wgOut->addHtml( '</ul>' );
547 function closeShowImage()
554 * If the page we've just displayed is in the "Image" namespace,
555 * we follow it with an upload history of the image and its usage.
557 function imageHistory()
559 global $wgUser, $wgOut, $wgUseExternalEditor;
561 $sk = $wgUser->getSkin();
563 if ( $this->img
->exists() ) {
564 $list = new ImageHistoryList( $sk, $this->current
);
565 $file = $this->current
;
566 $dims = $file->getDimensionsString();
567 $s = $list->beginImageHistoryList() .
568 $list->imageHistoryLine( true, $file );
569 // old image versions
570 $hist = $this->img
->getHistory();
571 foreach( $hist as $file ) {
572 $dims = $file->getDimensionsString();
573 $s .= $list->imageHistoryLine( false, $file );
575 $s .= $list->endImageHistoryList();
577 $wgOut->addHTML( $s );
579 $this->img
->resetHistory(); // free db resources
581 # Exist check because we don't want to show this on pages where an image
582 # doesn't exist along with the noimage message, that would suck. -ævar
583 if( $wgUseExternalEditor && $this->img
->exists() ) {
584 $this->uploadLinksBox();
589 function imageLinks()
591 global $wgUser, $wgOut;
595 $dbr = wfGetDB( DB_SLAVE
);
598 array( 'imagelinks', 'page' ),
599 array( 'page_namespace', 'page_title' ),
600 array( 'il_to' => $this->mTitle
->getDBkey(), 'il_from = page_id' ),
602 array( 'LIMIT' => $limit +
1)
605 if ( 0 == $dbr->numRows( $res ) ) {
606 $wgOut->addWikiMsg( 'nolinkstoimage' );
609 $wgOut->addWikiMsg( 'linkstoimage' );
610 $wgOut->addHTML( "<ul class='mw-imagepage-linktoimage'>\n" );
612 $sk = $wgUser->getSkin();
614 while ( $s = $res->fetchObject() ) {
616 if ( $count <= $limit ) {
617 // We have not yet reached the extra one that tells us there is more to fetch
618 $name = Title
::makeTitle( $s->page_namespace
, $s->page_title
);
619 $link = $sk->makeKnownLinkObj( $name, "" );
620 $wgOut->addHTML( "<li>{$link}</li>\n" );
623 $wgOut->addHTML( "</ul>\n" );
626 // Add a links to [[Special:Whatlinkshere]]
627 if ( $count > $limit )
628 $wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle
->getPrefixedDBkey() );
631 function imageRedirects()
633 global $wgUser, $wgOut;
635 $redirects = $this->getTitle()->getRedirectsHere( NS_IMAGE
);
636 if ( count( $redirects ) == 0 ) return;
639 $wgOut->addWikiMsg( 'redirectstofile' );
640 $wgOut->addHTML( "<ul class='mw-imagepage-redirectstofile'>\n" );
642 $sk = $wgUser->getSkin();
643 foreach ( $redirects as $title ) {
644 $link = $sk->makeKnownLinkObj( $title, "" );
645 $wgOut->addHTML( "<li>{$link}</li>\n" );
647 $wgOut->addHTML( "</ul>\n" );
651 function imageDupes() {
652 global $wgOut, $wgUser;
654 $dupes = $this->getDuplicates();
655 if ( count( $dupes ) == 0 ) return;
657 $wgOut->addWikiMsg( 'duplicatesoffile' );
658 $wgOut->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
660 $sk = $wgUser->getSkin();
661 foreach ( $dupes as $file ) {
662 if ( $file->isLocal() )
663 $link = $sk->makeKnownLinkObj( $file->getTitle(), "" );
665 $link = $sk->makeExternalLink( $file->getDescriptionUrl(),
666 $file->getTitle()->getPrefixedText() );
667 $wgOut->addHTML( "<li>{$link}</li>\n" );
669 $wgOut->addHTML( "</ul>\n" );
673 * Delete the file, or an earlier version of it
675 public function delete() {
676 if( !$this->img
->exists() ||
!$this->img
->isLocal() ) {
677 // Standard article deletion
681 $deleter = new FileDeleteForm( $this->img
);
686 * Revert the file to an earlier version
688 public function revert() {
689 $reverter = new FileRevertForm( $this->img
);
690 $reverter->execute();
694 * Override handling of action=purge
697 if( $this->img
->exists() ) {
698 wfDebug( "ImagePage::doPurge purging " . $this->img
->getName() . "\n" );
699 $update = new HTMLCacheUpdate( $this->mTitle
, 'imagelinks' );
701 $this->img
->upgradeRow();
702 $this->img
->purgeCache();
704 wfDebug( "ImagePage::doPurge no image\n" );
710 * Display an error with a wikitext description
712 function showError( $description ) {
714 $wgOut->setPageTitle( wfMsg( "internalerror" ) );
715 $wgOut->setRobotpolicy( "noindex,nofollow" );
716 $wgOut->setArticleRelated( false );
717 $wgOut->enableClientCache( false );
718 $wgOut->addWikiText( $description );
724 * Builds the image revision log shown on image pages
728 class ImageHistoryList
{
730 protected $img, $skin, $title, $repo;
732 public function __construct( $skin, $img ) {
735 $this->title
= $img->getTitle();
738 public function beginImageHistoryList() {
739 global $wgOut, $wgUser;
740 $deleteColumn = $wgUser->isAllowed( 'delete' ) ||
$wgUser->isAllowed( 'deleterevision' );
741 return Xml
::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) )
742 . $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
743 . Xml
::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"
745 . ( $this->img
->isLocal() && $deleteColumn ?
'<td></td>' : '' )
746 . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
747 . '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
748 . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
749 . '<th class="mw-imagepage-filesize">' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
750 . '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
754 public function endImageHistoryList() {
758 public function imageHistoryLine( $iscur, $file ) {
759 global $wgUser, $wgLang, $wgContLang, $wgTitle;
761 $timestamp = wfTimestamp(TS_MW
, $file->getTimestamp());
762 $img = $iscur ?
$file->getName() : $file->getArchiveName();
763 $user = $file->getUser('id');
764 $usertext = $file->getUser('text');
765 $size = $file->getSize();
766 $description = $file->getDescription();
767 $dims = $file->getDimensionsString();
768 $sha1 = $file->getSha1();
770 $local = $this->img
->isLocal();
774 if( $local && ($wgUser->isAllowed('delete') ||
$wgUser->isAllowed('deleterevision') ) ) {
776 # Link to remove from history
777 if( $wgUser->isAllowed( 'delete' ) ) {
779 $q[] = 'action=delete';
781 $q[] = 'oldimage=' . urlencode( $img );
782 $row .= $this->skin
->makeKnownLinkObj(
784 wfMsgHtml( $iscur ?
'filehist-deleteall' : 'filehist-deleteone' ),
789 # Link to hide content
790 if( $wgUser->isAllowed( 'deleterevision' ) ) {
791 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
792 // If file is top revision or locked from this user, don't link
793 if( $iscur ||
!$file->userCan(File
::DELETED_RESTRICTED
) ) {
794 $del = wfMsgHtml( 'rev-delundel' );
796 // If the file was hidden, link to sha-1
797 list($ts,$name) = explode('!',$img,2);
798 $del = $this->skin
->makeKnownLinkObj( $revdel, wfMsg( 'rev-delundel' ),
799 'target=' . urlencode( $wgTitle->getPrefixedText() ) .
800 '&oldimage=' . urlencode( $ts ) );
801 // Bolden oversighted content
802 if( $file->isDeleted(File
::DELETED_RESTRICTED
) )
803 $del = "<strong>$del</strong>";
805 $row .= "<tt><small>$del</small></tt>";
810 // Reversion link/current indicator
813 $row .= wfMsgHtml( 'filehist-current' );
814 } elseif( $local && $wgUser->isLoggedIn() && $this->title
->userCan( 'edit' ) ) {
815 if( $file->isDeleted(File
::DELETED_FILE
) ) {
816 $row .= wfMsgHtml('filehist-revert');
819 $q[] = 'action=revert';
820 $q[] = 'oldimage=' . urlencode( $img );
821 $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
822 $row .= $this->skin
->makeKnownLinkObj( $this->title
,
823 wfMsgHtml( 'filehist-revert' ),
824 implode( '&', $q ) );
829 // Date/time and image link
831 if( !$file->userCan(File
::DELETED_FILE
) ) {
832 # Don't link to unviewable files
833 $row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
834 } else if( $file->isDeleted(File
::DELETED_FILE
) ) {
835 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
836 # Make a link to review the image
837 $url = $this->skin
->makeKnownLinkObj( $revdel, $wgLang->timeAndDate( $timestamp, true ),
838 "target=".$wgTitle->getPrefixedText()."&file=$sha1.".$this->img
->getExtension() );
839 $row .= '<span class="history-deleted">'.$url.'</span>';
841 $url = $iscur ?
$this->img
->getUrl() : $this->img
->getArchiveUrl( $img );
842 $row .= Xml
::element( 'a',
843 array( 'href' => $url ),
844 $wgLang->timeAndDate( $timestamp, true ) );
852 // Hide deleted usernames
853 if( $file->isDeleted(File
::DELETED_USER
) )
854 $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
856 $row .= $this->skin
->userLink( $user, $usertext ) .
857 $this->skin
->userToolLinks( $user, $usertext );
859 $row .= htmlspecialchars( $usertext );
864 $row .= '<td>' . htmlspecialchars( $dims ) . '</td>';
867 $row .= '<td class="mw-imagepage-filesize">' . $this->skin
->formatSize( $size ) . '</td>';
869 // Don't show deleted descriptions
870 if ( $file->isDeleted(File
::DELETED_COMMENT
) )
871 $row .= '<td><span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span></td>';
873 $row .= '<td>' . $this->skin
->commentBlock( $description, $this->title
) . '</td>';
875 return "<tr>{$row}</tr>\n";