MediaWiki  REL1_22
FormatMetadata Class Reference

Format Image metadata values into a human readable form. More...

List of all members.

Static Public Member Functions

static collapseContactInfo ($vals)
 Format the contact info field into a single value.
static flattenArray ($vals, $type= 'ul', $noHtml=false)
 A function to collapse multivalued tags into a single value.
static formatCoords ($coord, $type)
 Format a coordinate value, convert numbers from floating point into degree minute second representation.
static formatFraction ($num)
 Format a rational number, reducing fractions.
static formatNum ($num, $round=false)
 Format a number, convert numbers from fractions into floating point numbers, joins arrays of numbers with commas.
static gcd ($a, $b)
 Calculate the greatest common divisor of two integers.
static getFormattedData ($tags)
 Numbers given by Exif user agents are often magical, that is they should be replaced by a detailed explanation depending on their value which most of the time are plain integers.
static msg ($tag, $val, $arg=null, $arg2=null)
 Convenience function for getFormattedData()

Static Private Member Functions

static convertNewsCode ($val)
 Fetch the human readable version of a news code.
static langItem ($value, $lang, $default=false, $noHtml=false)
 Helper function for creating lists of translations.

Detailed Description

Format Image metadata values into a human readable form.

Note lots of these messages use the prefix 'exif' even though they may not be exif properties. For example 'exif-ImageDescription' can be the Exif ImageDescription, or it could be the iptc-iim caption property, or it could be the xmp dc:description property. This is because these messages should be independent of how the data is stored, sine the user doesn't care if the description is stored in xmp, exif, etc only that its a description. (Additionally many of these properties are merged together following the MWG standard, such that for example, exif properties override XMP properties that mean the same thing if there is a conflict).

It should perhaps use a prefix like 'metadata' instead, but there is already a large number of messages using the 'exif' prefix.

Definition at line 47 of file FormatMetadata.php.


Member Function Documentation

static FormatMetadata::collapseContactInfo ( vals) [static]

Format the contact info field into a single value.

Parameters:
array$valsarray with fields of the ContactInfo struct defined in the IPTC4XMP spec. Or potentially an array with one element that is a free form text value from the older iptc iim 1:118 prop.

This function might be called from JpegHandler::convertMetadataVersion which is why it is public.

Returns:
String of html-ish looking wikitext

Definition at line 1239 of file FormatMetadata.php.

References array(), as, flattenArray(), and wfMessage().

Referenced by ExifBitmapHandler\convertMetadataVersion(), and getFormattedData().

static FormatMetadata::convertNewsCode ( val) [static, private]

Fetch the human readable version of a news code.

A news code is an 8 digit code. The first two digits are a general classification, so we just translate that.

Note, leading 0's are significant, so this is a string, not an int.

Parameters:
string$valThe 8 digit news code.
Returns:
string The human readable form

Definition at line 1122 of file FormatMetadata.php.

References msg().

Referenced by getFormattedData().

static FormatMetadata::flattenArray ( vals,
type = 'ul',
noHtml = false 
) [static]

A function to collapse multivalued tags into a single value.

This turns an array of (for example) authors into a bulleted list.

This is public on the basis it might be useful outside of this class.

Parameters:
array$valsarray of values
string$typeType of array (either lang, ul, ol). lang = language assoc array with keys being the lang code ul = unordered list, ol = ordered list type can also come from the '_type' member of $vals.
$noHtmlBoolean If to avoid returning anything resembling html. (Ugly hack for backwards compatibility with old mediawiki).
Returns:
String single value (in wiki-syntax).

Definition at line 844 of file FormatMetadata.php.

References $wgContLang, as, global, langItem(), and wfDebug().

Referenced by collapseContactInfo(), ExifBitmapHandler\convertMetadataVersion(), and getFormattedData().

static FormatMetadata::formatCoords ( coord,
type 
) [static]

Format a coordinate value, convert numbers from floating point into degree minute second representation.

Parameters:
int$coorddegrees, minutes and seconds
string$typelatitude or longitude (for if its a NWS or E)
Returns:
mixed A floating point number or whatever we were fed

Definition at line 1196 of file FormatMetadata.php.

References formatNum(), and wfMessage().

Referenced by getFormattedData().

static FormatMetadata::formatFraction ( num) [static]

Format a rational number, reducing fractions.

Access:
private
Parameters:
$numMixed: the value to format
Returns:
mixed A floating point number or whatever we were fed

Definition at line 1069 of file FormatMetadata.php.

References array(), formatNum(), and gcd().

static FormatMetadata::formatNum ( num,
round = false 
) [static]

Format a number, convert numbers from fractions into floating point numbers, joins arrays of numbers with commas.

Parameters:
$numMixed: the value to format
$roundfloat|int|bool digits to round to or false.
Returns:
mixed A floating point number or whatever we were fed

Definition at line 1032 of file FormatMetadata.php.

References $out, $wgLang, array(), as, and global.

Referenced by formatCoords(), formatFraction(), and getFormattedData().

static FormatMetadata::gcd ( a,
b 
) [static]

Calculate the greatest common divisor of two integers.

Parameters:
$aInteger: Numerator
$bInteger: Denominator
Returns:
int
Access:
private

Definition at line 1091 of file FormatMetadata.php.

Referenced by formatFraction().

static FormatMetadata::getFormattedData ( tags) [static]

Numbers given by Exif user agents are often magical, that is they should be replaced by a detailed explanation depending on their value which most of the time are plain integers.

This function formats Exif (and other metadata) values into human readable form.

Parameters:
array$tagsthe Exif data to format ( as returned by Exif::getFilteredData() or BitmapMetadataHandler )
Returns:
array

Definition at line 59 of file FormatMetadata.php.

References $n, $s, $time, $wgLang, array(), as, collapseContactInfo(), convertNewsCode(), Language\fetchLanguageName(), flattenArray(), formatCoords(), formatNum(), global, list, msg(), wfMessage(), and wfTimestamp().

Referenced by MediaHandler\formatMetadataHelper(), and Exif\makeFormattedData().

static FormatMetadata::langItem ( value,
lang,
default = false,
noHtml = false 
) [static, private]

Helper function for creating lists of translations.

Parameters:
string$valuevalue (this is not escaped)
string$langlang code of item or false
$defaultBoolean if it is default value.
$noHtmlBoolean If to avoid html (for back-compat)
Exceptions:
MWException
Returns:
string language item (Note: despite how this looks, this is treated as wikitext not html).

Definition at line 950 of file FormatMetadata.php.

References $value, Language\fetchLanguageName(), list, and wfMessage().

Referenced by flattenArray().

static FormatMetadata::msg ( tag,
val,
arg = null,
arg2 = null 
) [static]

Convenience function for getFormattedData()

Access:
private
Parameters:
string$tagthe tag name to pass on
string$valthe value of the tag
string$argan argument to pass ($1)
string$arg2a 2nd argument to pass ($2)
Returns:
string A wfMessage of "exif-$tag-$val" in lower case

Definition at line 1015 of file FormatMetadata.php.

References $wgContLang, global, text, and wfMessage().

Referenced by convertNewsCode(), and getFormattedData().


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