From 370e83bb0dfd0c70de268c93bf07ad5ee0897192 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 15 Aug 2008 01:29:47 +0200 Subject: Update auf 1.13.0 --- includes/media/BMP.php | 8 +++++-- includes/media/Bitmap.php | 22 +++++++++--------- includes/media/DjVu.php | 20 +++++++++-------- includes/media/Generic.php | 56 +++++++++++++++++++++++++++------------------- includes/media/SVG.php | 18 +++++++++------ 5 files changed, 73 insertions(+), 51 deletions(-) (limited to 'includes/media') diff --git a/includes/media/BMP.php b/includes/media/BMP.php index 2f451b0a..ce1b0362 100644 --- a/includes/media/BMP.php +++ b/includes/media/BMP.php @@ -1,10 +1,14 @@ = $srcWidth ) { $params['physicalWidth'] = $srcWidth; $params['physicalHeight'] = $srcHeight; @@ -35,7 +39,7 @@ class BitmapHandler extends ImageHandler { return true; } - + function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { global $wgUseImageMagick, $wgImageMagickConvertCommand; global $wgCustomConvertCommand; @@ -85,8 +89,8 @@ class BitmapHandler extends ImageHandler { } if ( !wfMkdirParents( dirname( $dstPath ) ) ) { - return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, - wfMsg( 'thumbnail_dest_directory' ) ); + wfDebug( "Unable to create thumbnail destination directory, falling back to client scaling\n" ); + return new ThumbnailImage( $image, $image->getURL(), $clientWidth, $clientHeight, $srcPath ); } if ( $scaler == 'im' ) { @@ -167,12 +171,12 @@ class BitmapHandler extends ImageHandler { $src_image = call_user_func( $loader, $srcPath ); $dst_image = imagecreatetruecolor( $physicalWidth, $physicalHeight ); - + // Initialise the destination image to transparent instead of // the default solid black, to support PNG and GIF transparency nicely $background = imagecolorallocate( $dst_image, 0, 0, 0 ); imagecolortransparent( $dst_image, $background ); - imagealphablending( $dst_image, false ); + imagealphablending( $dst_image, false ); if( $colorStyle == 'palette' ) { // Don't resample for paletted GIF images. @@ -187,7 +191,7 @@ class BitmapHandler extends ImageHandler { } imagesavealpha( $dst_image, true ); - + call_user_func( $saveType, $dst_image, $dstPath ); imagedestroy( $dst_image ); imagedestroy( $src_image ); @@ -303,5 +307,3 @@ class BitmapHandler extends ImageHandler { return $result; } } - - diff --git a/includes/media/DjVu.php b/includes/media/DjVu.php index 20e59d18..f0bbcc51 100644 --- a/includes/media/DjVu.php +++ b/includes/media/DjVu.php @@ -1,7 +1,11 @@ getMetadata(); if ( !$xml ) { - return new MediaTransformError( 'thumbnail_error', @$params['width'], @$params['height'], + return new MediaTransformError( 'thumbnail_error', @$params['width'], @$params['height'], wfMsg( 'djvu_no_xml' ) ); } - + if ( !$this->normaliseParams( $image, $params ) ) { return new TransformParameterError( $params ); } @@ -81,7 +85,7 @@ class DjVuHandler extends ImageHandler { if ( $page > $this->pageCount( $image ) ) { return new MediaTransformError( 'thumbnail_error', $width, $height, wfMsg( 'djvu_page_error' ) ); } - + if ( $flags & self::TRANSFORM_LATER ) { return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page ); } @@ -90,7 +94,7 @@ class DjVuHandler extends ImageHandler { return new MediaTransformError( 'thumbnail_error', $width, $height, wfMsg( 'thumbnail_dest_directory' ) ); } - # Use a subshell (brackets) to aggregate stderr from both pipeline commands + # Use a subshell (brackets) to aggregate stderr from both pipeline commands # before redirecting it to the overall stdout. This works in both Linux and Windows XP. $cmd = '(' . wfEscapeShellArg( $wgDjvuRenderer ) . " -format=ppm -page={$page} -size={$width}x{$height} " . wfEscapeShellArg( $srcPath ); @@ -208,5 +212,3 @@ class DjVuHandler extends ImageHandler { } } } - - diff --git a/includes/media/Generic.php b/includes/media/Generic.php index 19914929..b2cb70f6 100644 --- a/includes/media/Generic.php +++ b/includes/media/Generic.php @@ -1,13 +1,14 @@ getSkin(); - return wfMsg( 'file-info', $sk->formatSize( $file->getSize() ), $file->getMimeType() ); + return wfMsgExt( 'file-info', 'parseinline', + $sk->formatSize( $file->getSize() ), + $file->getMimeType() ); } function getDimensionsString( $file ) { @@ -272,7 +275,7 @@ abstract class MediaHandler { /** * Media handler abstract base class for images * - * @addtogroup Media + * @ingroup Media */ abstract class ImageHandler extends MediaHandler { function canRender( $file ) { @@ -354,13 +357,13 @@ abstract class ImageHandler extends MediaHandler { function getTransform( $image, $dstPath, $dstUrl, $params ) { return $this->doTransform( $image, $dstPath, $dstUrl, $params, self::TRANSFORM_LATER ); } - + /** * Validate thumbnail parameters and fill in the correct height * * @param integer &$width Specified width (input/output) * @param integer &$height Height (output only) - * @return false to indicate that an error should be returned to the user. + * @return false to indicate that an error should be returned to the user. */ function validateThumbParams( &$width, &$height, $srcWidth, $srcHeight, $mimeType ) { $width = intval( $width ); @@ -385,7 +388,7 @@ abstract class ImageHandler extends MediaHandler { } $url = $script . '&' . wfArrayToCGI( $this->getScriptParams( $params ) ); $page = isset( $params['page'] ) ? $params['page'] : false; - + if( $image->mustRender() || $params['width'] < $image->getWidth() ) { return new ThumbnailImage( $image, $url, $params['width'], $params['height'], $page ); } @@ -400,8 +403,8 @@ abstract class ImageHandler extends MediaHandler { function getShortDesc( $file ) { global $wgLang; - $nbytes = '(' . wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), - $wgLang->formatNum( $file->getSize() ) ) . ')'; + $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), + $wgLang->formatNum( $file->getSize() ) ); $widthheight = wfMsgHtml( 'widthheight', $wgLang->formatNum( $file->getWidth() ) ,$wgLang->formatNum( $file->getHeight() ) ); return "$widthheight ($nbytes)"; @@ -409,17 +412,24 @@ abstract class ImageHandler extends MediaHandler { function getLongDesc( $file ) { global $wgLang; - return wfMsgHtml('file-info-size', $wgLang->formatNum( $file->getWidth() ), $wgLang->formatNum( $file->getHeight() ), - $wgLang->formatSize( $file->getSize() ), $file->getMimeType() ); + return wfMsgExt('file-info-size', 'parseinline', + $wgLang->formatNum( $file->getWidth() ), + $wgLang->formatNum( $file->getHeight() ), + $wgLang->formatSize( $file->getSize() ), + $file->getMimeType() ); } function getDimensionsString( $file ) { global $wgLang; $pages = $file->pageCount(); + $width = $wgLang->formatNum( $file->getWidth() ); + $height = $wgLang->formatNum( $file->getHeight() ); + $pagesFmt = $wgLang->formatNum( $pages ); + if ( $pages > 1 ) { - return wfMsg( 'widthheightpage', $wgLang->formatNum( $file->getWidth() ), $wgLang->formatNum( $file->getHeight() ), $wgLang->formatNum( $pages ) ); + return wfMsgExt( 'widthheightpage', 'parsemag', $width, $height, $pagesFmt ); } else { - return wfMsg( 'widthheight', $wgLang->formatNum( $file->getWidth() ), $wgLang->formatNum( $file->getHeight() ) ); + return wfMsg( 'widthheight', $width, $height ); } } } diff --git a/includes/media/SVG.php b/includes/media/SVG.php index 75d0ad3d..2604e3b4 100644 --- a/includes/media/SVG.php +++ b/includes/media/SVG.php @@ -1,7 +1,11 @@ normaliseParams( $image, $params ) ) { return new TransformParameterError( $params ); } @@ -53,7 +57,7 @@ class SvgHandler extends ImageHandler { } if ( !wfMkdirParents( dirname( $dstPath ) ) ) { - return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, + return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, wfMsg( 'thumbnail_dest_directory' ) ); } @@ -94,9 +98,9 @@ class SvgHandler extends ImageHandler { function getLongDesc( $file ) { global $wgLang; - return wfMsg( 'svg-long-desc', $file->getWidth(), $file->getHeight(), + return wfMsgExt( 'svg-long-desc', 'parseinline', + $wgLang->formatNum( $file->getWidth() ), + $wgLang->formatNum( $file->getHeight() ), $wgLang->formatSize( $file->getSize() ) ); } } - - -- cgit v1.2.2