class ImagePage extends Article {
/* private */ var $img; // Image object this page is shown for
+ /* private */ var $repo;
var $mExtraDescription = false;
- function __construct( $title ) {
+ function __construct( $title, $time = false ) {
parent::__construct( $title );
- $this->img = wfFindFile( $this->mTitle );
+ $this->img = wfFindFile( $this->mTitle, $time );
if ( !$this->img ) {
$this->img = wfLocalFile( $this->mTitle );
+ $this->current = $this->img;
+ } else {
+ $this->current = $time ? wfLocalFile( $this->mTitle ) : $this->img;
}
+ $this->repo = $this->img->repo;
}
/**
function render() {
global $wgOut;
$wgOut->setArticleBodyOnly( true );
- $wgOut->addSecondaryWikitext( $this->getContent() );
+ parent::view();
}
function view() {
return Article::view();
if ($wgShowEXIF && $this->img->exists()) {
+ // FIXME: bad interface, see note on MediaHandler::formatMetadata().
$formattedMetadata = $this->img->formatMetadata();
$showmeta = $formattedMetadata !== false;
} else {
} else {
# Just need to set the right headers
$wgOut->setArticleFlag( true );
- $wgOut->setRobotpolicy( 'index,follow' );
+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
$this->viewUpdates();
}
# Show shared description, if needed
if ( $this->mExtraDescription ) {
- $fol = wfMsg( 'shareddescriptionfollows' );
+ $fol = wfMsgNoTrans( 'shareddescriptionfollows' );
if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
$wgOut->addWikiText( $fol );
}
$wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . '</div>' );
+ } else {
+ $this->checkSharedConflict();
}
$this->closeShowImage();
/**
* Make a table with metadata to be shown in the output page.
*
+ * FIXME: bad interface, see note on MediaHandler::formatMetadata().
+ *
* @access private
*
* @param array $exif The array containing the EXIF data
$r = wfMsg( 'metadata-help' ) . "\n\n";
$r .= "{| id=mw_metadata class=mw_metadata\n";
foreach ( $metadata as $type => $stuff ) {
- foreach ( $stuff as $k => $v ) {
+ foreach ( $stuff as $v ) {
$class = Sanitizer::escapeId( $v['id'] );
if( $type == 'collapsed' ) {
$class .= ' collapsable';
/**
* Overloading Article's getContent method.
- *
+ *
* Omit noarticletext if sharedupload; text will be fetched from the
* shared upload server if possible.
*/
}
function openShowImage() {
- global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang;
+ global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
$full_url = $this->img->getURL();
$linkAttribs = false;
$maxWidth = $max[0];
$maxHeight = $max[1];
$sk = $wgUser->getSkin();
+ $dirmark = $wgContLang->getDirMark();
if ( $this->img->exists() ) {
# image
$mime = $this->img->getMimeType();
$showLink = false;
$linkAttribs = array( 'href' => $full_url );
+ $longDesc = $this->img->getLongDesc();
- wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
+ wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
- if ( $this->img->allowInlineDisplay() and $width and $height) {
+ if ( $this->img->allowInlineDisplay() ) {
# image
# "Download high res version" link below the image
- $msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->getSize() ), $mime );
+ #$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->getSize() ), $mime );
# We'll show a thumbnail of this image
if ( $width > $maxWidth || $height > $maxHeight ) {
# Calculate the thumbnail size.
}
$msgbig = wfMsgHtml( 'show-big-image' );
$msgsmall = wfMsgExt( 'show-big-image-thumb',
- array( 'parseinline' ), $width, $height );
+ array( 'parseinline' ), $wgLang->formatNum( $width ), $wgLang->formatNum( $height ) );
} else {
# Image is small enough to show full size on image page
$msgbig = htmlspecialchars( $this->img->getName() );
if( $this->img->mustRender() ) {
$showLink = true;
} else {
- $anchorclose .=
+ $anchorclose .=
$msgsmall .
- '<br />' . Xml::tags( 'a', $linkAttribs, $msgbig ) . ' ' . $msgsize;
+ '<br />' . Xml::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
}
if ( $this->img->isMultipage() ) {
$wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
}
- $imgAttribs = array(
- 'border' => 0,
- 'alt' => $this->img->getTitle()->getPrefixedText()
- );
-
if ( $thumbnail ) {
- $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
- $thumbnail->toHtml( $imgAttribs, $linkAttribs ) .
+ $options = array(
+ 'alt' => $this->img->getTitle()->getPrefixedText(),
+ 'file-link' => true,
+ );
+ $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
+ $thumbnail->toHtml( $options ) .
$anchorclose . '</div>' );
}
if ( $page > 1 ) {
$label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
$link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page-1) );
- $thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $link, $label, 'none',
+ $thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $link, $label, 'none',
array( 'page' => $page - 1 ) );
} else {
$thumb1 = '';
if ( $page < $count ) {
$label = wfMsg( 'imgmultipagenext' );
$link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page+1) );
- $thumb2 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $link, $label, 'none',
+ $thumb2 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $link, $label, 'none',
array( 'page' => $page + 1 ) );
} else {
$thumb2 = '';
}
global $wgScript;
- $select = '<form name="pageselector" action="' .
+ $select = '<form name="pageselector" action="' .
htmlspecialchars( $wgScript ) .
'" method="get" onchange="document.pageselector.submit();">' .
Xml::hidden( 'title', $this->getTitle()->getPrefixedDbKey() );
if ($this->img->isSafeFile()) {
$icon= $this->img->iconThumb();
- $wgOut->addHTML( '<div class="fullImageLink" id="file"><a href="' . $full_url . '">' .
- $icon->toHtml() .
- '</a></div>' );
+ $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
+ $icon->toHtml( array( 'desc-link' => true ) ) .
+ '</div>' );
}
$showLink = true;
if ($showLink) {
- // Workaround for incorrect MIME type on SVGs uploaded in previous versions
- if ($mime == 'image/svg') $mime = 'image/svg+xml';
-
$filename = wfEscapeWikiText( $this->img->getName() );
- $info = wfMsg( 'file-info', $sk->formatSize( $this->img->getSize() ), $mime );
- $infores = '';
-
- // Check for MIME type. Other types may have more information in the future.
- if (substr($mime,0,9) == 'image/svg' ) {
- $infores = wfMsg('file-svg', $width_orig, $height_orig ) . '<br />';
- }
- global $wgContLang;
- $dirmark = $wgContLang->getDirMark();
if (!$this->img->isSafeFile()) {
- $warning = wfMsg( 'mediawarning' );
+ $warning = wfMsgNoTrans( 'mediawarning' );
$wgOut->addWikiText( <<<EOT
-<div class="fullMedia">$infores
+<div class="fullMedia">
<span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
-<span class="fileInfo"> $info</span>
+<span class="fileInfo"> $longDesc</span>
</div>
<div class="mediaWarning">$warning</div>
);
} else {
$wgOut->addWikiText( <<<EOT
-<div class="fullMedia">$infores
-[[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $info</span>
+<div class="fullMedia">
+[[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $longDesc</span>
</div>
EOT
);
}
}
+ /**
+ * Show a notice that the file is from a shared repository
+ */
function printSharedImageText() {
global $wgOut, $wgUser;
$descUrl = $this->img->getDescriptionUrl();
$descText = $this->img->getDescriptionText();
- $s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml("sharedupload");
- if ( $descUrl && !$descText) {
+ $s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml( 'sharedupload' );
+ if ( $descUrl ) {
$sk = $wgUser->getSkin();
- $link = $sk->makeExternalLink( $descUrl, wfMsg('shareduploadwiki-linktext') );
- $s .= " " . wfMsgWikiHtml('shareduploadwiki', $link);
+ $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) );
+ $msg = ( $descText ) ? 'shareduploadwiki-desc' : 'shareduploadwiki';
+ $msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
+ if ( $msg != '-' ) {
+ # Show message only if not voided by local sysops
+ $s .= $msg;
+ }
}
$s .= "</div>";
- $wgOut->addHTML($s);
+ $wgOut->addHTML( $s );
if ( $descText ) {
$this->mExtraDescription = $descText;
}
}
+ function checkSharedConflict() {
+ global $wgOut, $wgUser;
+ $repoGroup = RepoGroup::singleton();
+ if( !$repoGroup->hasForeignRepos() ) {
+ return;
+ }
+ if( !$this->img->isLocal() ) {
+ return;
+ }
+
+ $this->dupFile = null;
+ $repoGroup->forEachForeignRepo( array( $this, 'checkSharedConflictCallback' ) );
+
+ if( !$this->dupFile )
+ return;
+ $dupfile = $this->dupFile;
+ $same = (
+ ($this->img->getSha1() == $dupfile->getSha1()) &&
+ ($this->img->getSize() == $dupfile->getSize())
+ );
+
+ $sk = $wgUser->getSkin();
+ $descUrl = $dupfile->getDescriptionUrl();
+ if( $same ) {
+ $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadduplicate-linktext' ) );
+ $wgOut->addHTML( '<div id="shared-image-dup">' . wfMsgWikiHtml( 'shareduploadduplicate', $link ) . '</div>' );
+ } else {
+ $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadconflict-linktext' ) );
+ $wgOut->addHTML( '<div id="shared-image-conflict">' . wfMsgWikiHtml( 'shareduploadconflict', $link ) . '</div>' );
+ }
+ }
+
+ function checkSharedConflictCallback( $repo ) {
+ $dupfile = $repo->newFile( $this->img->getTitle() );
+ if( $dupfile->exists() )
+ $this->dupFile = $dupfile;
+ return $dupfile->exists();
+ }
+
function getUploadUrl() {
- global $wgServer;
$uploadTitle = SpecialPage::getTitleFor( 'Upload' );
- return $wgServer . $uploadTitle->getLocalUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
+ return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
}
/**
return;
$sk = $wgUser->getSkin();
-
+
$wgOut->addHtml( '<br /><ul>' );
-
+
# "Upload a new version of this file" link
if( UploadForm::userCanReUpload($wgUser,$this->img->name) ) {
$ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
$wgOut->addHtml( "<li><div class='plainlinks'>{$ulink}</div></li>" );
}
-
+
+ # Link to Special:FileDuplicateSearch
+ $dupeLink = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'FileDuplicateSearch', $this->mTitle->getDBkey() ), wfMsgHtml( 'imagepage-searchdupe' ) );
+ $wgOut->addHtml( "<li>{$dupeLink}</li>" );
+
# External editing link
$elink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' );
$wgOut->addHtml( '<li>' . $elink . '<div>' . wfMsgWikiHtml( 'edit-externally-help' ) . '</div></li>' );
-
+
$wgOut->addHtml( '</ul>' );
}
$sk = $wgUser->getSkin();
- $line = $this->img->nextHistoryLine();
-
- if ( $line ) {
- $list = new ImageHistoryList( $sk, $this->img );
+ if ( $this->img->exists() ) {
+ $list = new ImageHistoryList( $sk, $this->current );
+ $file = $this->current;
+ $dims = $file->getDimensionsString();
$s = $list->beginImageHistoryList() .
- $list->imageHistoryLine( true, wfTimestamp(TS_MW, $line->img_timestamp),
- $this->mTitle->getDBkey(), $line->img_user,
- $line->img_user_text, $line->img_size, $line->img_description,
- $line->img_width, $line->img_height
- );
-
- while ( $line = $this->img->nextHistoryLine() ) {
- $s .= $list->imageHistoryLine( false, $line->img_timestamp,
- $line->oi_archive_name, $line->img_user,
- $line->img_user_text, $line->img_size, $line->img_description,
- $line->img_width, $line->img_height
- );
+ $list->imageHistoryLine( true, $file );
+ // old image versions
+ $hist = $this->img->getHistory();
+ foreach( $hist as $file ) {
+ $dims = $file->getDimensionsString();
+ $s .= $list->imageHistoryLine( false, $file );
}
$s .= $list->endImageHistoryList();
} else { $s=''; }
$wgOut->addHTML( "</ul>\n" );
}
- function delete()
- {
- global $wgUser, $wgOut, $wgRequest;
-
- if ( !$this->img->exists() || !$this->img->isLocal() ) {
- # Use standard article deletion
- Article::delete();
- return;
- }
-
- $confirm = $wgRequest->wasPosted();
- $reason = $wgRequest->getVal( 'wpReason' );
- $image = $wgRequest->getVal( 'image' );
- $oldimage = $wgRequest->getVal( 'oldimage' );
-
- # Only sysops can delete images. Previously ordinary users could delete
- # old revisions, but this is no longer the case.
- if ( !$wgUser->isAllowed('delete') ) {
- $wgOut->permissionRequired( 'delete' );
- return;
- }
- if ( $wgUser->isBlocked() ) {
- $wgOut->blockedPage();
- return;
- }
- if ( wfReadOnly() ) {
- $wgOut->readOnlyPage();
- return;
- }
-
- # Better double-check that it hasn't been deleted yet!
- $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
- if ( ( !is_null( $image ) )
- && ( '' == trim( $image ) ) ) {
- $wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
- return;
- }
-
- # Deleting old images doesn't require confirmation
- if ( !is_null( $oldimage ) || $confirm ) {
- if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
- $this->doDeleteImage( $reason );
- } else {
- $wgOut->showFatalError( wfMsg( 'sessionfailure' ) );
- }
- return;
- }
-
- if ( !is_null( $image ) ) {
- $q = '&image=' . urlencode( $image );
- } else if ( !is_null( $oldimage ) ) {
- $q = '&oldimage=' . urlencode( $oldimage );
- } else {
- $q = '';
- }
- return $this->confirmDelete( $q, $wgRequest->getText( 'wpReason' ) );
- }
-
- /*
- * Delete an image.
- * Called doDeleteImage() not doDelete() so that Article::delete() doesn't
- * call back to here.
- *
- * @param $reason User provided reason for deletion.
- */
- function doDeleteImage( $reason ) {
- global $wgOut, $wgRequest;
-
- $oldimage = $wgRequest->getVal( 'oldimage' );
-
- if ( !is_null( $oldimage ) ) {
- if ( strlen( $oldimage ) < 16 ) {
- $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
- return;
- }
- if( strpos( $oldimage, '/' ) !== false || strpos( $oldimage, '\\' ) !== false ) {
- $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
- return;
- }
- $status = $this->doDeleteOldImage( $oldimage );
- $deleted = $oldimage;
- } else {
- $status = $this->img->delete( $reason );
- if ( !$status->isGood() ) {
- // Warning or error
- $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) );
- }
- if ( $status->ok ) {
- # Image itself is now gone, and database is cleaned.
- # Now we remove the image description page.
- $article = new Article( $this->mTitle );
- $article->doDeleteArticle( $reason ); # ignore errors
- $deleted = $this->img->getName();
- }
- }
-
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
-
- if ( !$status->ok ) {
- // Fatal error flagged
- $wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) );
- $wgOut->returnToMain( false, $this->mTitle->getPrefixedText() );
- } else {
- // Operation completed
- $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
- $loglink = '[[Special:Log/delete|' . wfMsg( 'deletionlog' ) . ']]';
- $text = wfMsg( 'deletedtext', $deleted, $loglink );
- $wgOut->addWikiText( $text );
- $wgOut->returnToMain( false, $this->mTitle->getPrefixedText() );
- }
- }
-
/**
- * Delete an old revision of an image,
- * @return FileRepoStatus
+ * Delete the file, or an earlier version of it
*/
- function doDeleteOldImage( $oldimage ) {
- global $wgOut;
-
- $status = $this->img->deleteOld( $oldimage, '' );
- if( !$status->isGood() ) {
- $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) );
- }
- if ( $status->ok ) {
- # Log the deletion
- $log = new LogPage( 'delete' );
- $log->addEntry( 'delete', $this->mTitle, wfMsg('deletedrevision',$oldimage) );
+ public function delete() {
+ if( !$this->img->exists() || !$this->img->isLocal() ) {
+ // Standard article deletion
+ Article::delete();
+ return;
}
- return $status;
+ $deleter = new FileDeleteForm( $this->img );
+ $deleter->execute();
}
/**
* Revert the file to an earlier version
*/
- function revert() {
+ public function revert() {
$reverter = new FileRevertForm( $this->img );
$reverter->execute();
}
-
+
/**
* Override handling of action=purge
*/
*/
class ImageHistoryList {
- protected $img, $skin, $title;
+ protected $img, $skin, $title, $repo;
public function __construct( $skin, $img ) {
$this->skin = $skin;
public function beginImageHistoryList() {
global $wgOut, $wgUser;
+ $deleteColumn = $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deleterevision' );
return Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) )
. $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
. Xml::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"
. '<tr><td></td>'
- . ( $this->img->isLocal() && $wgUser->isAllowed( 'delete' ) ? '<td></td>' : '' )
+ . ( $this->img->isLocal() && $deleteColumn ? '<td></td>' : '' )
. '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
. '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
. '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
- . '<th>' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
+ . '<th class="mw-imagepage-filesize">' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
. '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
. "</tr>\n";
}
return "</table>\n";
}
- public function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $width, $height ) {
- global $wgUser, $wgLang, $wgTitle, $wgContLang;
+ public function imageHistoryLine( $iscur, $file ) {
+ global $wgUser, $wgLang, $wgContLang, $wgTitle;
+
+ $timestamp = wfTimestamp(TS_MW, $file->getTimestamp());
+ $img = $iscur ? $file->getName() : $file->getArchiveName();
+ $user = $file->getUser('id');
+ $usertext = $file->getUser('text');
+ $size = $file->getSize();
+ $description = $file->getDescription();
+ $dims = $file->getDimensionsString();
+ $sha1 = $file->getSha1();
+
$local = $this->img->isLocal();
$row = '';
-
+
// Deletion link
- if( $local && $wgUser->isAllowed( 'delete' ) ) {
+ if( $local && ($wgUser->isAllowed('delete') || $wgUser->isAllowed('deleterevision') ) ) {
$row .= '<td>';
- $q = array();
- $q[] = 'action=delete';
- $q[] = ( $iscur ? 'image=' . $this->title->getPartialUrl() : 'oldimage=' . urlencode( $img ) );
- if( !$iscur )
- $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
- $row .= '(' . $this->skin->makeKnownLinkObj(
- $this->title,
- wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
- implode( '&', $q )
- ) . ')';
+ # Link to remove from history
+ if( $wgUser->isAllowed( 'delete' ) ) {
+ $q = array();
+ $q[] = 'action=delete';
+ if( !$iscur )
+ $q[] = 'oldimage=' . urlencode( $img );
+ $row .= $this->skin->makeKnownLinkObj(
+ $this->title,
+ wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
+ implode( '&', $q )
+ );
+ $row .= '<br/>';
+ }
+ # Link to hide content
+ if( $wgUser->isAllowed( 'deleterevision' ) ) {
+ $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
+ // If file is top revision or locked from this user, don't link
+ if( $iscur || !$file->userCan(File::DELETED_RESTRICTED) ) {
+ $del = wfMsgHtml( 'rev-delundel' );
+ } else {
+ // If the file was hidden, link to sha-1
+ list($ts,$name) = explode('!',$img,2);
+ $del = $this->skin->makeKnownLinkObj( $revdel, wfMsg( 'rev-delundel' ),
+ 'target=' . urlencode( $wgTitle->getPrefixedText() ) .
+ '&oldimage=' . urlencode( $ts ) );
+ // Bolden oversighted content
+ if( $file->isDeleted(File::DELETED_RESTRICTED) )
+ $del = "<strong>$del</strong>";
+ }
+ $row .= "<tt><small>$del</small></tt>";
+ }
$row .= '</td>';
}
-
+
// Reversion link/current indicator
$row .= '<td>';
if( $iscur ) {
- $row .= '(' . wfMsgHtml( 'filehist-current' ) . ')';
+ $row .= wfMsgHtml( 'filehist-current' );
} elseif( $local && $wgUser->isLoggedIn() && $this->title->userCan( 'edit' ) ) {
- $q = array();
- $q[] = 'action=revert';
- $q[] = 'oldimage=' . urlencode( $img );
- $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
- $row .= '(' . $this->skin->makeKnownLinkObj(
- $this->title,
- wfMsgHtml( 'filehist-revert' ),
- implode( '&', $q )
- ) . ')';
+ if( $file->isDeleted(File::DELETED_FILE) ) {
+ $row .= wfMsgHtml('filehist-revert');
+ } else {
+ $q = array();
+ $q[] = 'action=revert';
+ $q[] = 'oldimage=' . urlencode( $img );
+ $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
+ $row .= $this->skin->makeKnownLinkObj( $this->title,
+ wfMsgHtml( 'filehist-revert' ),
+ implode( '&', $q ) );
+ }
}
$row .= '</td>';
-
+
// Date/time and image link
$row .= '<td>';
- $url = $iscur ? $this->img->getUrl() : $this->img->getArchiveUrl( $img );
- $row .= Xml::element(
- 'a',
- array( 'href' => $url ),
- $wgLang->timeAndDate( $timestamp, true )
- );
+ if( !$file->userCan(File::DELETED_FILE) ) {
+ # Don't link to unviewable files
+ $row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
+ } else if( $file->isDeleted(File::DELETED_FILE) ) {
+ $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
+ # Make a link to review the image
+ $url = $this->skin->makeKnownLinkObj( $revdel, $wgLang->timeAndDate( $timestamp, true ),
+ "target=".$wgTitle->getPrefixedText()."&file=$sha1.".$this->img->getExtension() );
+ $row .= '<span class="history-deleted">'.$url.'</span>';
+ } else {
+ $url = $iscur ? $this->img->getUrl() : $this->img->getArchiveUrl( $img );
+ $row .= Xml::element( 'a',
+ array( 'href' => $url ),
+ $wgLang->timeAndDate( $timestamp, true ) );
+ }
+
$row .= '</td>';
-
+
// Uploading user
$row .= '<td>';
if( $local ) {
- $row .= $this->skin->userLink( $user, $usertext ) . $this->skin->userToolLinks( $user, $usertext );
+ // Hide deleted usernames
+ if( $file->isDeleted(File::DELETED_USER) )
+ $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
+ else
+ $row .= $this->skin->userLink( $user, $usertext ) .
+ $this->skin->userToolLinks( $user, $usertext );
} else {
$row .= htmlspecialchars( $usertext );
}
$row .= '</td>';
-
+
// Image dimensions
- // FIXME: It would be nice to show the duration (sound files) or
- // width/height/duration (video files) here, but this needs some
- // additional media handler work
- $row .= '<td>' . wfMsgHtml( 'widthheight', $width, $height ) . '</td>';
-
+ $row .= '<td>' . htmlspecialchars( $dims ) . '</td>';
+
// File size
- $row .= '<td>' . $this->skin->formatSize( $size ) . '</td>';
-
- // Comment
- $row .= '<td>' . $this->skin->formatComment( $description, $this->title ) . '</td>';
-
+ $row .= '<td class="mw-imagepage-filesize">' . $this->skin->formatSize( $size ) . '</td>';
+
+ // Don't show deleted descriptions
+ if ( $file->isDeleted(File::DELETED_COMMENT) )
+ $row .= '<td><span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span></td>';
+ else
+ $row .= '<td>' . $this->skin->commentBlock( $description, $this->title ) . '</td>';
+
return "<tr>{$row}</tr>\n";
}
-
-}
\ No newline at end of file
+}