From bbd225e01312fd56845d8fbf650aa3cd184bb731 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sat, 7 May 2011 19:34:14 +0000 Subject: [PATCH] (bug 28868) Include the number of pages in the default getLongDesc for multipaged documents This will only include the number of pages if there is at least two pages. If you have a pdf with a single page, it won't say 1 page. I modeled this on how animated images will only say x frames if x > 1. (For reference, this will affect extensions like pdfHandler, but it won't affect extensions like PagedTiffHandler since that one totally overrides the default method) --- includes/media/Generic.php | 21 ++++++++++++++++----- languages/messages/MessagesEn.php | 1 + languages/messages/MessagesQqq.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/includes/media/Generic.php b/includes/media/Generic.php index 6112140dec..547f411d41 100644 --- a/includes/media/Generic.php +++ b/includes/media/Generic.php @@ -655,11 +655,22 @@ abstract class ImageHandler extends MediaHandler { */ function getLongDesc( $file ) { global $wgLang; - return wfMsgExt('file-info-size', 'parseinline', - $wgLang->formatNum( $file->getWidth() ), - $wgLang->formatNum( $file->getHeight() ), - $wgLang->formatSize( $file->getSize() ), - $file->getMimeType() ); + $pages = $file->pageCount(); + if ( $pages === false || $pages <= 1 ) { + $msg = wfMsgExt('file-info-size', 'parseinline', + $wgLang->formatNum( $file->getWidth() ), + $wgLang->formatNum( $file->getHeight() ), + $wgLang->formatSize( $file->getSize() ), + $file->getMimeType() ); + } else { + $msg = wfMsgExt('file-info-size-pages', 'parseinline', + $wgLang->formatNum( $file->getWidth() ), + $wgLang->formatNum( $file->getHeight() ), + $wgLang->formatSize( $file->getSize() ), + $file->getMimeType(), + $wgLang->formatNum( $pages ) ); + } + return $msg; } /** diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index a7209d5750..6f91d61026 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3622,6 +3622,7 @@ By executing it, your system may be compromised.", 'widthheightpage' => '$1×$2, $3 {{PLURAL:$3|page|pages}}', 'file-info' => 'file size: $1, MIME type: $2', 'file-info-size' => '$1 × $2 pixels, file size: $3, MIME type: $4', +'file-info-size-pages' => '$1 × $2 pixels, file size: $3, MIME type: $4, $5 pages', 'file-nohires' => 'No higher resolution available.', 'svg-long-desc' => 'SVG file, nominally $1 × $2 pixels, file size: $3', 'show-big-image' => 'Full resolution', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index aff3b0b040..8f14a52d5e 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -3067,6 +3067,7 @@ The message appears after the name of the patroller.', 'widthheightpage' => 'This message is used on image pages in the dimensions column in the file history section for images with more than one page. Parameter $1 is the image width (in pixels), parameter $2 is the image height, and parameter $3 is the number of pages.', 'file-info' => 'File info displayed on file description page.', 'file-info-size' => 'File info displayed on file description page.', +'file-info-size-pages' => 'File info displayed on file description page, when the file is a multi-page document, with at least two pages. Like {{msg-mw|file-info-size}} but $5 is the total number of pages in the document.', 'file-nohires' => 'File info displayed on file description page. For example of message in use see [[:File:Mouse10.gif]].', 'svg-long-desc' => 'Displayed under an SVG image at the image description page. Note that argument 3 is a string that includes the file size unit symbol. See for example [[:File:Yes check.svg]].', 'show-big-image' => 'Displayed under an image at the image description page, when it is displayed smaller there than it was uploaded.', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index a73a425d04..714512644a 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2569,6 +2569,7 @@ $wgMessageStructure = array( 'widthheightpage', 'file-info', 'file-info-size', + 'file-info-size-pages', 'file-nohires', 'svg-long-desc', 'show-big-image', -- 2.20.1