summaryrefslogtreecommitdiff
path: root/includes/media/SVGMetadataExtractor.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
commitca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch)
treeec04cc15b867bc21eedca904cea9af0254531a11 /includes/media/SVGMetadataExtractor.php
parenta22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff)
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing
Diffstat (limited to 'includes/media/SVGMetadataExtractor.php')
-rw-r--r--includes/media/SVGMetadataExtractor.php27
1 files changed, 18 insertions, 9 deletions
diff --git a/includes/media/SVGMetadataExtractor.php b/includes/media/SVGMetadataExtractor.php
index 66ae1edf..22ef8e61 100644
--- a/includes/media/SVGMetadataExtractor.php
+++ b/includes/media/SVGMetadataExtractor.php
@@ -55,7 +55,7 @@ class SVGReader {
$size = filesize( $source );
if ( $size === false ) {
throw new MWException( "Error getting filesize of SVG." );
- }
+ }
if ( $size > $wgSVGMetadataCutoff ) {
$this->debug( "SVG is $size bytes, which is bigger than $wgSVGMetadataCutoff. Truncating." );
@@ -84,14 +84,14 @@ class SVGReader {
wfRestoreWarnings();
}
- /*
+ /**
* @return Array with the known metadata
*/
public function getMetadata() {
return $this->metadata;
}
- /*
+ /**
* Read the SVG
*/
public function read() {
@@ -139,10 +139,12 @@ class SVGReader {
$keepReading = $this->reader->next();
}
+ $this->reader->close();
+
return true;
}
- /*
+ /**
* Read a textelement from an element
*
* @param String $name of the element that we are reading from
@@ -155,7 +157,7 @@ class SVGReader {
}
$keepReading = $this->reader->read();
while( $keepReading ) {
- if( $this->reader->localName == $name && $this->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::END_ELEMENT ) {
+ if( $this->reader->localName == $name && $this->reader->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::END_ELEMENT ) {
break;
} elseif( $this->reader->nodeType == XmlReader::TEXT ){
$this->metadata[$metafield] = trim( $this->reader->value );
@@ -175,20 +177,27 @@ class SVGReader {
return;
}
// TODO: find and store type of xml snippet. metadata['metadataType'] = "rdf"
- $this->metadata[$metafield] = trim( $this->reader->readInnerXML() );
+ if( method_exists( $this->reader, 'readInnerXML' ) ) {
+ $this->metadata[$metafield] = trim( $this->reader->readInnerXML() );
+ } else {
+ throw new MWException( "The PHP XMLReader extension does not come with readInnerXML() method. Your libxml is probably out of date (need 2.6.20 or later)." );
+ }
$this->reader->next();
}
- /*
+ /**
* Filter all children, looking for animate elements
*
* @param String $name of the element that we are reading from
*/
private function animateFilter( $name ) {
- $this->debug ( "animate filter" );
+ $this->debug ( "animate filter for tag $name" );
if( $this->reader->nodeType != XmlReader::ELEMENT ) {
return;
}
+ if ( $this->reader->isEmptyElement ) {
+ return;
+ }
$exitDepth = $this->reader->depth;
$keepReading = $this->reader->read();
while( $keepReading ) {
@@ -230,7 +239,7 @@ class SVGReader {
wfDebug( "SVGReader WARN: $data\n" );
}
- /*
+ /**
* Parse the attributes of an SVG element
*
* The parser has to be in the start element of <svg>