DJVU rendering: Handle old DB metadata entries
authorJens Frank <jeluf@users.mediawiki.org>
Sun, 13 Aug 2006 21:09:20 +0000 (21:09 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Sun, 13 Aug 2006 21:09:20 +0000 (21:09 +0000)
includes/Image.php

index 743e1b8..f329fed 100644 (file)
@@ -2257,13 +2257,21 @@ class Image
                        $this->load();
                }
                if ( ! isset( $this->multiPageXML ) ) {
-                       $this->multiPageXML = new SimpleXMLElement( $this->metadata );
+                       $this->initializeMultiPageXML();
                }
                $o = $this->multiPageXML->BODY[0]->OBJECT[$page-1];
                $this->height = intval( $o['height'] );
                $this->width = intval( $o['width'] );
        }
 
+       function initializeMultiPageXML() {
+               if ( $this->metadata == '0' ) {
+                       $deja = new DjVuImage( $this->imagePath );
+                       $this->metadata = $deja->retrieveMetaData();
+               }
+               $this->multiPageXML = new SimpleXMLElement( $this->metadata );
+       }
+
        /**
         * Returns 'true' if this image is a multipage document, e.g. a DJVU
         * document.
@@ -2283,7 +2291,7 @@ class Image
                        return null;
                }
                if ( ! isset( $this->multiPageXML ) ) {
-                       $this->multiPageXML = new SimpleXMLElement( $this->metadata );
+                       $this->initializeMultiPageXML();
                }
                return count( $this->multiPageXML->xpath( '//OBJECT' ) );
        }