if ( !isset( self::$handlers[$class] ) ) {
self::$handlers[$class] = new $class;
if ( !self::$handlers[$class]->isEnabled() ) {
+ wfDebug( __METHOD__ . ": $class is not enabled\n" );
self::$handlers[$class] = false;
}
}
return self::$handlers[$class];
}
+ /**
+ * Resets all static caches
+ */
+ public static function resetCache() {
+ self::$handlers = array();
+ }
+
/**
* Get an associative array mapping magic word IDs to parameter names.
* Will be used by the parser to identify parameters.
* Get an image size array like that returned by getimagesize(), or false if it
* can't be determined.
*
+ * This function is used for determining the width, height and bitdepth directly
+ * from an image. The results are stored in the database in the img_width,
+ * img_height, img_bits fields.
+ *
+ * @note If this is a multipage file, return the width and height of the
+ * first page.
+ *
* @param File $image The image object, or false if there isn't one
* @param string $path the filename
* @return array Follow the format of PHP getimagesize() internal function.
- * See http://www.php.net/getimagesize
+ * See http://www.php.net/getimagesize. MediaWiki will only ever use the
+ * first two array keys (the width and height), and the 'bits' associative
+ * key. All other array keys are ignored. Returning a 'bits' key is optional
+ * as not all formats have a notion of "bitdepth".
*/
abstract function getImageSize( $image, $path );
* @param File $image The image object, or false if there isn't one.
* Warning, FSFile::getPropsFromPath might pass an (object)array() instead (!)
* @param string $path The filename
- * @return string
+ * @return string A string of metadata in php serialized form (Run through serialize())
*/
function getMetadata( $image, $path ) {
return '';
*
* This is not used for validating metadata, this is used for the api when returning
* metadata, since api content formats should stay the same over time, and so things
- * using ForiegnApiRepo can keep backwards compatibility
+ * using ForeignApiRepo can keep backwards compatibility
*
* All core media handlers share a common version number, and extensions can
* use the GetMetadataVersion hook to append to the array (they should append a unique
/**
* Get a string describing the type of metadata, for display purposes.
+ *
+ * @note This method is currently unused.
* @param File $image
* @return string
*/
* If it returns MediaHandler::METADATA_BAD (or false), Image
* will reload the metadata from the file and update the database.
* MediaHandler::METADATA_GOOD for if the metadata is a-ok,
- * MediaHanlder::METADATA_COMPATIBLE if metadata is old but backwards
+ * MediaHandler::METADATA_COMPATIBLE if metadata is old but backwards
* compatible (which may or may not trigger a metadata reload).
+ *
+ * @note Returning self::METADATA_BAD will trigger a metadata reload from
+ * file on page view. Always returning this from a broken file, or suddenly
+ * triggering as bad metadata for a large number of files can cause
+ * performance problems.
* @param File $image
- * @param array $metadata
+ * @param string $metadata The metadata in serialized form
* @return bool
*/
function isMetadataValid( $image, $metadata ) {
* @return string
*/
function getShortDesc( $file ) {
- global $wgLang;
-
- return htmlspecialchars( $wgLang->formatSize( $file->getSize() ) );
+ return self::getGeneralShortDesc( $file );
}
/**
* @return string
*/
function getLongDesc( $file ) {
- global $wgLang;
-
- return wfMessage( 'file-info', htmlspecialchars( $wgLang->formatSize( $file->getSize() ) ),
- $file->getMimeType() )->parse();
+ return self::getGeneralLongDesc( $file );
}
/**
static function getGeneralShortDesc( $file ) {
global $wgLang;
- return $wgLang->formatSize( $file->getSize() );
+ return htmlspecialchars( $wgLang->formatSize( $file->getSize() ) );
}
/**
* @return string
*/
static function getGeneralLongDesc( $file ) {
- global $wgLang;
-
- return wfMessage( 'file-info', $wgLang->formatSize( $file->getSize() ),
- $file->getMimeType() )->parse();
+ return wfMessage( 'file-info' )->sizeParams( $file->getSize() )
+ ->params( $file->getMimeType() )->parse();
}
/**
public function getLength( $file ) {
return 0.0;
}
+
+ /**
+ * True if creating thumbnails from the file is large or otherwise resource-intensive.
+ * @param File $file
+ * @return bool
+ */
+ public function isExpensiveToThumbnail( $file ) {
+ return false;
+ }
+
+ /**
+ * Returns whether or not this handler supports the chained generation of thumbnails according
+ * to buckets
+ * @return boolean
+ * @since 1.24
+ */
+ public function supportsBucketing() {
+ return false;
+ }
+
+ /**
+ * Returns a normalised params array for which parameters have been cleaned up for bucketing
+ * purposes
+ * @param array $params
+ * @return array
+ */
+ public function sanitizeParamsForBucketing( $params ) {
+ return $params;
+ }
}