MediaWiki
REL1_22
|
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 47 of file FormatMetadata.php.
static FormatMetadata::collapseContactInfo | ( | $ | vals | ) | [static] |
Format the contact info field into a single value.
array | $vals | 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 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.
string | $val | The 8 digit news code. |
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.
array | $vals | array of values |
string | $type | 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 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.
int | $coord | degrees, minutes and seconds |
string | $type | latitude or longitude (for if its a NWS or E) |
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.
$num | Mixed: the value to format |
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.
$num | Mixed: the value to format |
$round | float|int|bool digits to round to or false. |
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.
$a | Integer: Numerator |
$b | Integer: Denominator |
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.
array | $tags | the Exif data to format ( as returned by Exif::getFilteredData() or BitmapMetadataHandler ) |
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.
string | $value | value (this is not escaped) |
string | $lang | lang code of item or false |
$default | Boolean if it is default value. | |
$noHtml | Boolean If to avoid html (for back-compat) |
MWException |
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()
string | $tag | the tag name to pass on |
string | $val | the value of the tag |
string | $arg | an argument to pass ($1) |
string | $arg2 | a 2nd argument to pass ($2) |
Definition at line 1015 of file FormatMetadata.php.
References $wgContLang, global, text, and wfMessage().
Referenced by convertNewsCode(), and getFormattedData().