MediaWiki  REL1_19
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 46 of file FormatMetadata.php.


Member Function Documentation

static FormatMetadata::collapseContactInfo ( vals) [static]

Format the contact info field into a single value.

Parameters:
$valsArray array 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 1236 of file FormatMetadata.php.

References $url, flattenArray(), and wfMsg().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$valString: The 8 digit news code.
Returns:
The human readable form

Definition at line 1116 of file FormatMetadata.php.

References msg().

Referenced by getFormattedData().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$valsArray array of values
$typeString Type 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 838 of file FormatMetadata.php.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Parameters:
$coordArray: degrees, minutes and seconds
$typeString: latitude or longitude (for if its a NWS or E)
Returns:
mixed A floating point number or whatever we were fed

Definition at line 1190 of file FormatMetadata.php.

References formatNum(), and wfMsg().

Referenced by getFormattedData().

Here is the call graph for this function:

Here is the caller graph for this function:

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 1064 of file FormatMetadata.php.

References formatNum(), and gcd().

Here is the call graph for this function:

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

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

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

Definition at line 1027 of file FormatMetadata.php.

References $out, and $wgLang.

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

Here is the caller graph for this function:

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 1086 of file FormatMetadata.php.

Referenced by formatFraction().

Here is the caller graph for this function:

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:
$tagsArray: the Exif data to format ( as returned by Exif::getFilteredData() or BitmapMetadataHandler )
Returns:
array

Definition at line 58 of file FormatMetadata.php.

References $n, $wgLang, collapseContactInfo(), convertNewsCode(), flattenArray(), formatCoords(), formatNum(), msg(), wfMsg(), and wfTimestamp().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Helper function for creating lists of translations.

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

Definition at line 943 of file FormatMetadata.php.

References $wgContLang, and wfMsg().

Referenced by flattenArray().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Convenience function for getFormattedData()

Access:
private
Parameters:
$tagString: the tag name to pass on
$valString: the value of the tag
$argString: an argument to pass ($1)
$arg2String: a 2nd argument to pass ($2)
Returns:
string A wfMsg of "exif-$tag-$val" in lower case

Definition at line 1009 of file FormatMetadata.php.

References $wgContLang, and wfMsg().

Referenced by convertNewsCode(), and getFormattedData().

Here is the call graph for this function:

Here is the caller graph for this function:


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