From e56b96288675d15c5d3d89f0c33a4a5b9cec339a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 21 Jan 2009 15:46:48 +0000 Subject: [PATCH] (bug 15811) Re-upload form tweaks * Don't show license dropdown * Use different message for summary box label * Don't show "file exists" message * Lock the destination name --- includes/ImagePage.php | 2 +- includes/specials/SpecialUpload.php | 22 +++++++++++++--------- languages/messages/MessagesEn.php | 1 + 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 314d478e11..e70e11160b 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -557,7 +557,7 @@ EOT public function getUploadUrl() { $this->loadFile(); $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); - return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) ); + return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) . '&wpReUpload=1' ); } /** diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index bfbc290477..60ebb88ecf 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -62,6 +62,7 @@ class UploadForm { $this->mDesiredDestName = $request->getText( 'wpDestFile' ); $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' ); $this->mComment = $request->getText( 'wpUploadDescription' ); + $this->mReUpload = $request->getCheck( 'wpReUpload' ); if( !$request->wasPosted() ) { # GET requests just give the main form; no data except destination @@ -868,6 +869,7 @@ class UploadForm { */ function unsaveUploadedFile() { global $wgOut; + if( !$this->mTempPath ) return true; // nothing to delete $repo = RepoGroup::singleton()->getLocalRepo(); $success = $repo->freeTemp( $this->mTempPath ); if ( ! $success ) { @@ -1073,7 +1075,8 @@ wgUploadAutoFill = {$autofill}; $sourcefilename = wfMsgExt( 'sourcefilename', array( 'parseinline', 'escapenoentities' ) ); $destfilename = wfMsgExt( 'destfilename', array( 'parseinline', 'escapenoentities' ) ); - $summary = wfMsgExt( 'fileuploadsummary', 'parseinline' ); + $msg = $this->mReUpload ? 'filereuploadsummary' : 'fileuploadsummary'; + $summary = wfMsgExt( $msg, 'parseinline' ); $licenses = new Licenses(); $license = wfMsgExt( 'license', array( 'parseinline' ) ); @@ -1087,10 +1090,9 @@ wgUploadAutoFill = {$autofill}; $encDestName = htmlspecialchars( $this->mDesiredDestName ); - $watchChecked = $this->watchCheck() - ? 'checked="checked"' - : ''; - $warningChecked = $this->mIgnoreWarning ? 'checked' : ''; + $watchChecked = $this->watchCheck() ? 'checked="checked"' : ''; + # Re-uploads should not need "file exist already" warnings + $warningChecked = ($this->mIgnoreWarning || $this->mReUpload) ? 'checked' : ''; // Prepare form for upload or upload/copy if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) { @@ -1125,6 +1127,8 @@ wgUploadAutoFill = {$autofill}; $warningRow = ''; $destOnkeyup = ''; } + # Uploading a new version? If so, the name is fixed. + $on = $this->mReUpload ? "disabled='disabled'" : ""; $encComment = htmlspecialchars( $this->mComment ); @@ -1156,7 +1160,7 @@ wgUploadAutoFill = {$autofill}; + value=\"{$encDestName}\" onchange='toggleFilenameFiller()' $on $destOnkeyup /> @@ -1171,8 +1175,8 @@ wgUploadAutoFill = {$autofill}; " ); - - if ( $licenseshtml != '' ) { + # Re-uploads should not need license info + if ( !$this->mReUpload && $licenseshtml != '' ) { global $wgStylePath; $wgOut->addHTML( " @@ -1704,7 +1708,7 @@ wgUploadAutoFill = {$autofill}; * @access private */ function cleanupTempFile() { - if ( $this->mRemoveTempFile && file_exists( $this->mTempPath ) ) { + if ( $this->mRemoveTempFile && $this->mTempPath && file_exists( $this->mTempPath ) ) { wfDebug( "SpecialUpload::cleanupTempFile: Removing temporary file {$this->mTempPath}\n" ); unlink( $this->mTempPath ); } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 69e9cdbbd8..b624c218d0 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1792,6 +1792,7 @@ See the [[Special:NewFiles|gallery of new files]] for a more visual overview.', 'filename' => 'Filename', 'filedesc' => 'Summary', 'fileuploadsummary' => 'Summary:', +'filereuploadsummary' => 'File changes:', 'filestatus' => 'Copyright status:', 'filesource' => 'Source:', 'uploadedfiles' => 'Uploaded files', -- 2.20.1