diff options
author | nobody <nobody@localhost> | 2006-01-05 23:36:45 +0000 |
---|---|---|
committer | nobody <nobody@localhost> | 2006-01-05 23:36:45 +0000 |
commit | 4ce70280face928c604c4300fd2ba6fdc78243da (patch) | |
tree | 3b2f616b592484fcd8bf9b70ea4a062cd5ac64fc /includes/Image.php | |
parent | 9018faf3a776fffd61bbb9a7516da6ae8bf55f55 (diff) | |
parent | b2a8013a4893454f32dc13bd253e141d7fef2f35 (diff) | |
download | mediawikicore-1.5.5.tar.gz mediawikicore-1.5.5.zip |
This commit was manufactured by cvs2svn to create tag 'REL1_5_5'.1.5.5
Diffstat (limited to 'includes/Image.php')
-rw-r--r-- | includes/Image.php | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/includes/Image.php b/includes/Image.php index 3e7362132438..15e45937ef25 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -582,7 +582,7 @@ class Image if (!$mime || $mime==='unknown' || $mime==='unknown/unknown') return false; - #if it's SVG, check if ther's a converter enabled + #if it's SVG, check if there's a converter enabled if ($mime === 'image/svg') { global $wgSVGConverters, $wgSVGConverter; @@ -854,7 +854,7 @@ class Image * @return ThumbnailImage * @access public */ - function &getThumbnail( $width, $height=-1 ) { + function getThumbnail( $width, $height=-1 ) { if ( $height == -1 ) { return $this->renderThumb( $width ); } @@ -915,6 +915,9 @@ class Image function renderThumb( $width, $useScript = true ) { global $wgUseSquid, $wgInternalServer; global $wgThumbnailScriptPath, $wgSharedThumbnailScriptPath; + + $fname = 'Image::renderThumb'; + wfProfileIn( $fname ); $width = IntVal( $width ); @@ -922,18 +925,26 @@ class Image if ( ! $this->exists() ) { # If there is no image, there will be no thumbnail + wfProfileOut( $fname ); return null; } # Sanity check $width if( $width <= 0 || $this->width <= 0) { # BZZZT + wfProfileOut( $fname ); return null; } - if( $width >= $this->width && !$this->mustRender() ) { + global $wgSVGMaxSize; + $maxsize = $this->mustRender() + ? max( $this->width, $wgSVGMaxSize ) + : $this->width - 1; + if( $width > $maxsize ) { # Don't make an image bigger than the source - return new ThumbnailImage( $this->getViewURL(), $this->getWidth(), $this->getHeight() ); + $thumb = new ThumbnailImage( $this->getViewURL(), $this->getWidth(), $this->getHeight() ); + wfProfileOut( $fname ); + return $thumb; } $height = floor( $this->height * ( $width/$this->width ) ); @@ -941,7 +952,9 @@ class Image list( $isScriptUrl, $url ) = $this->thumbUrl( $width ); if ( $isScriptUrl && $useScript ) { // Use thumb.php to render the image - return new ThumbnailImage( $url, $width, $height ); + $thumb = new ThumbnailImage( $url, $width, $height ); + wfProfileOut( $fname ); + return $thumb; } $thumbName = $this->thumbName( $width, $this->fromSharedDirectory ); @@ -976,7 +989,9 @@ class Image } } - return new ThumbnailImage( $url, $width, $height, $thumbPath ); + $thumb = new ThumbnailImage( $url, $width, $height, $thumbPath ); + wfProfileOut( $fname ); + return $thumb; } // END OF function renderThumb /** @@ -998,12 +1013,14 @@ class Image if( isset( $wgSVGConverters[$wgSVGConverter] ) ) { global $wgSVGConverterPath; $cmd = str_replace( - array( '$path/', '$width', '$input', '$output' ), - array( $wgSVGConverterPath, - $width, + array( '$path/', '$width', '$height', '$input', '$output' ), + array( $wgSVGConverterPath ? "$wgSVGConverterPath/" : "", + intval( $width ), + intval( $height ), wfEscapeShellArg( $this->imagePath ), wfEscapeShellArg( $thumbPath ) ), $wgSVGConverters[$wgSVGConverter] ); + wfDebug( "reallyRenderThumb SVG: $cmd\n" ); $conv = shell_exec( $cmd ); } else { $conv = false; @@ -1016,7 +1033,7 @@ class Image " -quality 85 -background white -geometry {$width} ". wfEscapeShellArg($this->imagePath) . " " . wfEscapeShellArg($thumbPath); - wfDebug("reallyRenderThumb: running ImageMagick: $cmd"); + wfDebug("reallyRenderThumb: running ImageMagick: $cmd\n"); $conv = shell_exec( $cmd ); } else { # Use PHP's builtin GD library functions. @@ -1244,7 +1261,7 @@ class Image /** * Record an image upload in the upload log and the image table */ - function recordUpload( $oldver, $desc, $copyStatus = '', $source = '' ) { + function recordUpload( $oldver, $desc, $copyStatus = '', $source = '', $watch = false ) { global $wgUser, $wgLang, $wgTitle, $wgDeferredUpdateList; global $wgUseCopyrightUpload, $wgUseSquid, $wgPostCommitUpdateList; @@ -1304,15 +1321,7 @@ class Image $descTitle = $this->getTitle(); $purgeURLs = array(); - if ( $dbw->affectedRows() ) { - # Successfully inserted, this is a new image - $id = $descTitle->getArticleID(); - - if ( $id == 0 ) { - $article = new Article( $descTitle ); - $article->insertNewArticle( $textdesc, $desc, false, false, true ); - } - } else { + if( $dbw->affectedRows() == 0 ) { # Collision, this is an update of an image # Insert previous contents into oldimage $dbw->insertSelect( 'oldimage', 'image', @@ -1349,12 +1358,27 @@ class Image 'img_name' => $this->name ), $fname ); + } + + $article = new Article( $descTitle ); + $minor = false; + $watch = $watch || $wgUser->isWatched( $descTitle ); + $suppressRC = true; // There's already a log entry, so don't double the RC load + + if( $descTitle->exists() ) { + // TODO: insert a null revision into the page history for this update. + if( $watch ) { + $wgUser->addWatch( $descTitle ); + } # Invalidate the cache for the description page $descTitle->invalidateCache(); $purgeURLs[] = $descTitle->getInternalURL(); + } else { + // New image; create the description page. + $article->insertNewArticle( $textdesc, $desc, $minor, $watch, $suppressRC ); } - + # Invalidate cache for all pages using this image $linksTo = $this->getLinksTo(); |