* (bug 13490) Show upload/file size limit on upload form
authorRaimond Spekking <raymond@users.mediawiki.org>
Thu, 27 Mar 2008 18:34:27 +0000 (18:34 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Thu, 27 Mar 2008 18:34:27 +0000 (18:34 +0000)
RELEASE-NOTES
includes/SpecialUpload.php
languages/messages/MessagesDe.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index e5c6b8f..83544c0 100644 (file)
@@ -56,7 +56,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 9447) Added hooks for search result headings
 * Image redirects are now enabled
 * (bug 13450) Email confirmation can now be canceled before the expiration
-
+* (bug 13490) Show upload/file size limit on upload form
 
 === Bug fixes in 1.13 ===
 
index b2017bc..3c6d2f6 100644 (file)
@@ -890,7 +890,7 @@ class UploadForm {
         * @access private
         */
        function mainUploadForm( $msg='' ) {
-               global $wgOut, $wgUser;
+               global $wgOut, $wgUser, $wgLang, $wgMaxUploadSize;
                global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
                global $wgRequest, $wgAllowCopyUploads;
                global $wgStylePath, $wgStyleVersion;
@@ -980,6 +980,26 @@ wgUploadAutoFill = {$autofill};
                        }
                }
 
+               # Get the maximum file size from php.ini as $wgMaxUploadSize works for uploads from URL via CURL only
+               # See http://de.php.net/manual/en/ini.core.php#ini.upload-max-filesize for possible values of upload_max_filesize
+               $val = trim( ini_get( 'upload_max_filesize' ) );
+               $last = ( substr( $val, -1 ) );
+               switch( $last ) {
+                       case 'G':
+                               $val2 = substr( $val, 0, -1 ) * 1024 * 1024 * 1024;
+                               break;
+                       case 'M':
+                               $val2 = substr( $val, 0, -1 ) * 1024 * 1024;
+                               break;
+                       case 'K':
+                               $val2 = substr( $val, 0, -1 ) * 1024;
+                               break;
+                       default:
+                               $val2 = $val;
+               }
+               $val2 = $wgAllowCopyUploads ? min( $wgMaxUploadSize, $val2 ) : $val2;
+               $maxUploadSize = wfMsgExt( 'upload-maxfilesize', 'parseinline', $wgLang->formatSize( $val2 ) );
+
                $sourcefilename = wfMsgExt( 'sourcefilename', 'escapenoentities' );
                $destfilename = wfMsgExt( 'destfilename', 'escapenoentities' );
                $summary = wfMsgExt( 'fileuploadsummary', 'parseinline' );
@@ -1057,6 +1077,7 @@ wgUploadAutoFill = {$autofill};
                        <tr>
                                <td></td>
                                <td>
+                                       {$maxUploadSize}
                                        {$extensionsList}
                                </td>
                        </tr>
index e0e474a..983616b 100644 (file)
@@ -1161,6 +1161,7 @@ Bitte prüfe, ob du das Bild in voller Auflösung vorliegen hast und lade dieses
 'uploadvirus'                 => 'Diese Datei enthält einen Virus! Details: $1',
 'sourcefilename'              => 'Quelldatei:',
 'destfilename'                => 'Zielname:',
+'upload-maxfilesize'          => 'Maximale Dateigröße: $1',
 'watchthisupload'             => 'Diese Seite beobachten',
 'filewasdeleted'              => 'Eine Datei mit diesem Namen wurde schon einmal hochgeladen und zwischenzeitlich wieder gelöscht. Bitte prüfe zuerst den Eintrag im $1, bevor du die Datei wirklich speicherst.',
 'upload-wasdeleted'           => "'''Achtung: Du lädst eine Datei hoch, die bereits früher gelöscht wurde.'''
index 4e9c95f..ad7f27c 100644 (file)
@@ -1496,6 +1496,7 @@ If you have this image in full resolution upload this one, otherwise change the
 'uploadvirus'                 => 'The file contains a virus! Details: $1',
 'sourcefilename'              => 'Source filename:',
 'destfilename'                => 'Destination filename:',
+'upload-maxfilesize'          => 'Maximum file size: $1',
 'watchthisupload'             => 'Watch this page',
 'filewasdeleted'              => 'A file of this name has been previously uploaded and subsequently deleted. You should check the $1 before proceeding to upload it again.',
 'upload-wasdeleted'           => "'''Warning: You are uploading a file that was previously deleted.'''
index 6e0f40c..e085824 100644 (file)
@@ -906,6 +906,7 @@ $wgMessageStructure = array(
                'uploadvirus',
                'sourcefilename',
                'destfilename',
+               'upload-maxfilesize',
                'watchthisupload',
                'filewasdeleted',
                'upload-wasdeleted',