* (bug 7782) Standardisation of file info at image description pages.
authorRaimond Spekking <raymond@users.mediawiki.org>
Tue, 27 Feb 2007 18:27:11 +0000 (18:27 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Tue, 27 Feb 2007 18:27:11 +0000 (18:27 +0000)
* tweak formatSize/Linker.php for smarter output of big numbers
* RELEASE-NOTES forgotten in r20044

RELEASE-NOTES
includes/ImagePage.php
includes/Linker.php
languages/messages/MessagesDe.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index dda9d37..546803a 100644 (file)
@@ -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 ==
 
index bfdaa93..b8403ad 100644 (file)
@@ -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}</a>";
+                                               $anchorclose .= wfMsg('show-big-image-thumb', $width, $height ) .
+                                                       '<br />' . "\n$anchoropen{$msgbig}</a> " . $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') . '<br />';
+                                       $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( <<<END
-<div class="fullMedia">
+<div class="fullMedia">$infores
 <span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
-<span class="fileInfo"> ($info)</span>
+<span class="fileInfo"> $info</span>
 </div>
 
 <div class="mediaWarning">$warning</div>
@@ -333,8 +347,8 @@ END
                                                );
                                } else {
                                        $wgOut->addWikiText( <<<END
-<div class="fullMedia">
-[[Media:$filename|$filename]]$dirmark <span class="fileInfo"> ($info)</span>
+<div class="fullMedia">$infores
+[[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $info</span>
 </div>
 END
                                                );
index 1a2f216..5662252 100644 (file)
@@ -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 ) );
        }
 
index 0802698..feae20b 100644 (file)
@@ -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.<hr />",
-
-'fileinfo' => '$1 kB, MIME Typ: <code>$2</code>',
+# 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.<hr />",
+'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'          => '<small>Keine höhere Auflösung vorhanden.</small>',
+'show-big-image'        => 'Version in höherer Auflösung',
+'show-big-image-thumb'  => '<small>Größe der Voransicht: $1 × $2 Pixel</small>',
 
 # Metadata
 'metadata'          => 'Metadaten',
index 716817a..59b327a 100644 (file)
@@ -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.<hr />",
+'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'          => '<small>No higher resolution available.</small>',
+'show-big-image'        => 'Image in higher resolution',
+'show-big-image-thumb'  => '<small>Size of this preview: $1 × $2 pixel</small>',
 
 '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.<hr />',
-
-'fileinfo' => '$1KB, MIME type: <code>$2</code>',
-
 # 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.',
index ce39cea..09a57b4 100644 (file)
@@ -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',