summaryrefslogtreecommitdiff
path: root/includes/media
diff options
context:
space:
mode:
Diffstat (limited to 'includes/media')
-rw-r--r--includes/media/BMP.php8
-rw-r--r--includes/media/Bitmap.php22
-rw-r--r--includes/media/DjVu.php20
-rw-r--r--includes/media/Generic.php56
-rw-r--r--includes/media/SVG.php18
5 files changed, 73 insertions, 51 deletions
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 @@
<?php
+/**
+ * @file
+ * @ingroup Media
+ */
/**
* Handler for Microsoft's bitmap format; getimagesize() doesn't
* support these files
*
- * @addtogroup Media
+ * @ingroup Media
*/
class BmpHandler extends BitmapHandler {
@@ -26,4 +30,4 @@ class BmpHandler extends BitmapHandler {
$h = unpack( 'V' , $h );
return array( $w[1], $h[1] );
}
-} \ No newline at end of file
+}
diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php
index ca82aab0..e01386e9 100644
--- a/includes/media/Bitmap.php
+++ b/includes/media/Bitmap.php
@@ -1,7 +1,11 @@
<?php
+/**
+ * @file
+ * @ingroup Media
+ */
/**
- * @addtogroup Media
+ * @ingroup Media
*/
class BitmapHandler extends ImageHandler {
function normaliseParams( $image, &$params ) {
@@ -26,7 +30,7 @@ class BitmapHandler extends ImageHandler {
# Don't make an image bigger than the source
$params['physicalWidth'] = $params['width'];
$params['physicalHeight'] = $params['height'];
-
+
if ( $params['physicalWidth'] >= $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 @@
<?php
-
/**
- * @addtogroup Media
+ * @file
+ * @ingroup Media
+ */
+
+/**
+ * @ingroup Media
*/
class DjVuHandler extends ImageHandler {
function isEnabled() {
@@ -63,14 +67,14 @@ class DjVuHandler extends ImageHandler {
function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
global $wgDjvuRenderer, $wgDjvuPostProcessor;
- // Fetch XML and check it, to give a more informative error message than the one which
+ // Fetch XML and check it, to give a more informative error message than the one which
// normaliseParams will inevitably give.
$xml = $image->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 @@
<?php
-
/**
* Media-handling base classes and generic functionality
+ * @file
+ * @ingroup Media
*/
/**
* Base media handler class
*
- * @addtogroup Media
+ * @ingroup Media
*/
abstract class MediaHandler {
const TRANSFORM_LATER = 1;
@@ -43,7 +44,7 @@ abstract class MediaHandler {
abstract function getParamMap();
/*
- * Validate a thumbnail parameter at parse time.
+ * Validate a thumbnail parameter at parse time.
* Return true to accept the parameter, and false to reject it.
* If you return false, the parser will do something quiet and forgiving.
*/
@@ -60,14 +61,14 @@ abstract class MediaHandler {
abstract function parseParamString( $str );
/**
- * Changes the parameter array as necessary, ready for transformation.
+ * Changes the parameter array as necessary, ready for transformation.
* Should be idempotent.
* Returns false if the parameters are unacceptable and the transform should fail
*/
abstract function normaliseParams( $image, &$params );
/**
- * Get an image size array like that returned by getimagesize(), or false if it
+ * Get an image size array like that returned by getimagesize(), or false if it
* can't be determined.
*
* @param Image $image The image object, or false if there isn't one
@@ -110,7 +111,7 @@ abstract class MediaHandler {
}
/**
- * Get a MediaTransformOutput object representing the transformed output. Does not
+ * Get a MediaTransformOutput object representing the transformed output. Does not
* actually do the transform.
*
* @param Image $image The image object
@@ -123,7 +124,7 @@ abstract class MediaHandler {
}
/**
- * Get a MediaTransformOutput object representing the transformed output. Does the
+ * Get a MediaTransformOutput object representing the transformed output. Does the
* transform unless $flags contains self::TRANSFORM_LATER.
*
* @param Image $image The image object
@@ -140,14 +141,14 @@ abstract class MediaHandler {
*/
function getThumbType( $ext, $mime ) {
return array( $ext, $mime );
- }
+ }
/**
* True if the handled types can be transformed
*/
function canRender( $file ) { return true; }
/**
- * True if handled types cannot be displayed directly in a browser
+ * True if handled types cannot be displayed directly in a browser
* but can be rendered
*/
function mustRender( $file ) { return false; }
@@ -166,7 +167,7 @@ abstract class MediaHandler {
/**
* Get an associative array of page dimensions
- * Currently "width" and "height" are understood, but this might be
+ * Currently "width" and "height" are understood, but this might be
* expanded in the future.
* Returns false if unknown or if the document is not multi-page.
*/
@@ -191,7 +192,7 @@ abstract class MediaHandler {
* ...
* )
* )
- * The UI will format this into a table where the visible fields are always
+ * The UI will format this into a table where the visible fields are always
* visible, and the collapsed fields are optionally visible.
*
* The function should return false if there is no metadata to display.
@@ -199,7 +200,7 @@ abstract class MediaHandler {
/**
* FIXME: I don't really like this interface, it's not very flexible
- * I think the media handler should generate HTML instead. It can do
+ * I think the media handler should generate HTML instead. It can do
* all the formatting according to some standard. That makes it possible
* to do things like visual indication of grouped and chained streams
* in ogg container files.
@@ -234,7 +235,9 @@ abstract class MediaHandler {
function getLongDesc( $file ) {
global $wgUser;
$sk = $wgUser->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 @@
<?php
+/**
+ * @file
+ * @ingroup Media
+ */
/**
- * @addtogroup Media
+ * @ingroup Media
*/
class SvgHandler extends ImageHandler {
function isEnabled() {
@@ -35,10 +39,10 @@ class SvgHandler extends ImageHandler {
}
return true;
}
-
+
function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath;
-
+
if ( !$this->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() ) );
}
}
-
-