diff --git a/PdfHandler.php b/PdfHandler.php index beef16f..279f094 100644 --- a/PdfHandler.php +++ b/PdfHandler.php @@ -103,10 +103,8 @@ class PdfHandler extends ImageHandler { wfMsg( 'pdf_page_error' ) ); if ( $flags & self::TRANSFORM_LATER ) - return new ThumbnailImage( $dstUrl, - $width, - $height, - $dstPath ); + return new ThumbnailImage( $image, $dstUrl, $width, + $height, $dstPath, $page ); if ( !wfMkdirParents( dirname( $dstPath ) ) ) return new MediaTransformError( 'thumbnail_error', @@ -134,7 +132,7 @@ class PdfHandler extends ImageHandler { wfHostname(), $retval, trim($err), $cmd ) ); return new MediaTransformError( 'thumbnail_error', $width, $height, $err ); } else { - return new ThumbnailImage( $dstUrl, $width, $height, $dstPath ); + return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page ); } } diff --git a/PdfHandler_i18n.php b/PdfHandler_i18n.php new file mode 100644 index 0000000..ed22e34 --- /dev/null +++ b/PdfHandler_i18n.php @@ -0,0 +1,21 @@ + array( + 'pdf_no_xml' => 'cannot get metadata from pdf', + 'pdf_page_error' => 'page number not in range', + ), + + 'de' => array( + 'pdf_no_xml' => 'Keine Metadaten im PDF vorhanden.', + 'pdf_page_error' => 'Seitenzahl außerhalb des Dokumentes.', + ), +); + + return $messages; +} diff --git a/PdfLoader.php b/PdfLoader.php index c715b65..d048b42 100644 --- a/PdfLoader.php +++ b/PdfLoader.php @@ -40,3 +40,22 @@ $wgAutoloadClasses['PdfImage'] = dirname(__FILE__) . '/PdfImage.php'; $wgAutoloadClasses['PdfHandler'] = dirname(__FILE__) . '/PdfHandler.php'; $wgMediaHandlers['application/pdf'] = 'PdfHandler'; + $wgExtensionFunctions[] = 'wfPdfHandlerLoadMessages'; + + /* load messages */ + function wfPdfHandlerLoadMessages() { + global $wgMessageCache; + static $msgLoaded = false; + + if ( $msgLoaded ) + return false; + + $msgLoaded = true; + require( dirname( __FILE__ ) . '/PdfHandler_i18n.php' ); + + foreach ( efPdfHandlerMessages() as $lang => $messagesForLang ) { + $wgMessageCache->addMessages( $messagesForLang, $lang ); + } + + return true; + }