MediaHandler Class Reference

Base media handler class. More...

Inherited by ImageHandler.

List of all members.

Public Member Functions

 getParamMap ()
 Get an associative array mapping magic word IDs to parameter names.
 validateParam ($name, $value)
 makeParamString ($params)
 Merge a parameter array into a string appropriate for inclusion in filenames.
 parseParamString ($str)
 Parse a param string made with makeParamString back into an array.
 normaliseParams ($image, &$params)
 Changes the parameter array as necessary, ready for transformation.
 getImageSize ($image, $path)
 Get an image size array like that returned by getimagesize(), or false if it can't be determined.
 getMetadata ($image, $path)
 Get handler-specific metadata which will be saved in the img_metadata field.
 getMetadataType ($image)
 Get a string describing the type of metadata, for display purposes.
 isMetadataValid ($image, $metadata)
 Check if the metadata string is valid for this handler.
 getScriptedTransform ($image, $script, $params)
 Get a MediaTransformOutput object representing an alternate of the transformed output which will call an intermediary thumbnail assist script.
 getTransform ($image, $dstPath, $dstUrl, $params)
 Get a MediaTransformOutput object representing the transformed output.
 doTransform ($image, $dstPath, $dstUrl, $params, $flags=0)
 Get a MediaTransformOutput object representing the transformed output.
 getThumbType ($ext, $mime)
 Get the thumbnail extension and MIME type for a given source MIME type.
 canRender ($file)
 True if the handled types can be transformed.
 mustRender ($file)
 True if handled types cannot be displayed directly in a browser but can be rendered.
 isMultiPage ($file)
 True if the type has multi-page capabilities.
 pageCount ($file)
 Page count for a multi-page document, false if unsupported or unknown.
 isEnabled ()
 False if the handler is disabled for all files.
 getPageDimensions ($image, $page)
 Get an associative array of page dimensions Currently "width" and "height" are understood, but this might be expanded in the future.
 formatMetadata ($image)
 Get an array structure that looks like this:.
 getShortDesc ($file)
 getLongDesc ($file)
 getDimensionsString ($file)
 parserTransformHook ($parser, $file)
 Modify the parser object post-transform.
 removeBadFile ($dstPath, $retval=0)
 Check for zero-sized thumbnails.

Static Public Member Functions

static getHandler ($type)
 Get a MediaHandler for a given MIME type from the instance cache.
static getGeneralShortDesc ($file)
static getGeneralLongDesc ($file)

Public Attributes

const TRANSFORM_LATER = 1

Static Public Attributes

static $handlers = array()
 Instance cache.

Static Protected Member Functions

static addMeta (&$array, $visibility, $type, $id, $value, $param=false)
 document this! 'value' thingy goes into a wikitext table; it used to be escaped but that was incompatible with previous practice of customized display with wikitext formatting via messages such as 'exif-model-value'.


Detailed Description

Base media handler class.

Definition at line 13 of file Generic.php.


Member Function Documentation

static MediaHandler::addMeta ( &$  array,
visibility,
type,
id,
value,
param = false 
) [static, protected]

document this! 'value' thingy goes into a wikitext table; it used to be escaped but that was incompatible with previous practice of customized display with wikitext formatting via messages such as 'exif-model-value'.

So the escaping is taken back out, but generally this seems a confusing interface.

Definition at line 220 of file Generic.php.

References wfMsg().

Referenced by BitmapHandler::formatMetadata().

MediaHandler::canRender ( file  ) 

True if the handled types can be transformed.

Reimplemented in ImageHandler, and TiffHandler.

Definition at line 149 of file Generic.php.

MediaHandler::doTransform ( image,
dstPath,
dstUrl,
params,
flags = 0 
) [abstract]

Get a MediaTransformOutput object representing the transformed output.

Does the transform unless $flags contains self::TRANSFORM_LATER.

Parameters:
Image $image The image object
string $dstPath Filesystem destination path
string $dstUrl Destination URL to use in output HTML
array $params Arbitrary set of parameters validated by $this->validateParam()
integer $flags A bitfield, may contain self::TRANSFORM_LATER

Reimplemented in BitmapHandler, BitmapHandler_ClientOnly, DjVuHandler, and SvgHandler.

Referenced by ImageHandler::getTransform(), and getTransform().

MediaHandler::formatMetadata ( image  ) 

Get an array structure that looks like this:.

array( 'visible' => array( 'Human-readable name' => 'Human readable value', ... ), 'collapsed' => array( 'Human-readable name' => 'Human readable value', ... ) ) 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. 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 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.

Reimplemented in BitmapHandler.

Definition at line 208 of file Generic.php.

MediaHandler::getDimensionsString ( file  ) 

Reimplemented in ImageHandler.

Definition at line 258 of file Generic.php.

static MediaHandler::getGeneralLongDesc ( file  )  [static]

Definition at line 250 of file Generic.php.

References $file, $wgUser, and wfMsgExt().

Referenced by File::getLongDesc().

static MediaHandler::getGeneralShortDesc ( file  )  [static]

Definition at line 243 of file Generic.php.

References $file, $wgLang, and wfMsgExt().

Referenced by File::getShortDesc().

static MediaHandler::getHandler ( type  )  [static]

Get a MediaHandler for a given MIME type from the instance cache.

Definition at line 24 of file Generic.php.

References $type, $wgMediaHandlers, isEnabled(), and wfDebug().

MediaHandler::getImageSize ( image,
path 
) [abstract]

Get an image size array like that returned by getimagesize(), or false if it can't be determined.

Parameters:
Image $image The image object, or false if there isn't one
string $fileName The filename
Returns:
array

Reimplemented in BmpHandler, DjVuHandler, ImageHandler, and SvgHandler.

Referenced by getPageDimensions().

MediaHandler::getLongDesc ( file  ) 

Reimplemented in ImageHandler, and SvgHandler.

Definition at line 235 of file Generic.php.

References $file, $wgUser, and wfMsgExt().

MediaHandler::getMetadata ( image,
path 
)

Get handler-specific metadata which will be saved in the img_metadata field.

Parameters:
Image $image The image object, or false if there isn't one
string $fileName The filename
Returns:
string

Reimplemented in BitmapHandler, and DjVuHandler.

Definition at line 87 of file Generic.php.

MediaHandler::getMetadataType ( image  ) 

Get a string describing the type of metadata, for display purposes.

Reimplemented in BitmapHandler, and DjVuHandler.

Definition at line 92 of file Generic.php.

MediaHandler::getPageDimensions ( image,
page 
)

Get an associative array of page dimensions 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.

Reimplemented in DjVuHandler.

Definition at line 174 of file Generic.php.

References getImageSize().

MediaHandler::getParamMap (  )  [abstract]

Get an associative array mapping magic word IDs to parameter names.

Will be used by the parser to identify parameters.

Reimplemented in DjVuHandler, and ImageHandler.

MediaHandler::getScriptedTransform ( image,
script,
params 
)

Get a MediaTransformOutput object representing an alternate of the transformed output which will call an intermediary thumbnail assist script.

Used when the repository has a thumbnailScriptUrl option configured.

Return false to fall back to the regular getTransform().

Reimplemented in ImageHandler.

Definition at line 109 of file Generic.php.

MediaHandler::getShortDesc ( file  ) 

Reimplemented in ImageHandler.

Definition at line 228 of file Generic.php.

References $file, $wgLang, and wfMsgExt().

MediaHandler::getThumbType ( ext,
mime 
)

Get the thumbnail extension and MIME type for a given source MIME type.

Returns:
array thumbnail extension and MIME type

Reimplemented in BmpHandler, DjVuHandler, SvgHandler, and TiffHandler.

Definition at line 142 of file Generic.php.

References $ext.

MediaHandler::getTransform ( image,
dstPath,
dstUrl,
params 
)

Get a MediaTransformOutput object representing the transformed output.

Does not actually do the transform.

Parameters:
Image $image The image object
string $dstPath Filesystem destination path
string $dstUrl Destination URL to use in output HTML
array $params Arbitrary set of parameters validated by $this->validateParam()

Reimplemented in ImageHandler.

Definition at line 122 of file Generic.php.

References doTransform().

MediaHandler::isEnabled (  ) 

False if the handler is disabled for all files.

Reimplemented in DjVuHandler, and SvgHandler.

Definition at line 166 of file Generic.php.

Referenced by getHandler().

MediaHandler::isMetadataValid ( image,
metadata 
)

Check if the metadata string is valid for this handler.

If it returns false, Image will reload the metadata from the file and update the database

Reimplemented in BitmapHandler, and DjVuHandler.

Definition at line 98 of file Generic.php.

MediaHandler::isMultiPage ( file  ) 

True if the type has multi-page capabilities.

Definition at line 158 of file Generic.php.

MediaHandler::makeParamString ( params  )  [abstract]

Merge a parameter array into a string appropriate for inclusion in filenames.

Reimplemented in DjVuHandler, and ImageHandler.

MediaHandler::mustRender ( file  ) 

True if handled types cannot be displayed directly in a browser but can be rendered.

Reimplemented in BmpHandler, SvgHandler, and TiffHandler.

Definition at line 154 of file Generic.php.

MediaHandler::normaliseParams ( image,
&$  params 
) [abstract]

Changes the parameter array as necessary, ready for transformation.

Should be idempotent. Returns false if the parameters are unacceptable and the transform should fail

Reimplemented in BitmapHandler, BitmapHandler_ClientOnly, ImageHandler, and SvgHandler.

MediaHandler::pageCount ( file  ) 

Page count for a multi-page document, false if unsupported or unknown.

Reimplemented in DjVuHandler.

Definition at line 162 of file Generic.php.

MediaHandler::parseParamString ( str  )  [abstract]

Parse a param string made with makeParamString back into an array.

Reimplemented in DjVuHandler, and ImageHandler.

MediaHandler::parserTransformHook ( parser,
file 
)

Modify the parser object post-transform.

Definition at line 265 of file Generic.php.

MediaHandler::removeBadFile ( dstPath,
retval = 0 
)

Check for zero-sized thumbnails.

These can be generated when no disk space is available or some other error occurs

Parameters:
$dstPath The location of the suspect file
$retval Return value of some shell process, file will be deleted if this is non-zero
Returns:
true if removed, false otherwise

Definition at line 275 of file Generic.php.

References wfDebugLog().

Referenced by DjVuHandler::doTransform(), BitmapHandler::doTransform(), and SvgHandler::rasterize().

MediaHandler::validateParam ( name,
value 
) [abstract]

Reimplemented in DjVuHandler, and ImageHandler.


Member Data Documentation

MediaHandler::$handlers = array() [static]

Instance cache.

Definition at line 19 of file Generic.php.

Definition at line 14 of file Generic.php.


The documentation for this class was generated from the following file:

Generated on Sat Sep 5 02:08:42 2009 for MediaWiki by  doxygen 1.5.9