diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
commit | 9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch) | |
tree | 46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/media/Generic.php | |
parent | 78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff) |
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/media/Generic.php')
-rw-r--r-- | includes/media/Generic.php | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/includes/media/Generic.php b/includes/media/Generic.php index 8a4d7054..fa4e731a 100644 --- a/includes/media/Generic.php +++ b/includes/media/Generic.php @@ -1,6 +1,7 @@ <?php /** * Media-handling base classes and generic functionality + * * @file * @ingroup Media */ @@ -72,7 +73,7 @@ abstract class MediaHandler { * can't be determined. * * @param $image File: the image object, or false if there isn't one - * @param $fileName String: the filename + * @param $path String: the filename * @return Array */ abstract function getImageSize( $image, $path ); @@ -80,7 +81,8 @@ abstract class MediaHandler { /** * Get handler-specific metadata which will be saved in the img_metadata field. * - * @param $image File: the image object, or false if there isn't one + * @param $image File: the image object, or false if there isn't one. + * Warning, File::getPropsFromPath might pass an (object)array() instead (!) * @param $path String: the filename * @return String */ @@ -139,7 +141,7 @@ abstract class MediaHandler { * Get the thumbnail extension and MIME type for a given source MIME type * @return array thumbnail extension and MIME type */ - function getThumbType( $ext, $mime ) { + function getThumbType( $ext, $mime, $params = null ) { return array( $ext, $mime ); } @@ -161,6 +163,10 @@ abstract class MediaHandler { */ function pageCount( $file ) { return false; } /** + * The material is vectorized and thus scaling is lossless + */ + function isVectorized( $file ) { return false; } + /** * False if the handler is disabled for all files */ function isEnabled() { return true; } @@ -235,8 +241,8 @@ abstract class 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() ) ); return "$nbytes"; } @@ -250,8 +256,8 @@ abstract class MediaHandler { static function getGeneralShortDesc( $file ) { global $wgLang; - $nbytes = '(' . wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), - $wgLang->formatNum( $file->getSize() ) ) . ')'; + $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), + $wgLang->formatNum( $file->getSize() ) ); return "$nbytes"; } @@ -273,6 +279,20 @@ abstract class MediaHandler { function parserTransformHook( $parser, $file ) {} /** + * File validation hook called on upload. + * + * If the file at the given local path is not valid, or its MIME type does not + * match the handler class, a Status object should be returned containing + * relevant errors. + * + * @param $fileName The local path to the file. + * @return Status object + */ + function verifyUpload( $fileName ) { + return Status::newGood(); + } + + /** * Check for zero-sized thumbnails. These can be generated when * no disk space is available or some other error occurs * @@ -357,9 +377,19 @@ abstract class ImageHandler extends MediaHandler { if ( !isset( $params['width'] ) ) { return false; } + if ( !isset( $params['page'] ) ) { $params['page'] = 1; + } else { + if ( $params['page'] > $image->pageCount() ) { + $params['page'] = $image->pageCount(); + } + + if ( $params['page'] < 1 ) { + $params['page'] = 1; + } } + $srcWidth = $image->getWidth( $params['page'] ); $srcHeight = $image->getHeight( $params['page'] ); if ( isset( $params['height'] ) && $params['height'] != -1 ) { @@ -386,6 +416,9 @@ abstract class ImageHandler extends MediaHandler { * * @param $width Integer: specified width (input/output) * @param $height Integer: height (output only) + * @param $srcWidth Integer: width of the source image + * @param $srcHeight Integer: height of the source image + * @param $mimeType Unused * @return false to indicate that an error should be returned to the user. */ function validateThumbParams( &$width, &$height, $srcWidth, $srcHeight, $mimeType ) { @@ -424,6 +457,10 @@ abstract class ImageHandler extends MediaHandler { return $gis; } + function isAnimatedImage( $image ) { + return false; + } + function getShortDesc( $file ) { global $wgLang; $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), |