From c97d076ed177a77a9b9617e872b3009545b1d308 Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Tue, 27 Feb 2007 18:27:11 +0000 Subject: [PATCH] * (bug 7782) Standardisation of file info at image description pages. * tweak formatSize/Linker.php for smarter output of big numbers * RELEASE-NOTES forgotten in r20044 --- RELEASE-NOTES | 2 ++ includes/ImagePage.php | 42 ++++++++++++++++++++----------- includes/Linker.php | 6 ++++- languages/messages/MessagesDe.php | 18 +++++++------ languages/messages/MessagesEn.php | 19 +++++++------- maintenance/language/messages.inc | 21 +++++++--------- 6 files changed, 64 insertions(+), 44 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index dda9d37f90..546803a77f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -231,6 +231,7 @@ lighter making things easier to read. * Have a checkered background on images on the description pages and in galeries to make transparency visible (just MonoBook for now, will add the rest soon). +* (bug 7782) Standardisation of file info at image description pages. == Languages updated == @@ -268,6 +269,7 @@ lighter making things easier to read. * Slovak (sk) * Swedish (sv) * Zealandic (zea) +* Cantonese (zh-yue) == Compatibility == diff --git a/includes/ImagePage.php b/includes/ImagePage.php index bfdaa93999..b8403ad39e 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -195,16 +195,19 @@ class ImagePage extends Article { } else { $page = 1; } - $width = $this->img->getWidth(); - $height = $this->img->getHeight(); + $width_orig = $this->img->getWidth(); + $width = $width_orig; + $height_orig = $this->img->getHeight(); + $height = $height_orig; + $mime = $this->img->getMimeType(); $showLink = false; if ( $this->img->allowInlineDisplay() and $width and $height) { # image # "Download high res version" link below the image - $msg = wfMsgHtml('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) ); - + $msgbig = wfMsgHtml('show-big-image'); + $msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->getSize() ), $mime ); # We'll show a thumbnail of this image if ( $width > $maxWidth || $height > $maxHeight ) { # Calculate the thumbnail size. @@ -238,7 +241,8 @@ class ImagePage extends Article { if( $this->img->mustRender() ) { $showLink = true; } else { - $anchorclose .= "\n$anchoropen{$msg}"; + $anchorclose .= wfMsg('show-big-image-thumb', $width, $height ) . + '
' . "\n$anchoropen{$msgbig} " . $msgsize; } } else { $url = $this->img->getViewURL(); @@ -311,21 +315,31 @@ class ImagePage extends Article { // Hacky workaround: for some reason we use the incorrect MIME type // image/svg for SVG. This should be fixed internally, but at least // make the displayed type right. - $mime = $this->img->getMimeType(); if ($mime == 'image/svg') $mime = 'image/svg+xml'; - - $info = wfMsg( 'fileinfo', - ceil($this->img->getSize()/1024.0), - $mime ); + // Check for MIME type. Other types may have more information in the future. + $infores = ''; + if ( substr($mime,0,5) == 'image' ) { + $infores = wfMsg('file-nohires') . '
'; + $info = wfMsg( + 'file-info-size', + $width_orig, $height_orig, + $sk->formatSize( $this->img->getSize() ), + $mime ); + } else { + $info = wfMsg( + 'file-info', + $sk->formatSize( $this->img->getSize() ), + $mime ); + } global $wgContLang; $dirmark = $wgContLang->getDirMark(); if (!$this->img->isSafeFile()) { $warning = wfMsg( 'mediawarning' ); $wgOut->addWikiText( << +
$infores [[Media:$filename|$filename]]$dirmark - ($info) + $info
$warning
@@ -333,8 +347,8 @@ END ); } else { $wgOut->addWikiText( << -[[Media:$filename|$filename]]$dirmark ($info) +
$infores +[[Media:$filename|$filename]]$dirmark $info
END ); diff --git a/includes/Linker.php b/includes/Linker.php index 1a2f216c44..56622529e1 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1197,10 +1197,14 @@ class Linker { */ public function formatSize( $size ) { global $wgLang; + // For small sizes no decimal places necessary + $round = 0; if( $size > 1024 ) { $size = $size / 1024; if( $size > 1024 ) { $size = $size / 1024; + // For MB and bigger two decimal places are smarter + $round = 2; if( $size > 1024 ) { $size = $size / 1024; $msg = 'size-gigabytes'; @@ -1213,7 +1217,7 @@ class Linker { } else { $msg = 'size-bytes'; } - $size = round( $size, 0 ); + $size = round( $size, $round ); return wfMsgHtml( $msg, $wgLang->formatNum( $size ) ); } diff --git a/languages/messages/MessagesDe.php b/languages/messages/MessagesDe.php index 08026984cf..feae20b744 100644 --- a/languages/messages/MessagesDe.php +++ b/languages/messages/MessagesDe.php @@ -1814,10 +1814,6 @@ Alle Transwiki Import-Aktionen werden im [[Special:Log/import|Import-Logbuch]] p 'previousdiff' => '← Zum vorherigen Versionsunterschied', 'nextdiff' => 'Zum nächsten Versionsunterschied →', -'imagemaxsize' => 'Maximale Bildgröße auf Bildbeschreibungsseiten:', -'thumbsize' => 'Standardgröße der Vorschaubilder (thumbnails):', -'showbigimage' => 'Version mit hoher Auflösung herunterladen ($1 x $2 Pixel, $3 kB)', - 'newimages' => 'Neue Dateien', 'newimages-summary' => 'Diese Spezialseite zeigt die zuletzt hochgeladenen Bilder und Dateien an.', 'showhidebots' => '(Bots $1)', @@ -1854,10 +1850,16 @@ Variants for Chinese language 'passwordtooshort' => 'Das Passwort ist zu kurz. Es muss mindestens $1 Zeichen lang sein.', -# Media Warning -'mediawarning' => "'''Warnung:''' Diese Art von Datei kann böswilligen Programmcode enthalten. Durch das Herunterladen oder Öffnen der Datei kann Ihr Computer beschädigt werden.
", - -'fileinfo' => '$1 kB, MIME Typ: $2', +# Media-info +'mediawarning' => "'''Warnung:''' Diese Art von Datei kann böswilligen Programmcode enthalten. Durch das Herunterladen und Öffnen der Datei kann Ihr Computer beschädigt werden.
", +'imagemaxsize' => 'Maximale Bildgröße auf Bildbeschreibungsseiten:', +'thumbsize' => 'Standardgröße der Vorschaubilder (thumbnails):', +'widthheight' => '$1×$2', +'file-info' => 'Dateigröße: $1, MIME-Typ: $2', +'file-info-size' => '($1 × $2 Pixel, Dateigröße: $3, MIME-Typ: $4)', +'file-nohires' => 'Keine höhere Auflösung vorhanden.', +'show-big-image' => 'Version in höherer Auflösung', +'show-big-image-thumb' => 'Größe der Voransicht: $1 × $2 Pixel', # Metadata 'metadata' => 'Metadaten', diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 716817a407..59b327a659 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -674,7 +674,6 @@ parent class in order maintain consistency across languages. 'versionrequired' => 'Version $1 of MediaWiki required', 'versionrequiredtext' => 'Version $1 of MediaWiki is required to use this page. See [[Special:Version|version page]].', -'widthheight' => '$1×$2', 'ok' => 'OK', 'sitetitle' => '{{SITENAME}}', 'pagetitle' => '$1 - {{SITENAME}}', @@ -2278,9 +2277,16 @@ All transwiki import actions are logged at the [[Special:Log/import|import log]] 'previousdiff' => '← Previous diff', 'nextdiff' => 'Next diff →', -'imagemaxsize' => 'Limit images on image description pages to:', -'thumbsize' => 'Thumbnail size:', -'showbigimage' => 'Download high resolution version ($1x$2, $3 KB)', +# media-info +'mediawarning' => "'''Warning''': This file may contain malicious code, by executing it your system may be compromised.
", +'imagemaxsize' => 'Limit images on image description pages to:', +'thumbsize' => 'Thumbnail size:', +'widthheight' => '$1×$2', +'file-info' => 'File size: $1, MIME type: $2', +'file-info-size' => '($1 × $2 pixel, file size: $3, MIME type: $4)', +'file-nohires' => 'No higher resolution available.', +'show-big-image' => 'Image in higher resolution', +'show-big-image-thumb' => 'Size of this preview: $1 × $2 pixel', 'newimages' => 'Gallery of new files', 'newimages-summary' => '', @@ -2313,11 +2319,6 @@ All transwiki import actions are logged at the [[Special:Log/import|import log]] 'passwordtooshort' => 'Your password is too short. It must have at least $1 characters.', -# Media Warning -'mediawarning' => '\'\'\'Warning\'\'\': This file may contain malicious code, by executing it your system may be compromised.
', - -'fileinfo' => '$1KB, MIME type: $2', - # Metadata 'metadata' => 'Metadata', 'metadata-help' => 'This file contains additional information, probably added from the digital camera or scanner used to create or digitize it. If the file has been modified from its original state, some details may not fully reflect the modified image.', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index ce39cea726..09a57b4477 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -237,7 +237,6 @@ $wgMessageStructure = array( 'versionrequiredtext', ), 'miscellaneous3' => array( - 'widthheight', 'ok', 'sitetitle', 'pagetitle', @@ -1546,10 +1545,16 @@ $wgMessageStructure = array( 'previousdiff', 'nextdiff', ), - 'imagesize' => array( + 'media-info' => array( + 'mediawarning', 'imagemaxsize', 'thumbsize', - 'showbigimage', + 'widthheight', + 'file-info', + 'file-info-size', + 'file-nohires', + 'show-big-image', + 'show-big-image-thumb', ), 'newimages' => array( 'newimages', @@ -1584,12 +1589,6 @@ $wgMessageStructure = array( 'passwordtooshort' => array( 'passwordtooshort', ), - 'mediawarning' => array( - 'mediawarning', - ), - 'fileinfo' => array( - 'fileinfo', - ), 'metadata' => array( 'metadata', 'metadata-help', @@ -2120,7 +2119,6 @@ XHTML id names.", 'patrol-log' => 'Patrol log', 'imagedeletion' => 'Image deletion', 'browsediffs' => 'Browsing diffs', - 'imagesize' => '', 'newimages' => '', 'variantname-zh' => "Short names for language variants used for language conversion links. To disable showing a particular link, set it to 'disable', e.g. @@ -2130,8 +2128,7 @@ Variants for Chinese language", 'variantname-kk' => 'Variants for Kazakh language', 'specialloglabels' => 'Labels for User: and Title: on Special:Log pages', 'passwordtooshort' => '', - 'mediawarning' => 'Media Warning', - 'fileinfo' => '', + 'media-info' => 'Media information', 'metadata' => 'Metadata', 'exif' => 'EXIF tags', 'exif-values' => 'Make & model, can be wikified in order to link to the camera and model name', -- 2.20.1