X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImagePage.php;h=7bdfe8c71847a850b9b7c48c3aeec13a5c797c14;hb=1ef6cb2f89dd3870c68722921a799c8a051445a3;hp=d29a431180773dfe1079f5da84f85dc605d9473d;hpb=f696971eba84feadab524eb6e563cfa3d064b951;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/ImagePage.php b/includes/ImagePage.php
index d29a431180..7bdfe8c718 100644
--- a/includes/ImagePage.php
+++ b/includes/ImagePage.php
@@ -6,6 +6,9 @@
/**
*
*/
+if( !defined( 'MEDIAWIKI' ) )
+ die();
+
require_once( 'Image.php' );
/**
@@ -40,14 +43,21 @@ class ImagePage extends Article {
global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
$wgUseImageResize, $wgRepositoryBaseUrl;
$this->img = Image::newFromTitle( $this->mTitle );
- $url = $this->img->getViewURL();
+ $full_url = $this->img->getViewURL();
$anchoropen = '';
$anchorclose = '';
- if ( $wgUseImageResize && $wgUser->getOption( 'imagesize' ) != '' ) {
- $max = $wgImageLimits[ intval( $wgUser->getOption( 'imagesize' ) ) ];
- $maxWidth = $max[0];
- $maxHeight = $max[1];
+
+ if( $wgUser->getOption( 'imagesize' ) == '' ) {
+ $sizeSel = User::getDefaultOption( 'imagesize' );
+ } else {
+ $sizeSel = IntVal( $wgUser->getOption( 'imagesize' ) );
}
+ if( !isset( $wgImageLimits[$sizeSel] ) ) {
+ $sizeSel = User::getDefaultOption( 'imagesize' );
+ }
+ $max = $wgImageLimits[$sizeSel];
+ $maxWidth = $max[0];
+ $maxHeight = $max[1];
if ( $this->img->exists() ) {
@@ -59,27 +69,43 @@ class ImagePage extends Article {
$width = $this->img->getWidth();
$height = $this->img->getHeight();
$msg = wfMsg('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) );
- if ( $width > $maxWidth && $wgUseImageResize ) {
- $anchoropen = "";
- $anchorclose = "
{$msg}";
-
- $url = $this->img->createThumb( $maxWidth );
+ if ( $width > $maxWidth ) {
$height = floor( $height * $maxWidth / $width );
$width = $maxWidth;
}
- if ( $height > $maxHeight && $wgUseImageResize ) {
- $anchoropen = "";
- $anchorclose = "
{$msg}";
-
+ if ( $height > $maxHeight ) {
$width = floor( $width * $maxHeight / $height );
$height = $maxHeight;
- $url = $this->img->createThumb( $width );
}
- $s = "
" . $anchoropen .
+ if ( $width != $this->img->getWidth() || $height != $this->img->getHeight() ) {
+ if( $wgUseImageResize ) {
+ $thumbnail = $this->img->getThumbnail( $width );
+
+ if ( ( ! $this->img->mustRender() )
+ && ( $thumbnail->getSize() > $this->img->getSize() ) ) {
+ # the thumbnail is bigger thatn the original image.
+ # show the original image instead of the thumb.
+ $url = $full_url;
+ $width = $this->img->getWidth();
+ $height = $this->img->getHeight();
+ } else {
+ $url = $thumbnail->getUrl();
+ }
+ } else {
+ # No resize ability? Show the full image, but scale
+ # it down in the browser so it fits on the page.
+ $url = $full_url;
+ }
+ $anchoropen = "
";
+ $anchorclose = "
{$msg}";
+ } else {
+ $url = $full_url;
+ }
+ $s = '
' . $anchoropen .
"
![\""](\"{$url}\")
getVal( 'image' ) )."\" />" . $anchorclose . "
";
+ htmlspecialchars( $wgRequest->getVal( 'image' ) ).'" />' . $anchorclose . '
';
} else {
- $s = "".$sk->makeMediaLink($this->img->getName(),"")."
";
+ $s = "" . $sk->makeMediaLink( $this->img->getName(),'' ) . '
';
}
$wgOut->addHTML( $s );
if($this->img->fromSharedDirectory) {
@@ -134,11 +160,11 @@ class ImagePage extends Article {
$wgOut->addHTML( '' . wfMsg( 'imagelinks' ) . "
\n" );
$dbr =& wfGetDB( DB_SLAVE );
- $cur = $dbr->tableName( 'cur' );
+ $page = $dbr->tableName( 'page' );
$imagelinks = $dbr->tableName( 'imagelinks' );
- $sql = "SELECT cur_namespace,cur_title FROM $imagelinks,$cur WHERE il_to=" .
- $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=cur_id"
+ $sql = "SELECT page_namespace,page_title FROM $imagelinks,$page WHERE il_to=" .
+ $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=page_id"
. " LIMIT 500"; # quickie emergency brake
$res = $dbr->query( $sql, DB_SLAVE, "Article::imageLinks" );
@@ -150,7 +176,7 @@ class ImagePage extends Article {
$sk = $wgUser->getSkin();
while ( $s = $dbr->fetchObject( $res ) ) {
- $name = Title::MakeTitle( $s->cur_namespace, $s->cur_title );
+ $name = Title::MakeTitle( $s->page_namespace, $s->page_title );
$link = $sk->makeKnownLinkObj( $name, "" );
$wgOut->addHTML( "{$link}\n" );
}
@@ -178,11 +204,10 @@ class ImagePage extends Article {
# Better double-check that it hasn't been deleted yet!
$wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
- if ( !is_null( $image ) ) {
- if ( '' == trim( $image ) ) {
- $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
- return;
- }
+ if ( ( !is_null( $image ) )
+ && ( '' == trim( $image ) ) ) {
+ $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
+ return;
}
# Deleting old images doesn't require confirmation