Parameter documentation
This commit is contained in:
parent
15f4f6f360
commit
dfcc5bb7fc
8 changed files with 151 additions and 9 deletions
|
|
@ -12,6 +12,12 @@
|
|||
* @ingroup Media
|
||||
*/
|
||||
class BitmapHandler extends ImageHandler {
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $params
|
||||
* @return bool
|
||||
*/
|
||||
function normaliseParams( $image, &$params ) {
|
||||
global $wgMaxImageArea;
|
||||
if ( !parent::normaliseParams( $image, $params ) ) {
|
||||
|
|
@ -65,6 +71,14 @@ class BitmapHandler extends ImageHandler {
|
|||
return $width * $height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $dstPath
|
||||
* @param $dstUrl
|
||||
* @param $params
|
||||
* @param int $flags
|
||||
* @return MediaTransformError|ThumbnailImage|TransformParameterError
|
||||
*/
|
||||
function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
|
||||
if ( !$this->normaliseParams( $image, $params ) ) {
|
||||
return new TransformParameterError( $params );
|
||||
|
|
@ -614,6 +628,10 @@ class BitmapHandler extends ImageHandler {
|
|||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @return array|bool
|
||||
*/
|
||||
function formatMetadata( $image ) {
|
||||
$result = array(
|
||||
'visible' => array(),
|
||||
|
|
|
|||
|
|
@ -15,10 +15,24 @@
|
|||
* @ingroup Media
|
||||
*/
|
||||
class BitmapHandler_ClientOnly extends BitmapHandler {
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $params
|
||||
* @return bool
|
||||
*/
|
||||
function normaliseParams( $image, &$params ) {
|
||||
return ImageHandler::normaliseParams( $image, $params );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $dstPath
|
||||
* @param $dstUrl
|
||||
* @param $params
|
||||
* @param int $flags
|
||||
* @return ThumbnailImage|TransformParameterError
|
||||
*/
|
||||
function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
|
||||
if ( !$this->normaliseParams( $image, $params ) ) {
|
||||
return new TransformParameterError( $params );
|
||||
|
|
|
|||
|
|
@ -68,6 +68,14 @@ class DjVuHandler extends ImageHandler {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $dstPath
|
||||
* @param $dstUrl
|
||||
* @param $params
|
||||
* @param int $flags
|
||||
* @return MediaTransformError|ThumbnailImage|TransformParameterError
|
||||
*/
|
||||
function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
|
||||
global $wgDjvuRenderer, $wgDjvuPostProcessor;
|
||||
|
||||
|
|
@ -139,6 +147,7 @@ class DjVuHandler extends ImageHandler {
|
|||
|
||||
/**
|
||||
* Cache a document tree for the DjVu XML metadata
|
||||
* @param $image File
|
||||
*/
|
||||
function getMetaTree( $image , $gettext = false ) {
|
||||
if ( isset( $image->dejaMetaTree ) ) {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,13 @@ class GIFHandler extends BitmapHandler {
|
|||
function formatMetadata( $image ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $width
|
||||
* @param $height
|
||||
* @return
|
||||
*/
|
||||
function getImageArea( $image, $width, $height ) {
|
||||
$ser = $image->getMetadata();
|
||||
if ($ser) {
|
||||
|
|
@ -42,6 +48,10 @@ class GIFHandler extends BitmapHandler {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @return bool
|
||||
*/
|
||||
function isAnimatedImage( $image ) {
|
||||
$ser = $image->getMetadata();
|
||||
if ($ser) {
|
||||
|
|
@ -62,6 +72,10 @@ class GIFHandler extends BitmapHandler {
|
|||
return (boolean) $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @return string
|
||||
*/
|
||||
function getLongDesc( $image ) {
|
||||
global $wgLang;
|
||||
|
||||
|
|
|
|||
|
|
@ -187,6 +187,8 @@ abstract class MediaHandler {
|
|||
* 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.
|
||||
*
|
||||
* @param $image File
|
||||
*/
|
||||
function getPageDimensions( $image, $page ) {
|
||||
$gis = $this->getImageSize( $image, $image->getPath() );
|
||||
|
|
@ -250,6 +252,10 @@ abstract class MediaHandler {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return string
|
||||
*/
|
||||
function getShortDesc( $file ) {
|
||||
global $wgLang;
|
||||
$nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
|
||||
|
|
@ -257,6 +263,10 @@ abstract class MediaHandler {
|
|||
return "$nbytes";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return string
|
||||
*/
|
||||
function getLongDesc( $file ) {
|
||||
global $wgUser;
|
||||
$sk = $wgUser->getSkin();
|
||||
|
|
@ -264,7 +274,11 @@ abstract class MediaHandler {
|
|||
$sk->formatSize( $file->getSize() ),
|
||||
$file->getMimeType() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return string
|
||||
*/
|
||||
static function getGeneralShortDesc( $file ) {
|
||||
global $wgLang;
|
||||
$nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
|
||||
|
|
@ -272,6 +286,10 @@ abstract class MediaHandler {
|
|||
return "$nbytes";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return string
|
||||
*/
|
||||
static function getGeneralLongDesc( $file ) {
|
||||
global $wgUser;
|
||||
$sk = $wgUser->getSkin();
|
||||
|
|
@ -332,12 +350,13 @@ abstract class MediaHandler {
|
|||
* @ingroup Media
|
||||
*/
|
||||
abstract class ImageHandler extends MediaHandler {
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return bool
|
||||
*/
|
||||
function canRender( $file ) {
|
||||
if ( $file->getWidth() && $file->getHeight() ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return ( $file->getWidth() && $file->getHeight() );
|
||||
}
|
||||
|
||||
function getParamMap() {
|
||||
|
|
@ -382,6 +401,11 @@ abstract class ImageHandler extends MediaHandler {
|
|||
return array( 'width' => $params['width'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $params
|
||||
* @return bool
|
||||
*/
|
||||
function normaliseParams( $image, &$params ) {
|
||||
$mimeType = $image->getMimeType();
|
||||
|
||||
|
|
@ -449,6 +473,12 @@ abstract class ImageHandler extends MediaHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $script
|
||||
* @param $params
|
||||
* @return bool|ThumbnailImage
|
||||
*/
|
||||
function getScriptedTransform( $image, $script, $params ) {
|
||||
if ( !$this->normaliseParams( $image, $params ) ) {
|
||||
return false;
|
||||
|
|
@ -472,6 +502,10 @@ abstract class ImageHandler extends MediaHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return string
|
||||
*/
|
||||
function getShortDesc( $file ) {
|
||||
global $wgLang;
|
||||
$nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
|
||||
|
|
@ -481,6 +515,10 @@ abstract class ImageHandler extends MediaHandler {
|
|||
return "$widthheight ($nbytes)";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return string
|
||||
*/
|
||||
function getLongDesc( $file ) {
|
||||
global $wgLang;
|
||||
return wfMsgExt('file-info-size', 'parseinline',
|
||||
|
|
@ -490,6 +528,10 @@ abstract class ImageHandler extends MediaHandler {
|
|||
$file->getMimeType() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return string
|
||||
*/
|
||||
function getDimensionsString( $file ) {
|
||||
global $wgLang;
|
||||
$pages = $file->pageCount();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,12 @@
|
|||
* @ingroup Media
|
||||
*/
|
||||
abstract class MediaTransformOutput {
|
||||
var $file, $width, $height, $url, $page, $path;
|
||||
/**
|
||||
* @var File
|
||||
*/
|
||||
var $file;
|
||||
|
||||
var $width, $height, $url, $page, $path;
|
||||
|
||||
/**
|
||||
* Get the width of the output box
|
||||
|
|
|
|||
|
|
@ -31,7 +31,11 @@ class PNGHandler extends BitmapHandler {
|
|||
function formatMetadata( $image ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @return bool
|
||||
*/
|
||||
function isAnimatedImage( $image ) {
|
||||
$ser = $image->getMetadata();
|
||||
if ($ser) {
|
||||
|
|
@ -51,6 +55,11 @@ class PNGHandler extends BitmapHandler {
|
|||
wfRestoreWarnings();
|
||||
return (boolean) $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @return string
|
||||
*/
|
||||
function getLongDesc( $image ) {
|
||||
global $wgLang;
|
||||
$original = parent::getLongDesc( $image );
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ class SvgHandler extends ImageHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return bool
|
||||
*/
|
||||
function isAnimatedImage( $file ) {
|
||||
# TODO: detect animated SVGs
|
||||
$metadata = $file->getMetadata();
|
||||
|
|
@ -44,6 +48,11 @@ class SvgHandler extends ImageHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $params
|
||||
* @return bool
|
||||
*/
|
||||
function normaliseParams( $image, &$params ) {
|
||||
global $wgSVGMaxSize;
|
||||
if ( !parent::normaliseParams( $image, $params ) ) {
|
||||
|
|
@ -61,6 +70,14 @@ class SvgHandler extends ImageHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image File
|
||||
* @param $dstPath
|
||||
* @param $dstUrl
|
||||
* @param $params
|
||||
* @param int $flags
|
||||
* @return bool|MediaTransformError|ThumbnailImage|TransformParameterError
|
||||
*/
|
||||
function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
|
||||
if ( !$this->normaliseParams( $image, $params ) ) {
|
||||
return new TransformParameterError( $params );
|
||||
|
|
@ -125,6 +142,12 @@ class SvgHandler extends ImageHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @param $path
|
||||
* @param bool $metadata
|
||||
* @return array
|
||||
*/
|
||||
function getImageSize( $file, $path, $metadata = false ) {
|
||||
if ( $metadata === false ) {
|
||||
$metadata = $file->getMetaData();
|
||||
|
|
@ -141,6 +164,10 @@ class SvgHandler extends ImageHandler {
|
|||
return array( 'png', 'image/png' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return string
|
||||
*/
|
||||
function getLongDesc( $file ) {
|
||||
global $wgLang;
|
||||
return wfMsgExt( 'svg-long-desc', 'parseinline',
|
||||
|
|
@ -183,6 +210,10 @@ class SvgHandler extends ImageHandler {
|
|||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file File
|
||||
* @return array|bool
|
||||
*/
|
||||
function formatMetadata( $file ) {
|
||||
$result = array(
|
||||
'visible' => array(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue