*
*/
if( !defined( 'MEDIAWIKI' ) )
- die();
+ die( -1 );
require_once( 'Image.php' );
/* private */ var $img; // Image object this page is shown for
var $mExtraDescription = false;
+ /**
+ * Handler for action=render
+ * Include body text only; none of the image extras
+ */
function render() {
global $wgOut;
- $wgOut->setArticleBodyOnly(true);
- $wgOut->addWikitext($this->getContent(true));
+ $wgOut->setArticleBodyOnly( true );
+ $wgOut->addSecondaryWikitext( $this->getContent() );
}
function view() {
- global $wgUseExternalEditor, $wgOut, $wgShowEXIF;
+ global $wgOut, $wgShowEXIF;
$this->img = new Image( $this->mTitle );
$wgOut->setArticleFlag( true );
$wgOut->setRobotpolicy( 'index,follow' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
- $wgOut->addMetaTags();
$this->viewUpdates();
}
- if ($this->mExtraDescription) {
- $fol = wfMsg('shareddescriptionfollows');
- if ($fol != '-')
- $wgOut->addWikiText(wfMsg('shareddescriptionfollows'));
- $wgOut->addHTML($this->mExtraDescription);
+ # Show shared description, if needed
+ if( $this->mExtraDescription ) {
+ $fol = wfMsg( 'shareddescriptionfollows' );
+ if( $fol != '-' ) {
+ $wgOut->addWikiText( $fol );
+ }
+ $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . '</div>' );
}
$this->closeShowImage();
$r .= '|}';
return $r;
}
-
+
/**
* Get a list of EXIF metadata items which should be displayed when
* the metadata table is collapsed.
/**
* Overloading Article's getContent method.
- * Omit noarticletext if sharedupload
- *
- * @param $noredir If true, do not follow redirects
+ *
+ * Omit noarticletext if sharedupload; text will be fetched from the
+ * shared upload server if possible.
*/
- function getContent( $noredir )
- {
- if ( $this->img && $this->img->fromSharedDirectory && 0 == $this->getID() ) {
+ function getContent() {
+ if( $this->img && $this->img->fromSharedDirectory && 0 == $this->getID() ) {
return '';
}
- return Article::getContent( $noredir );
+ return Article::getContent();
}
- function openShowImage()
- {
- global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
- $wgUseImageResize, $wgRepositoryBaseUrl,
- $wgUseExternalEditor, $wgServer, $wgFetchCommonsDescriptions;
+ function openShowImage() {
+ global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgUseImageResize;
+
$full_url = $this->img->getURL();
$anchoropen = '';
$anchorclose = '';
# "Download high res version" link below the image
$msg = wfMsgHtml('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) );
- if ( $width > $maxWidth ) {
- $height = floor( $height * $maxWidth / $width );
- $width = $maxWidth;
- }
- if ( $height > $maxHeight ) {
- $width = floor( $width * $maxHeight / $height );
- $height = $maxHeight;
- }
- if ( $width != $this->img->getWidth() || $height != $this->img->getHeight() ) {
+
+ # We'll show a thumbnail of this image
+ if ( $width > $maxWidth || $height > $maxHeight ) {
+ # Calculate the thumbnail size.
+ # First case, the limiting factor is the width, not the height.
+ if ( $width / $height >= $maxWidth / $maxHeight ) {
+ $height = round( $height * $maxWidth / $width);
+ $width = $maxWidth;
+ # Note that $height <= $maxHeight now.
+ } else {
+ $newwidth = floor( $width * $maxHeight / $height);
+ $height = round( $height * $newwidth / $width );
+ $width = $newwidth;
+ # Note that $height <= $maxHeight now, but might not be identical
+ # because of rounding.
+ }
+
if( $wgUseImageResize ) {
$thumbnail = $this->img->getThumbnail( $width );
if ( $thumbnail == null ) {
$icon->toHtml() .
'</a></div>' );
}
-
+
$showLink = true;
}
$info = wfMsg( 'fileinfo',
ceil($this->img->getSize()/1024.0),
$this->img->getMimeType() );
-
+
if (!$this->img->isSafeFile()) {
$warning = wfMsg( 'mediawarning' );
$wgOut->addWikiText( <<<END
$sk = $wgUser->getSkin();
$wgOut->addHTML( '<br /><ul>' );
- if( $wgUser->isAllowed( 'reupload' ) ) {
+ if( $wgUser->isAllowed( 'reupload' ) ) {
$wgOut->addWikiText( "<li>\n<div>". wfMsg( 'uploadnewversion', $this->getUploadUrl() ) ."</div>\n</li>\n" );
}
$wgOut->addHTML( '<li>' );
return $this->confirmDelete( $q, $wgRequest->getText( 'wpReason' ) );
}
- function doDelete()
- {
- global $wgOut, $wgUser, $wgContLang, $wgRequest;
- global $wgUseSquid, $wgInternalServer, $wgPostCommitUpdateList;
+ function doDelete() {
+ global $wgOut, $wgUser, $wgRequest, $wgUseSquid, $wgInternalServer;
+ global $wgPostCommitUpdateList;
+
$fname = 'ImagePage::doDelete';
$reason = $wgRequest->getVal( 'wpReason' );
# Squid purging
if ( $wgUseSquid ) {
- $urlArr = Array(
+ $urlArr = array(
$wgInternalServer.wfImageArchiveUrl( $oldimage ),
- $wgInternalServer.$this->mTitle->getFullURL()
+ $this->mTitle->getInternalURL()
);
wfPurgeSquidServers($urlArr);
}
}
}
- function revert()
- {
+ function revert() {
global $wgOut, $wgRequest, $wgUser;
- global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList;
$oldimage = $wgRequest->getText( 'oldimage' );
if ( strlen( $oldimage ) < 16 ) {
}
function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $width, $height ) {
- global $wgUser, $wgLang, $wgContLang, $wgTitle;
+ global $wgUser, $wgLang, $wgTitle, $wgContLang;
$datetime = $wgLang->timeanddate( $timestamp, true );
$del = wfMsg( 'deleteimg' );
if ( 0 == $user ) {
$userlink = $usertext;
} else {
- $userlink = $this->skin->makeLinkObj(
- Title::makeTitle( NS_USER, $usertext ),
- $usertext );
+ $userlink = $this->skin->makeLinkObj( Title::makeTitle( NS_USER, $usertext ), $usertext );
+ $usertalk = $this->skin->makeLinkObj( Title::makeTitle( NS_USER_TALK, $usertext), $wgContLang->getNsText( NS_TALK ) );
+ $userdata = $userlink . ' (' . $usertalk . ')';
}
$nbytes = wfMsg( 'nbytes', $size );
$widthheight = wfMsg( 'widthheight', $width, $height );
$style = $this->skin->getInternalLinkAttributes( $url, $datetime );
- $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a> . . {$userlink} . . {$widthheight} ({$nbytes})";
+ $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a> . . {$userdata} . . {$widthheight} ({$nbytes})";
$s .= $this->skin->commentBlock( $description, $wgTitle );
$s .= "</li>\n";