Merge "Declare visibility for class properties of PNGMetadataExtractor"
[lhc/web/wiklou.git] / includes / media / SVGMetadataExtractor.php
index c9a20f2..d332c3f 100644 (file)
@@ -31,6 +31,7 @@
 class SVGMetadataExtractor {
        static function getMetadata( $filename ) {
                $svg = new SVGReader( $filename );
+
                return $svg->getMetadata();
        }
 }
@@ -44,8 +45,10 @@ class SVGReader {
        const NS_SVG = 'http://www.w3.org/2000/svg';
 
        private $reader = null;
+
        private $mDebug = false;
-       private $metadata = Array();
+
+       private $metadata = array();
 
        /**
         * Constructor
@@ -101,7 +104,7 @@ class SVGReader {
                wfSuppressWarnings();
                try {
                        $this->read();
-               } catch( Exception $e ) {
+               } catch ( Exception $e ) {
                        // Note, if this happens, the width/height will be taken to be 0x0.
                        // Should we consider it the default 512x512 instead?
                        wfRestoreWarnings();
@@ -144,11 +147,13 @@ class SVGReader {
                while ( $keepReading ) {
                        $tag = $this->reader->localName;
                        $type = $this->reader->nodeType;
-                       $isSVG = ($this->reader->namespaceURI == self::NS_SVG);
+                       $isSVG = ( $this->reader->namespaceURI == self::NS_SVG );
 
                        $this->debug( "$tag" );
 
-                       if ( $isSVG && $tag == 'svg' && $type == XmlReader::END_ELEMENT && $this->reader->depth <= $exitDepth ) {
+                       if ( $isSVG && $tag == 'svg' && $type == XmlReader::END_ELEMENT
+                               && $this->reader->depth <= $exitDepth
+                       ) {
                                break;
                        } elseif ( $isSVG && $tag == 'title' ) {
                                $this->readField( $tag, 'title' );
@@ -192,7 +197,10 @@ class SVGReader {
                }
                $keepReading = $this->reader->read();
                while ( $keepReading ) {
-                       if ( $this->reader->localName == $name && $this->reader->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 );
@@ -216,7 +224,9 @@ class SVGReader {
                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)." );
+                       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();
        }
@@ -238,10 +248,13 @@ class SVGReader {
                $keepReading = $this->reader->read();
                while ( $keepReading ) {
                        if ( $this->reader->localName == $name && $this->reader->depth <= $exitDepth
-                               && $this->reader->nodeType == XmlReader::END_ELEMENT ) {
+                               && $this->reader->nodeType == XmlReader::END_ELEMENT
+                       ) {
                                break;
-                       } elseif ( $this->reader->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::ELEMENT ) {
-                               switch( $this->reader->localName ) {
+                       } elseif ( $this->reader->namespaceURI ==
+                               self::NS_SVG && $this->reader->nodeType == XmlReader::ELEMENT
+                       ) {
+                               switch ( $this->reader->localName ) {
                                        case 'script':
                                                // Normally we disallow files with
                                                // <script>, but its possible
@@ -333,7 +346,7 @@ class SVGReader {
         * http://www.w3.org/TR/SVG11/coords.html#UnitIdentifiers
         *
         * @param string $length CSS/SVG length.
-        * @param $viewportSize: Float optional scale for percentage units...
+        * @param $viewportSize : Float optional scale for percentage units...
         * @return float: length in pixels
         */
        static function scaleSVGUnit( $length, $viewportSize = 512 ) {
@@ -347,7 +360,7 @@ class SVGReader {
                        'em' => 16.0, // fake it?
                        'ex' => 12.0, // fake it?
                        '' => 1.0, // "User units" pixels by default
-                       );
+               );
                $matches = array();
                if ( preg_match( '/^\s*(\d+(?:\.\d+)?)(em|ex|px|pt|pc|cm|mm|in|%|)\s*$/', $length, $matches ) ) {
                        $length = floatval( $matches[1] );