MediaWiki
REL1_19
|
Format Image metadata values into a human readable form. More...
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. |
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.
static FormatMetadata::collapseContactInfo | ( | $ | vals | ) | [static] |
Format the contact info field into a single value.
$vals | Array 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.
Definition at line 1236 of file FormatMetadata.php.
References $url, flattenArray(), and wfMsg().
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.
$val | String: The 8 digit news code. |
Definition at line 1116 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.
$vals | Array array of values |
$type | String 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. |
$noHtml | Boolean If to avoid returning anything resembling html. (Ugly hack for backwards compatibility with old mediawiki). |
Definition at line 838 of file FormatMetadata.php.
References $wgContLang, 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.
$coord | Array: degrees, minutes and seconds |
$type | String: latitude or longitude (for if its a NWS or E) |
Definition at line 1190 of file FormatMetadata.php.
References formatNum(), and wfMsg().
Referenced by getFormattedData().
static FormatMetadata::formatFraction | ( | $ | num | ) | [static] |
Format a rational number, reducing fractions.
$num | Mixed: the value to format |
Definition at line 1064 of file FormatMetadata.php.
References 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.
$num | Mixed: the value to format |
$round | digits to round to or false. |
Definition at line 1027 of file FormatMetadata.php.
Referenced by formatCoords(), formatFraction(), and getFormattedData().
static FormatMetadata::gcd | ( | $ | a, |
$ | b | ||
) | [static] |
Calculate the greatest common divisor of two integers.
$a | Integer: Numerator |
$b | Integer: Denominator |
Definition at line 1086 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.
$tags | Array: the Exif data to format ( as returned by Exif::getFilteredData() or BitmapMetadataHandler ) |
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().
static FormatMetadata::langItem | ( | $ | value, |
$ | lang, | ||
$ | default = false , |
||
$ | noHtml = false |
||
) | [static, private] |
Helper function for creating lists of translations.
$value | String value (this is not escaped) |
$lang | String lang code of item or false |
$default | Boolean if it is default value. |
$noHtml | Boolean If to avoid html (for back-compat) |
Definition at line 943 of file FormatMetadata.php.
References $wgContLang, and wfMsg().
Referenced by flattenArray().
static FormatMetadata::msg | ( | $ | tag, |
$ | val, | ||
$ | arg = null , |
||
$ | arg2 = null |
||
) | [static] |
Convenience function for getFormattedData()
$tag | String: the tag name to pass on |
$val | String: the value of the tag |
$arg | String: an argument to pass ($1) |
$arg2 | String: a 2nd argument to pass ($2) |
Definition at line 1009 of file FormatMetadata.php.
References $wgContLang, and wfMsg().
Referenced by convertNewsCode(), and getFormattedData().