r48881 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48880‎ | r48881 | r48882 >
Date:15:11, 26 March 2009
Author:ashley
Status:deferred
Tags:
Comment:
MultiUpload: don't display a (nearly-)blank page if the button was pressed but no files were given. Code by Bartek Łapiński for Wikia (see http://trac.wikia-code.com/changeset/7357)
Modified paths:
  • /trunk/extensions/MultiUpload/SpecialMultipleUpload.body.php (modified) (history)
  • /trunk/extensions/MultiUpload/SpecialMultipleUpload.i18n.php (modified) (history)
  • /trunk/extensions/MultiUpload/SpecialMultipleUpload.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MultiUpload/SpecialMultipleUpload.body.php
@@ -116,32 +116,41 @@
117117 function processUpload() {
118118 global $wgMaxUploadFiles, $wgOut;
119119
120 - $wgOut->addHTML("<table>");
 120+ $images = 0;
 121+ $wgOut->addHTML( '<table>' );
121122 $this->mShowUploadForm = false;
122123 for( $x = 0; $x < $wgMaxUploadFiles; $x++ ) {
123124 $this->mFileIndex = $x;
124125 if( !isset( $this->mUploadTempNameArray[$x] ) || $this->mUploadTempNameArray[$x] == null ) continue;
125126
 127+ $images++;
126128 $this->mTempPath = $this->mUploadTempNameArray[$x];
127129 $this->mFileSize = $this->mUploadSizeArray[$x];
128130 $this->mSrcName = $this->mOnameArray[$x]; // for mw > 1.9
129131 $this->mRemoveTempFile = true;
130132 $this->mIgnoreWarning = true;
131133
132 - $this->mUploadError = $this->mUploadErrorArray [$x];
133 - $this->mDesiredDestName = $this->mDestFileArray [$x];
134 - $this->mComment = $this->mUploadDescriptionArray [$x];
135 - $wgOut->addHTML("<tr><td>");
 134+ $this->mUploadError = $this->mUploadErrorArray[$x];
 135+ $this->mDesiredDestName = $this->mDestFileArray[$x];
 136+ $this->mComment = $this->mUploadDescriptionArray[$x];
 137+ $wgOut->addHTML( '<tr><td>' );
136138 parent::processUpload();
137 - $wgOut->addHTML("</td></tr>");
 139+ $wgOut->addHTML( '</td></tr>' );
138140 }
139141
140 - $wgOut->addHTML("</table>");
141 - $this->mShowUploadForm = false;
142 - $wgOut->redirect(''); // clear the redirect, we want to show a nice page of images
143 - $this->mShowUploadForm = true;
144 - if( $this->mHasWarning ) {
145 - $this->showWarningOptions();
 142+ $wgOut->addHTML( '</table>' );
 143+ // Display a form again with a warning if we gave no files, instead of a blank screen
 144+ if( 0 == $images ) {
 145+ $this->mShowUploadForm = true;
 146+ $this->mUploadSaveName = wfMsg( 'multiupload-blank' );
 147+ $this->mainUploadForm( wfMsg( 'multiupload-no-files' ) );
 148+ } else {
 149+ $this->mShowUploadForm = false;
 150+ $wgOut->redirect(''); // clear the redirect, we want to show a nice page of images
 151+ $this->mShowUploadForm = true;
 152+ if( $this->mHasWarning ) {
 153+ $this->showWarningOptions();
 154+ }
146155 }
147156 }
148157
Index: trunk/extensions/MultiUpload/SpecialMultipleUpload.i18n.php
@@ -28,6 +28,8 @@
2929 Inappropriate files will be deleted immediately, see the [[{{MediaWiki:Multipleupload-page}}|file deletion policy]].",
3030 'multiupload-fileuploaded' => 'File uploaded.',
3131 'multiupload-toolbox' => 'Upload multiple files',
 32+ 'multiupload-no-files' => 'Please select at least one file to upload',
 33+ 'multiupload-blank' => 'No file selected',
3234 );
3335
3436 /** Message documentation (Message documentation)
Index: trunk/extensions/MultiUpload/SpecialMultipleUpload.php
@@ -19,7 +19,7 @@
2020 $wgExtensionCredits['specialpage'][] = array(
2121 'name' => 'MultipleUpload',
2222 'author' => 'Travis Derouin',
23 - 'version' => '1.0',
 23+ 'version' => '1.01',
2424 'description' => 'Allows users to upload several files at once.',
2525 'descriptionmsg' => 'multipleupload-desc',
2626 'url' => 'http://www.mediawiki.org/wiki/Extension:MultiUpload',

Status & tagging log