diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
commit | 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch) | |
tree | af68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /includes/media/DjVuImage.php | |
parent | af4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff) |
Update to MediaWiki 1.22.0
Diffstat (limited to 'includes/media/DjVuImage.php')
-rw-r--r-- | includes/media/DjVuImage.php | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php index 46989668..54efe7a8 100644 --- a/includes/media/DjVuImage.php +++ b/includes/media/DjVuImage.php @@ -64,7 +64,7 @@ class DjVuImage { public function getImageSize() { $data = $this->getInfo(); - if( $data !== false ) { + if ( $data !== false ) { $width = $data['width']; $height = $data['height']; @@ -93,20 +93,20 @@ class DjVuImage { $start = ftell( $file ); $secondary = fread( $file, 4 ); echo str_repeat( ' ', $indent * 4 ) . "($secondary)\n"; - while( ftell( $file ) - $start < $length ) { + while ( ftell( $file ) - $start < $length ) { $chunkHeader = fread( $file, 8 ); - if( $chunkHeader == '' ) { + if ( $chunkHeader == '' ) { break; } // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. extract( unpack( 'a4chunk/NchunkLength', $chunkHeader ) ); echo str_repeat( ' ', $indent * 4 ) . "$chunk $chunkLength\n"; - if( $chunk == 'FORM' ) { + if ( $chunk == 'FORM' ) { $this->dumpForm( $file, $chunkLength, $indent + 1 ); } else { fseek( $file, $chunkLength, SEEK_CUR ); - if( $chunkLength & 1 == 1 ) { + if ( $chunkLength & 1 == 1 ) { // Padding byte between chunks fseek( $file, 1, SEEK_CUR ); } @@ -118,7 +118,7 @@ class DjVuImage { wfSuppressWarnings(); $file = fopen( $this->mFilename, 'rb' ); wfRestoreWarnings(); - if( $file === false ) { + if ( $file === false ) { wfDebug( __METHOD__ . ": missing or failed file read\n" ); return false; } @@ -126,21 +126,21 @@ class DjVuImage { $header = fread( $file, 16 ); $info = false; - if( strlen( $header ) < 16 ) { + if ( strlen( $header ) < 16 ) { wfDebug( __METHOD__ . ": too short file header\n" ); } else { // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. extract( unpack( 'a4magic/a4form/NformLength/a4subtype', $header ) ); - if( $magic != 'AT&T' ) { + if ( $magic != 'AT&T' ) { wfDebug( __METHOD__ . ": not a DjVu file\n" ); - } elseif( $subtype == 'DJVU' ) { + } elseif ( $subtype == 'DJVU' ) { // Single-page document $info = $this->getPageInfo( $file, $formLength ); - } elseif( $subtype == 'DJVM' ) { + } elseif ( $subtype == 'DJVM' ) { // Multi-page document $info = $this->getMultiPageInfo( $file, $formLength ); - } else { + } else { wfDebug( __METHOD__ . ": unrecognized DJVU file type '$formType'\n" ); } } @@ -150,7 +150,7 @@ class DjVuImage { private function readChunk( $file ) { $header = fread( $file, 8 ); - if( strlen( $header ) < 8 ) { + if ( strlen( $header ) < 8 ) { return array( false, 0 ); } else { // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. @@ -162,7 +162,7 @@ class DjVuImage { private function skipChunk( $file, $chunkLength ) { fseek( $file, $chunkLength, SEEK_CUR ); - if( $chunkLength & 0x01 == 1 && !feof( $file ) ) { + if ( $chunkLength & 0x01 == 1 && !feof( $file ) ) { // padding byte fseek( $file, 1, SEEK_CUR ); } @@ -174,13 +174,13 @@ class DjVuImage { $start = ftell( $file ); do { list( $chunk, $length ) = $this->readChunk( $file ); - if( !$chunk ) { + if ( !$chunk ) { break; } - if( $chunk == 'FORM' ) { + if ( $chunk == 'FORM' ) { $subtype = fread( $file, 4 ); - if( $subtype == 'DJVU' ) { + if ( $subtype == 'DJVU' ) { wfDebug( __METHOD__ . ": found first subpage\n" ); return $this->getPageInfo( $file, $length ); } @@ -189,7 +189,7 @@ class DjVuImage { wfDebug( __METHOD__ . ": skipping '$chunk' chunk\n" ); $this->skipChunk( $file, $length ); } - } while( $length != 0 && !feof( $file ) && ftell( $file ) - $start < $formLength ); + } while ( $length != 0 && !feof( $file ) && ftell( $file ) - $start < $formLength ); wfDebug( __METHOD__ . ": multi-page DJVU file contained no pages\n" ); return false; @@ -197,17 +197,17 @@ class DjVuImage { private function getPageInfo( $file, $formLength ) { list( $chunk, $length ) = $this->readChunk( $file ); - if( $chunk != 'INFO' ) { + if ( $chunk != 'INFO' ) { wfDebug( __METHOD__ . ": expected INFO chunk, got '$chunk'\n" ); return false; } - if( $length < 9 ) { + if ( $length < 9 ) { wfDebug( __METHOD__ . ": INFO should be 9 or 10 bytes, found $length\n" ); return false; } $data = fread( $file, $length ); - if( strlen( $data ) < $length ) { + if ( strlen( $data ) < $length ) { wfDebug( __METHOD__ . ": INFO chunk cut off\n" ); return false; } @@ -263,7 +263,7 @@ class DjVuImage { $retval = ''; $txt = wfShellExec( $cmd, $retval, array(), array( 'memory' => self::DJVUTXT_MEMORY_LIMIT ) ); wfProfileOut( 'djvutxt' ); - if( $retval == 0) { + if ( $retval == 0 ) { # Strip some control characters $txt = preg_replace( "/[\013\035\037]/", "", $txt ); $reg = <<<EOR @@ -280,7 +280,7 @@ EOR; $txt = preg_replace_callback( $reg, array( $this, 'pageTextCallback' ), $txt ); $txt = "<DjVuTxt>\n<HEAD></HEAD>\n<BODY>\n" . $txt . "</BODY>\n</DjVuTxt>\n"; $xml = preg_replace( "/<DjVuXML>/", "<mw-djvu><DjVuXML>", $xml, 1 ); - $xml = $xml . $txt. '</mw-djvu>'; + $xml = $xml . $txt . '</mw-djvu>'; } } wfProfileOut( __METHOD__ ); |