BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
FormatMetadata Class Reference
Inheritance diagram for FormatMetadata:
Collaboration diagram for FormatMetadata:

Public Member Functions

 setSingleLanguage ($val)
 
 makeFormattedData ($tags)
 
 flattenArrayReal ($vals, $type= 'ul', $noHtml=false)
 
 collapseContactInfo ($vals)
 
 fetchExtendedMetadata (File $file)
 
- Public Member Functions inherited from ContextSource
 getContext ()
 
 setContext (IContextSource $context)
 
 getConfig ()
 
 getRequest ()
 
 getTitle ()
 
 canUseWikiPage ()
 
 getWikiPage ()
 
 getOutput ()
 
 getUser ()
 
 getLanguage ()
 
 getSkin ()
 
 getTiming ()
 
 getStats ()
 
 msg ($key)
 
 exportSession ()
 

Static Public Member Functions

static getFormattedData ($tags, $context=false)
 
static flattenArrayContentLang ($vals, $type= 'ul', $noHtml=false, $context=false)
 
static getVisibleFields ()
 

Protected Member Functions

 getExtendedMetadataFromFile (File $file)
 
 getExtendedMetadataFromHook (File $file, array $extendedMetadata, &$maxCacheTime)
 
 resolveMultilangValue ($value)
 
 resolveMultivalueValue ($value)
 
 resolveMultilangMetadata (&$metadata)
 
 discardMultipleValues (&$metadata)
 
 sanitizeArrayForAPI (&$arr)
 
 sanitizeKeyForAPI ($key)
 
 getPriorityLanguages ()
 

Protected Attributes

 $singleLang = false
 

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.

Since
1.23 the class extends ContextSource and various formerly-public internal methods are private

Member Function Documentation

FormatMetadata::collapseContactInfo (   $vals)

Format the contact info field into a single value.

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

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.
Returns
string HTML-ish looking wikitext
Since
1.23 no longer static
FormatMetadata::discardMultipleValues ( $metadata)
protected

Takes an array returned by the getExtendedMetadata* functions, and turns all fields into single-valued ones by dropping extra values.

Parameters
array&$metadata
Since
1.25
FormatMetadata::fetchExtendedMetadata ( File  $file)

Get an array of extended metadata. (See the imageinfo API for format.)

Parameters
File$fileFile to use
Returns
array [<property name>=""> => ['value' =>

]], or [] on error

Since
1.23
static FormatMetadata::flattenArrayContentLang (   $vals,
  $type = 'ul',
  $noHtml = false,
  $context = false 
)
static

Flatten an array, using the content language for any messages.

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.
bool$noHtmlIf to avoid returning anything resembling HTML. (Ugly hack for backwards compatibility with old MediaWiki).
bool | IContextSource$context
Returns
string Single value (in wiki-syntax).
Since
1.23
FormatMetadata::flattenArrayReal (   $vals,
  $type = 'ul',
  $noHtml = false 
)

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.
bool$noHtmlIf to avoid returning anything resembling HTML. (Ugly hack for backwards compatibility with old mediawiki).
Returns
string Single value (in wiki-syntax).
Since
1.23
FormatMetadata::getExtendedMetadataFromFile ( File  $file)
protected

Get file-based metadata in standardized format.

Note that for a remote file, this might return metadata supplied by extensions.

Parameters
File$fileFile to use
Returns
array [<property name>=""> => ['value' =>

]], or [] on error

Since
1.23
FormatMetadata::getExtendedMetadataFromHook ( File  $file,
array  $extendedMetadata,
$maxCacheTime 
)
protected

Get additional metadata from hooks in standardized format.

Parameters
File$fileFile to use
array$extendedMetadata
int&$maxCacheTimeHook handlers might use this parameter to override cache time
Returns
array [<property name>=""> => ['value' =>

]], or [] on error

Since
1.23
static FormatMetadata::getFormattedData (   $tags,
  $context = false 
)
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.

This is the usual entry point for this class.

Parameters
array$tagsThe Exif data to format ( as returned by Exif::getFilteredData() or BitmapMetadataHandler )
bool | IContextSource$contextContext to use (optional)
Returns
array
FormatMetadata::getPriorityLanguages ( )
protected

Returns a list of languages (first is best) to use when formatting multilang fields, based on user and site preferences.

Returns
array
Since
1.23
static FormatMetadata::getVisibleFields ( )
static

Get a list of fields that are visible by default.

Returns
array
Since
1.23
FormatMetadata::makeFormattedData (   $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. 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
Since
1.23
FormatMetadata::resolveMultilangMetadata ( $metadata)
protected

Takes an array returned by the getExtendedMetadata* functions, and resolves multi-language values in it.

Parameters
array&$metadata
Since
1.23
FormatMetadata::resolveMultilangValue (   $value)
protected

Turns an XMP-style multilang array into a single value. If the value is not a multilang array, it is returned unchanged. See mediawiki.org/wiki/Manual:File_metadata_handling::Multi-language_array_format

Parameters
mixed$value
Returns
mixed Value in best language, null if there were no languages at all
Since
1.23
FormatMetadata::resolveMultivalueValue (   $value)
protected

Turns an XMP-style multivalue array into a single value by dropping all but the first value. If the value is not a multivalue array (or a multivalue array inside a multilang array), it is returned unchanged. See mediawiki.org/wiki/Manual:File_metadata_handling::Multi-language_array_format

Parameters
mixed$value
Returns
mixed The value, or the first value if there were multiple ones
Since
1.25
FormatMetadata::sanitizeArrayForAPI ( $arr)
protected

Makes sure the given array is a valid API response fragment

Parameters
array&$arr
FormatMetadata::sanitizeKeyForAPI (   $key)
protected

Turns a string into a valid API identifier.

Parameters
string$key
Returns
string
Since
1.23
FormatMetadata::setSingleLanguage (   $val)

Trigger only outputting single language for multilanguage fields

Parameters
bool$val
Since
1.23

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