* Introduce Linker::formatSize(); will do sizes from B through to GB incl.
* "largefile" renamed to "large-file" due to backwards-incompatible changes
the links in the sitenotice
* (bug 8271) Show full time and date on viewer for individual deleted
revisions
+* (bug 8214) Output file size limit and actual file size in appropriate units
+ on Special:Upload
== Languages updated ==
wfProfileOut( __METHOD__ );
return $outText;
}
+
+ /**
+ * Format a size in bytes for output, using an appropriate
+ * unit (B, KB, MB or GB) according to the magnitude in question
+ *
+ * @param $size Size to format
+ * @return string
+ */
+ public function formatSize( $size ) {
+ global $wgLang;
+ if( $size > 1024 ) {
+ $size = $size / 1024;
+ if( $size > 1024 ) {
+ $size = $size / 1024;
+ if( $size > 1024 ) {
+ $size = $size / 1024;
+ $msg = 'size-gigabytes';
+ } else {
+ $msg = 'size-megabytes';
+ }
+ } else {
+ $msg = 'size-kilobytes';
+ }
+ } else {
+ $msg = 'size-bytes';
+ }
+ $size = round( $size, 0 );
+ return wfMsgHtml( $msg, $wgLang->formatNum( $size ) );
+ }
+
}
+
?>
global $wgUploadSizeWarning;
if ( $wgUploadSizeWarning && ( $this->mUploadSize > $wgUploadSizeWarning ) ) {
- # TODO: Format $wgUploadSizeWarning to something that looks better than the raw byte
- # value, perhaps add GB,MB and KB suffixes?
- $warning .= '<li>'.wfMsgHtml( 'largefile', $wgUploadSizeWarning, $this->mUploadSize ).'</li>';
+ $skin =& $wgUser->getSkin();
+ $wsize = $skin->formatSize( $wgUploadSizeWarning );
+ $asize = $skin->formatSize( $this->mUploadSize );
+ $warning .= '<li>' . wfMsgHtml( 'large-file', $wsize, $asize ) . '</li>';
}
if ( $this->mUploadSize == 0 ) {
$warning .= '<li>'.wfMsgHtml( 'emptyfile' ).'</li>';
'illegalfilename' => 'The filename "$1" contains characters that are not allowed in page titles. Please rename the file and try uploading it again.',
'badfilename' => 'File name has been changed to "$1".',
'badfiletype' => "\".$1\" is not a recommended image file format.",
-'largefile' => 'It is recommended that files do not exceed $1 bytes in size; this file is $2 bytes',
+'large-file' => 'It is recommended that files are no larger than $1; this file is $2.',
'largefileserver' => 'This file is bigger than the server is configured to allow.',
'emptyfile' => 'The file you uploaded seems to be empty. This might be due to a typo in the file name. Please check whether you really want to upload this file.',
'fileexists' => 'A file with this name exists already, please check $1 if you are not sure if you want to change it.',
*205.188.146.144/30
*207.200.112.0/21',
+# Size units
+'size-bytes' => '$1 B',
+'size-kilobytes' => '$1 KB',
+'size-megabytes' => '$1 MB',
+'size-gigabytes' => '$1 GB',
+
);
?>