From 1d6efbd9a559da4afc9f4c01e1ff4828de35b495 Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Wed, 5 Sep 2007 20:58:23 +0000 Subject: [PATCH] * Fix to be conform with latest changes to MediaTransformOutput * Add i18n file Patch by xaras and /me --- PdfHandler.php | 8 +++----- PdfHandler_i18n.php | 21 +++++++++++++++++++++ PdfLoader.php | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 PdfHandler_i18n.php 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; + }