[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.tag.xmp.php
index 40dd8bd..a976ef8 100644 (file)
@@ -1,11 +1,11 @@
 <?php
+
 /////////////////////////////////////////////////////////////////
 /// getID3() by James Heinrich <info@getid3.org>               //
-//  available at http://getid3.sourceforge.net                 //
-//            or http://www.getid3.org                         //
-//          also https://github.com/JamesHeinrich/getID3       //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details                             //
+//  available at https://github.com/JamesHeinrich/getID3       //
+//            or https://www.getid3.org                        //
+//            or http://getid3.sourceforge.net                 //
+//  see readme.txt for more details                            //
 /////////////////////////////////////////////////////////////////
 //                                                             //
 // module.tag.xmp.php                                          //
@@ -81,8 +81,8 @@ class Image_XMP
        * Reads all the JPEG header segments from an JPEG image file into an array
        *
        * @param string $filename - the filename of the JPEG file to read
-       * @return array $headerdata - Array of JPEG header segments
-       * @return boolean FALSE - if headers could not be read
+       * @return array|boolean  $headerdata - Array of JPEG header segments,
+       *                        FALSE - if headers could not be read
        */
        public function _get_jpeg_header_data($filename)
        {
@@ -124,6 +124,7 @@ class Image_XMP
                // Flag that we havent yet hit the compressed image data
                $hit_compressed_image_data = false;
 
+        $headerdata = array();
                // Cycle through the file until, one of: 1) an EOI (End of image) marker is hit,
                //                                       2) we have hit the compressed image data (no more headers are allowed after data)
                //                                       3) or end of file is hit
@@ -191,8 +192,8 @@ class Image_XMP
        * Retrieves XMP information from an APP1 JPEG segment and returns the raw XML text as a string.
        *
        * @param string $filename - the filename of the JPEG file to read
-       * @return string $xmp_data - the string of raw XML text
-       * @return boolean FALSE - if an APP 1 XMP segment could not be found, or if an error occured
+       * @return string|boolean $xmp_data - the string of raw XML text,
+       *                        FALSE - if an APP 1 XMP segment could not be found, or if an error occured
        */
        public function _get_XMP_text($filename)
        {
@@ -212,7 +213,7 @@ class Image_XMP
                                        // Return the XMP text
                                        $xmp_data = substr($jpeg_header_data[$i]['SegData'], 29);
 
-                                       return trim($xmp_data); // trim() should not be neccesary, but some files found in the wild with null-terminated block (known samples from Apple Aperture) causes problems elsewhere (see http://www.getid3.org/phpBB3/viewtopic.php?f=4&t=1153)
+                                       return trim($xmp_data); // trim() should not be neccesary, but some files found in the wild with null-terminated block (known samples from Apple Aperture) causes problems elsewhere (see https://www.getid3.org/phpBB3/viewtopic.php?f=4&t=1153)
                                }
                        }
                }
@@ -223,9 +224,9 @@ class Image_XMP
        * Parses a string containing XMP data (XML), and returns an array
        * which contains all the XMP (XML) information.
        *
-       * @param string $xml_text - a string containing the XMP data (XML) to be parsed
-       * @return array $xmp_array - an array containing all xmp details retrieved.
-       * @return boolean FALSE - couldn't parse the XMP data
+       * @param string $xmltext - a string containing the XMP data (XML) to be parsed
+       * @return array|boolean $xmp_array - an array containing all xmp details retrieved,
+       *                       FALSE - couldn't parse the XMP data.
        */
        public function read_XMP_array_from_text($xmltext)
        {
@@ -311,10 +312,12 @@ class Image_XMP
                                                                        }
                                                                }
                                                        }
+                                                       break;
                                                case 'cdata':
                                                case 'close':
                                                        break;
                                        }
+                                       break;
 
                                case 'rdf:ID':
                                case 'rdf:nodeID':
@@ -397,7 +400,7 @@ class Image_XMP
        /**
        * Constructor
        *
-       * @param string - Name of the image file to access and extract XMP information from.
+       * @param string $sFilename - Name of the image file to access and extract XMP information from.
        */
        public function __construct($sFilename)
        {
@@ -409,8 +412,11 @@ class Image_XMP
                        $xmp_data = $this->_get_XMP_text($sFilename);
                        if ($xmp_data)
                        {
-                               $this->_aXMP = $this->read_XMP_array_from_text($xmp_data);
-                               $this->_bXMPParse = true;
+                               $aXMP = $this->read_XMP_array_from_text($xmp_data);
+                               if ($aXMP !== false) {
+                                       $this->_aXMP = (array) $aXMP;
+                                       $this->_bXMPParse = true;
+                               }
                        }
                }
        }