[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/media/ -> XMP.php (summary)

Reader for XMP data containing properties relevant to images. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 1232 lines (40 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

XMPReader:: (26 methods):
  __construct()
  resetXMLParser()
  __destruct()
  getResults()
  parse()
  parseExtended()
  char()
  endElementModeIgnore()
  endElementModeSimple()
  endElementNested()
  endElementModeLi()
  endElementModeQDesc()
  endElement()
  startElementModeIgnore()
  startElementModeBag()
  startElementModeSeq()
  startElementModeLang()
  startElementModeSimple()
  startElementModeQDesc()
  startElementModeInitial()
  startElementModeStruct()
  startElementModeLi()
  startElementModeLiLang()
  startElement()
  doAttribs()
  saveValue()


Class: XMPReader  - X-Ref

Class for reading xmp data containing properties relevant to
images, and spitting out an array that FormatMetadata accepts.

Note, this is not meant to recognize every possible thing you can
encode in XMP. It should recognize all the properties we want.
For example it doesn't have support for structures with multiple
nesting levels, as none of the properties we're supporting use that
feature. If it comes across properties it doesn't recognize, it should
ignore them.

The public methods one would call in this class are
- parse( $content )
Reads in xmp content.
Can potentially be called multiple times with partial data each time.
- parseExtended( $content )
Reads XMPExtended blocks (jpeg files only).
- getResults
Outputs a results array.

Note XMP kind of looks like rdf. They are not the same thing - XMP is
encoded as a specific subset of rdf. This class can read XMP. It cannot
read rdf.

__construct()   X-Ref
Constructor.

Primary job is to initialize the XMLParser

resetXMLParser()   X-Ref
Main use is if a single item has multiple xmp documents describing it.
For example in jpeg's with extendedXMP


__destruct()   X-Ref
No description

getResults()   X-Ref
No description

parse( $content, $allOfIt = true, $reset = false )   X-Ref
Main function to call to parse XMP. Use getResults to
get results.

Also catches any errors during processing, writes them to
debug log, blanks result array and returns false.

param: string $content XMP data
param: bool $allOfIt If this is all the data (true) or if its split up (false). Default true
param: bool $reset Does xml parser need to be reset. Default false
return: bool Success.

parseExtended( $content )   X-Ref
No description

char( $parser, $data )   X-Ref
Character data handler
Called whenever character data is found in the xmp document.

does nothing if we're in MODE_IGNORE or if the data is whitespace
throws an error if we're not in MODE_SIMPLE (as we're not allowed to have character
data in the other modes).

As an example, this happens when we encounter XMP like:
<exif:DigitalZoomRatio>0/10</exif:DigitalZoomRatio>
and are processing the 0/10 bit.

param: XMLParser $parser XMLParser reference to the xml parser
param: string $data Character data

endElementModeIgnore( $elm )   X-Ref
No description

endElementModeSimple( $elm )   X-Ref
Hit a closing element when in MODE_SIMPLE.
This generally means that we finished processing a
property value, and now have to save the result to the
results array

For example, when processing:
<exif:DigitalZoomRatio>0/10</exif:DigitalZoomRatio>
this deals with when we hit </exif:DigitalZoomRatio>.

Or it could be if we hit the end element of a property
of a compound data structure (like a member of an array).

param: string $elm Namespace, space, and tag name.

endElementNested( $elm )   X-Ref
Hit a closing element in MODE_STRUCT, MODE_SEQ, MODE_BAG
generally means we've finished processing a nested structure.
resets some internal variables to indicate that.

Note this means we hit the closing element not the "</rdf:Seq>".

param: string $elm Namespace . space . tag name.

endElementModeLi( $elm )   X-Ref
Hit a closing element in MODE_LI (either rdf:Seq, or rdf:Bag )
Add information about what type of element this is.

Note we still have to hit the outer "</property>"

param: string $elm Namespace . ' ' . element name

endElementModeQDesc( $elm )   X-Ref
End element while in MODE_QDESC
mostly when ending an element when we have a simple value
that has qualifiers.

Qualifiers aren't all that common, and we don't do anything
with them.

param: string $elm Namespace and element

endElement( $parser, $elm )   X-Ref
Handler for hitting a closing element.

generally just calls a helper function depending on what
mode we're in.

Ignores the outer wrapping elements that are optional in
xmp and have no meaning.

param: XMLParser $parser
param: string $elm Namespace . ' ' . element name

startElementModeIgnore( $elm )   X-Ref
Hit an opening element while in MODE_IGNORE

XMP is extensible, so ignore any tag we don't understand.

Mostly ignores, unless we encounter the element that we are ignoring.
in which case we add it to the item stack, so we can ignore things
that are nested, correctly.

param: string $elm Namespace . ' ' . tag name

startElementModeBag( $elm )   X-Ref
Start element in MODE_BAG (unordered array)
this should always be <rdf:Bag>

param: string $elm Namespace . ' ' . tag

startElementModeSeq( $elm )   X-Ref
Start element in MODE_SEQ (ordered array)
this should always be <rdf:Seq>

param: string $elm Namespace . ' ' . tag

startElementModeLang( $elm )   X-Ref
Start element in MODE_LANG (language alternative)
this should always be <rdf:Alt>

This tag tends to be used for metadata like describe this
picture, which can be translated into multiple languages.

XMP supports non-linguistic alternative selections,
which are really only used for thumbnails, which
we don't care about.

param: string $elm Namespace . ' ' . tag

startElementModeSimple( $elm, $attribs )   X-Ref
Handle an opening element when in MODE_SIMPLE

This should not happen often. This is for if a simple element
already opened has a child element. Could happen for a
qualified element.

For example:
<exif:DigitalZoomRatio><rdf:Description><rdf:value>0/10</rdf:value>
<foo:someQualifier>Bar</foo:someQualifier> </rdf:Description>
</exif:DigitalZoomRatio>

This method is called when processing the <rdf:Description> element

param: string $elm Namespace and tag names separated by space.
param: array $attribs Attributes of the element.

startElementModeQDesc( $elm )   X-Ref
Start an element when in MODE_QDESC.
This generally happens when a simple element has an inner
rdf:Description to hold qualifier elements.

For example in:
<exif:DigitalZoomRatio><rdf:Description><rdf:value>0/10</rdf:value>
<foo:someQualifier>Bar</foo:someQualifier> </rdf:Description>
</exif:DigitalZoomRatio>
Called when processing the <rdf:value> or <foo:someQualifier>.

param: string $elm Namespace and tag name separated by a space.

startElementModeInitial( $ns, $tag, $attribs )   X-Ref
Starting an element when in MODE_INITIAL
This usually happens when we hit an element inside
the outer rdf:Description

This is generally where most properties start.

param: string $ns Namespace
param: string $tag Tag name (without namespace prefix)
param: array $attribs Array of attributes

startElementModeStruct( $ns, $tag, $attribs )   X-Ref
Hit an opening element when in a Struct (MODE_STRUCT)
This is generally for fields of a compound property.

Example of a struct (abbreviated; flash has more properties):

<exif:Flash> <rdf:Description> <exif:Fired>True</exif:Fired>
<exif:Mode>1</exif:Mode></rdf:Description></exif:Flash>

or:

<exif:Flash rdf:parseType='Resource'> <exif:Fired>True</exif:Fired>
<exif:Mode>1</exif:Mode></exif:Flash>

param: string $ns Namespace
param: string $tag Tag name (no ns)
param: array $attribs Array of attribs w/ values.

startElementModeLi( $elm, $attribs )   X-Ref
opening element in MODE_LI
process elements of arrays.

Example:
<exif:ISOSpeedRatings> <rdf:Seq> <rdf:li>64</rdf:li>
</rdf:Seq> </exif:ISOSpeedRatings>
This method is called when we hit the <rdf:li> element.

param: string $elm Namespace . ' ' . tagname
param: array $attribs Attributes. (needed for BAGSTRUCTS)

startElementModeLiLang( $elm, $attribs )   X-Ref
Opening element in MODE_LI_LANG.
process elements of language alternatives

Example:
<dc:title> <rdf:Alt> <rdf:li xml:lang="x-default">My house
</rdf:li> </rdf:Alt> </dc:title>

This method is called when we hit the <rdf:li> element.

param: string $elm Namespace . ' ' . tag
param: array $attribs Array of elements (most importantly xml:lang)

startElement( $parser, $elm, $attribs )   X-Ref
Hits an opening element.
Generally just calls a helper based on what MODE we're in.
Also does some initial set up for the wrapper element

param: XMLParser $parser
param: string $elm Namespace "<space>" element
param: array $attribs Attribute name => value

doAttribs( $attribs )   X-Ref
Process attributes.
Simple values can be stored as either a tag or attribute

Often the initial "<rdf:Description>" tag just has all the simple
properties as attributes.

param: array $attribs Array attribute=>value

saveValue( $ns, $tag, $val )   X-Ref
Given an extracted value, save it to results array

note also uses $this->ancestorStruct and
$this->processingArray to determine what name to
save the value under. (in addition to $tag).

param: string $ns Namespace of tag this is for
param: string $tag Tag name
param: string $val Value to save



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1