<?php
-
-/*
- Special handling for image description pages
-*/
-
-require_once( "Image.php" );
-
+/**
+ * @package MediaWiki
+ */
+
+/**
+ *
+ */
+require_once( 'Image.php' );
+
+/**
+ * Special handling for image description pages
+ * @package MediaWiki
+ */
class ImagePage extends Article {
/* private */ var $img; // Image object this page is shown for. Initilaized in openShowImage, not
function openShowImage()
{
- global $wgOut, $wgUser, $wgRequest, $wgMaxImageWidth, $wgUseImageResize;
+ global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgUseImageResize;
$this->img = Image::newFromTitle( $this->mTitle );
$url = $this->img->getUrl();
- $anchoropen = "";
- $anchorclose = "";
+ $anchoropen = '';
+ $anchorclose = '';
+ if ( $wgUseImageResize && $wgUser->getOption( 'imagesize' ) != '' ) {
+ $max = $wgImageLimits[ intval( $wgUser->getOption( 'imagesize' ) ) ];
+ $maxWidth = $max[0];
+ $maxHeight = $max[1];
+ }
if ( $this->img->exists() ) {
$sk = $wgUser->getSkin();
- if ( $this->img->getType() != "" ) {
+ if ( $this->img->getType() != '' ) {
# image
$width = $this->img->getWidth();
$height = $this->img->getHeight();
- if ( $width > $wgMaxImageWidth && $wgUseImageResize ) {
+ $msg = wfMsg('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) );
+ if ( $width > $maxWidth && $wgUseImageResize ) {
$anchoropen = "<a href=\"{$url}\">";
- $anchorclose = '</a>';
- $url=$this->img->createThumb( $wgMaxImageWidth );
- $height = floor( $height * $wgMaxImageWidth / $width );
- $width = $wgMaxImageWidth;
+ $anchorclose = "<br>{$msg}</a>";
+
+ $url = $this->img->createThumb( $maxWidth );
+ $height = floor( $height * $maxWidth / $width );
+ $width = $maxWidth;
+ }
+ if ( $height > $maxHeight && $wgUseImageResize ) {
+ $anchoropen = "<a href=\"{$url}\">";
+ $anchorclose = "<br>{$msg}</a>";
+
+ $width = floor( $width * $maxHeight / $height );
+ $height = $maxHeight;
+ $url = $this->img->createThumb( $width );
}
- $s = "<div class=\"fullImage\">" . $anchoropen .
+ $s = "<div class=\"fullImageLink\">" . $anchoropen .
"<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" alt=\"" .
$wgRequest->getVal( 'image' )."\" />" . $anchorclose . "</div>";
} else {
# For overloading
}
- # If the page we've just displayed is in the "Image" namespace,
- # we follow it with an upload history of the image and its usage.
-
+ /**
+ * If the page we've just displayed is in the "Image" namespace,
+ * we follow it with an upload history of the image and its usage.
+ */
function imageHistory()
{
global $wgUser, $wgOut;
$line->img_user_text, $line->img_size, $line->img_description );
}
$s .= $sk->endImageHistoryList();
- } else { $s=""; }
+ } else { $s=''; }
$wgOut->addHTML( $s );
}
{
global $wgUser, $wgOut;
- $wgOut->addHTML( "<h2>" . wfMsg( "imagelinks" ) . "</h2>\n" );
+ $wgOut->addHTML( '<h2>' . wfMsg( 'imagelinks' ) . "</h2>\n" );
$dbr =& wfGetDB( DB_SLAVE );
$cur = $dbr->tableName( 'cur' );
$res = $dbr->query( $sql, DB_SLAVE, "Article::imageLinks" );
if ( 0 == $dbr->numRows( $res ) ) {
- $wgOut->addHtml( "<p>" . wfMsg( "nolinkstoimage" ) . "</p>\n" );
+ $wgOut->addHtml( '<p>' . wfMsg( "nolinkstoimage" ) . "</p>\n" );
return;
}
- $wgOut->addHTML( "<p>" . wfMsg( "linkstoimage" ) . "</p>\n<ul>" );
+ $wgOut->addHTML( '<p>' . wfMsg( 'linkstoimage' ) . "</p>\n<ul>" );
$sk = $wgUser->getSkin();
while ( $s = $dbr->fetchObject( $res ) ) {
}
# Better double-check that it hasn't been deleted yet!
- $wgOut->setPagetitle( wfMsg( "confirmdelete" ) );
+ $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
if ( !is_null( $image ) ) {
- if ( "" == trim( $image ) ) {
- $wgOut->fatalError( wfMsg( "cannotdelete" ) );
+ if ( '' == trim( $image ) ) {
+ $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
return;
}
}
}
if ( !is_null( $image ) ) {
- $q = "&image=" . urlencode( $image );
+ $q = '&image=' . urlencode( $image );
} else if ( !is_null( $oldimage ) ) {
- $q = "&oldimage=" . urlencode( $oldimage );
+ $q = '&oldimage=' . urlencode( $oldimage );
} else {
- $q = "";
+ $q = '';
}
return $this->confirmDelete( $q, $wgRequest->getText( 'wpReason' ) );
}
{
global $wgOut, $wgUser, $wgLang, $wgRequest;
global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList;
- $fname = "Article::doDelete";
+ $fname = 'ImagePage::doDelete';
$reason = $wgRequest->getVal( 'wpReason' );
$image = $wgRequest->getVal( 'image' );
$dbw =& wfGetDB( DB_MASTER );
- if ( !is_null( $image ) ) {
+ if ( !is_null( $oldimage ) ) {
+ # Squid purging
+ if ( $wgUseSquid ) {
+ $urlArr = Array(
+ $wgInternalServer.wfImageArchiveUrl( $oldimage )
+ );
+ wfPurgeSquidServers($urlArr);
+ }
+ $this->doDeleteOldImage( $oldimage );
+ $dbw->delete( 'oldimage', array( 'oi_archive_name' => $oldimage ) );
+ $deleted = $oldimage;
+ } else {
+ if ( is_null ( $image ) ) {
+ $image = $this->mTitle->getDBkey();
+ }
$dest = wfImageDir( $image );
$archive = wfImageDir( $image );
if ( ! @unlink( "{$dest}/{$image}" ) ) {
$urlArr = Array();
- while ( $s = $dbr->fetchObject( $res ) ) {
+ while ( $s = $dbw->fetchObject( $res ) ) {
$this->doDeleteOldImage( $s->oi_archive_name );
$urlArr[] = $wgInternalServer.wfImageArchiveUrl( $s->oi_archive_name );
}
$article->doDeleteArticle( $reason ); # ignore errors
$deleted = $image;
- } else if ( !is_null( $oldimage ) ) {
- # Squid purging
- if ( $wgUseSquid ) {
- $urlArr = Array(
- $wgInternalServer.wfImageArchiveUrl( $oldimage )
- );
- wfPurgeSquidServers($urlArr);
- }
- $this->doDeleteOldImage( $oldimage );
- $dbw->delete( 'oldimage', array( 'oi_archive_name' => $oldimage ) );
- $deleted = $oldimage;
- } else {
- $this->doDeleteArticle( $reason ); # ignore errors
- $deleted = $this->mTitle->getPrefixedText();
}
- $wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
+
+ $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
$sk = $wgUser->getSkin();
$loglink = $sk->makeKnownLink( $wgLang->getNsText(
Namespace::getWikipedia() ) .
- ":" . wfMsg( "dellogpage" ), wfMsg( "deletionlog" ) );
+ ':' . wfMsg( 'dellogpage' ), wfMsg( 'deletionlog' ) );
- $text = wfMsg( "deletedtext", $deleted, $loglink );
+ $text = wfMsg( 'deletedtext', $deleted, $loglink );
- $wgOut->addHTML( "<p>" . $text . "</p>\n" );
+ $wgOut->addHTML( '<p>' . $text . "</p>\n" );
$wgOut->returnToMain( false );
}
$name = substr( $oldimage, 15 );
$archive = wfImageArchiveDir( $name );
- if ( ! unlink( "{$archive}/{$oldimage}" ) ) {
+ if ( ! @unlink( "{$archive}/{$oldimage}" ) ) {
$wgOut->fileDeleteError( "{$archive}/{$oldimage}" );
+ } else {
+ # Log the deletion
+ $log = new LogPage( 'delete' );
+ $log->addEntry( 'delete', $this->mTitle, wfMsg('deletedrevision',$oldimage) );
}
}
$oldimage = $wgRequest->getText( 'oldimage' );
if ( strlen( $oldimage ) < 16 ) {
- $wgOut->unexpectedValueError( "oldimage", $oldimage );
+ $wgOut->unexpectedValueError( 'oldimage', $oldimage );
return;
}
if ( wfReadOnly() ) {
$oldver = wfTimestampNow() . "!{$name}";
$dbr =& wfGetDB( DB_SLAVE );
- $size = $dbr->getField( "oldimage", "oi_size", "oi_archive_name='" .
+ $size = $dbr->getField( 'oldimage', 'oi_size', 'oi_archive_name=\'' .
$dbr->strencode( $oldimage ) . "'" );
if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) {
wfPurgeSquidServers($urlArr);
}
- $wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
- $wgOut->addHTML( wfMsg( "imagereverted" ) );
+ $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->addHTML( wfMsg( 'imagereverted' ) );
$wgOut->returnToMain( false );
}
}