<?php
+/**
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Media
+ */
+
/**
* Class for reading xmp data containing properties relevant to
* images, and spitting out an array that FormatExif accepts.
protected $items;
- /*
+ /**
* These are various mode constants.
* they are used to figure out what to do
* with an element when its encountered.
array( $this, 'endElement' ) );
xml_set_character_data_handler( $this->xmlParser, array( $this, 'char' ) );
-
-
}
/** Destroy the xml parser
// only apply to the dc:Creator prop, not the
// exif:Artist prop.
- $data['xmp-general']['Artist'][0] =
+ $data['xmp-general']['Artist'][0] =
$data['xmp-special']['AuthorsPosition'] . ', '
. $data['xmp-general']['Artist'][0];
}
* Also catches any errors during processing, writes them to
* debug log, blanks result array and returns false.
*
- * @param String: $content XMP data
- * @param Boolean: $allOfIt If this is all the data (true) or if its split up (false). Default true
- * @param Boolean: $reset - does xml parser need to be reset. Default false
+ * @param $content String: XMP data
+ * @param $allOfIt Boolean: If this is all the data (true) or if its split up (false). Default true
+ * @param $reset Boolean: does xml parser need to be reset. Default false
* @return Boolean success.
*/
public function parse( $content, $allOfIt = true, $reset = false ) {
if ( !$this->charset ) {
$bom = array();
if ( preg_match( '/\xEF\xBB\xBF|\xFE\xFF|\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFF\xFE/',
- $content, $bom )
+ $content, $bom )
) {
switch ( $bom[0] ) {
case "\xFE\xFF":
* @return Boolean If it succeeded.
*/
public function parseExtended( $content ) {
- // FIXME: This is untested. Hard to find example files
+ // @todo FIXME: This is untested. Hard to find example files
// or programs that make such files..
$guid = substr( $content, 0, 32 );
if ( !isset( $this->results['xmp-special']['HasExtendedXMP'] )
}
}
+
/** When we hit a closing element in MODE_IGNORE
* Check to see if this is the element we started to ignore,
* in which case we get out of MODE_IGNORE
return;
}
+
/**
* 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:
+ * For example, when processing:
* <exif:DigitalZoomRatio>0/10</exif:DigitalZoomRatio>
* this deals with when we hit </exif:DigitalZoomRatio>.
*
array_shift( $this->mode );
}
+
/**
* Hit a closing element in MODE_STRUCT, MODE_SEQ, MODE_BAG
* generally means we've finished processing a nested structure.
throw new MWException( __METHOD__ . " expected </rdf:seq> or </rdf:bag> but instead got $elm." );
}
}
+
/**
* End element while in MODE_QDESC
* mostly when ending an element when we have a simple value
}
+
/**
* 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.
*
private function startElementModeSeq( $elm ) {
if ( $elm === self::NS_RDF . ' Seq' ) {
array_unshift( $this->mode, self::MODE_LI );
- } else if ( $elm === self::NS_RDF . ' Bag' ) {
+ } elseif ( $elm === self::NS_RDF . ' Bag' ) {
# bug 27105
wfDebugLog( 'XMP', __METHOD__ . ' Expected an rdf:Seq, but got an rdf:Bag. Pretending'
. ' it is a Seq, since some buggy software is known to screw this up.' );
* <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>
+ * <exif:Mode>1</exif:Mode></exif:Flash>
*
* @param $ns String namespace
* @param $tag String tag name (no ns)
* This method is called when we hit the <rdf:li> element.
*
* @param $elm String: namespace . ' ' . tagname
- * @param $attribs Array: Attributes. (needed for BAGSTRUCTS)
+ * @param $attribs Array: Attributes. (needed for BAGSTRUCTS)
* @throws MWException if gets a tag other than <rdf:li>
*/
private function startElementModeLi( $elm, $attribs ) {
function startElement( $parser, $elm, $attribs ) {
if ( $elm === self::NS_RDF . ' RDF'
- || $elm === 'adobe:ns:meta/ xmpmeta'
+ || $elm === 'adobe:ns:meta/ xmpmeta'
|| $elm === 'adobe:ns:meta/ xapmeta')
{
/* ignore. */
break;
}
}
+
/**
* Process attributes.
* Simple values can be stored as either a tag or attribute
* @param $attribs Array attribute=>value array.
*/
private function doAttribs( $attribs ) {
-
+
// first check for rdf:parseType attribute, as that can change
// how the attributes are interperted.
}
}
}
+
/**
* Given an extracted value, save it to results array
*