update metadata for old images, ignore page= if no djvu renderer has been supplied
authorJens Frank <jeluf@users.mediawiki.org>
Sun, 27 Aug 2006 18:36:54 +0000 (18:36 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Sun, 27 Aug 2006 18:36:54 +0000 (18:36 +0000)
includes/Image.php
includes/Parser.php

index f329fed..2596036 100644 (file)
@@ -2265,9 +2265,22 @@ class Image
        }
 
        function initializeMultiPageXML() {
+               #
+               # Check for files uploaded prior to DJVU support activation
+               # They have a '0' in their metadata field.
+               #
                if ( $this->metadata == '0' ) {
                        $deja = new DjVuImage( $this->imagePath );
                        $this->metadata = $deja->retrieveMetaData();
+                       $this->purgeMetadataCache();
+
+                       # Update metadata in the database
+                       $dbw =& wfGetDB( DB_MASTER );
+                       $dbw->update( 'image',
+                               array( 'img_metadata' => $this->metadata ),
+                               array( 'img_name' => $this->name ),
+                               __METHOD__
+                       );
                }
                $this->multiPageXML = new SimpleXMLElement( $this->metadata );
        }
index 56b4ccb..5692387 100644 (file)
@@ -4153,7 +4153,7 @@ class Parser
         * Parse image options text and use it to make an image
         */
        function makeImage( &$nt, $options ) {
-               global $wgUseImageResize;
+               global $wgUseImageResize, $wgDjvuRenderer;
 
                $align = '';
 
@@ -4203,7 +4203,8 @@ class Parser
                        } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
                                # remember to set an alignment, don't render immediately
                                $align = 'none';
-                       } elseif ( ! is_null( $match = $mwPage->matchVariableStartToEnd($val) ) ) {
+                       } elseif ( isset( $wgDjvuRenderer ) && $wgDjvuRenderer
+                                  && ! is_null( $match = $mwPage->matchVariableStartToEnd($val) ) ) {
                                # Select a page in a multipage document
                                $page = $match;
                        } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {