Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -557,7 +557,7 @@ |
558 | 558 | public function getUploadUrl() { |
559 | 559 | $this->loadFile(); |
560 | 560 | $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); |
561 | | - return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) ); |
| 561 | + return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) . '&wpReUpload=1' ); |
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -62,6 +62,7 @@ |
63 | 63 | $this->mDesiredDestName = $request->getText( 'wpDestFile' ); |
64 | 64 | $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' ); |
65 | 65 | $this->mComment = $request->getText( 'wpUploadDescription' ); |
| 66 | + $this->mReUpload = $request->getCheck( 'wpReUpload' ); |
66 | 67 | |
67 | 68 | if( !$request->wasPosted() ) { |
68 | 69 | # GET requests just give the main form; no data except destination |
— | — | @@ -868,6 +869,7 @@ |
869 | 870 | */ |
870 | 871 | function unsaveUploadedFile() { |
871 | 872 | global $wgOut; |
| 873 | + if( !$this->mTempPath ) return true; // nothing to delete |
872 | 874 | $repo = RepoGroup::singleton()->getLocalRepo(); |
873 | 875 | $success = $repo->freeTemp( $this->mTempPath ); |
874 | 876 | if ( ! $success ) { |
— | — | @@ -1073,7 +1075,8 @@ |
1074 | 1076 | $sourcefilename = wfMsgExt( 'sourcefilename', array( 'parseinline', 'escapenoentities' ) ); |
1075 | 1077 | $destfilename = wfMsgExt( 'destfilename', array( 'parseinline', 'escapenoentities' ) ); |
1076 | 1078 | |
1077 | | - $summary = wfMsgExt( 'fileuploadsummary', 'parseinline' ); |
| 1079 | + $msg = $this->mReUpload ? 'filereuploadsummary' : 'fileuploadsummary'; |
| 1080 | + $summary = wfMsgExt( $msg, 'parseinline' ); |
1078 | 1081 | |
1079 | 1082 | $licenses = new Licenses(); |
1080 | 1083 | $license = wfMsgExt( 'license', array( 'parseinline' ) ); |
— | — | @@ -1087,10 +1090,9 @@ |
1088 | 1091 | |
1089 | 1092 | $encDestName = htmlspecialchars( $this->mDesiredDestName ); |
1090 | 1093 | |
1091 | | - $watchChecked = $this->watchCheck() |
1092 | | - ? 'checked="checked"' |
1093 | | - : ''; |
1094 | | - $warningChecked = $this->mIgnoreWarning ? 'checked' : ''; |
| 1094 | + $watchChecked = $this->watchCheck() ? 'checked="checked"' : ''; |
| 1095 | + # Re-uploads should not need "file exist already" warnings |
| 1096 | + $warningChecked = ($this->mIgnoreWarning || $this->mReUpload) ? 'checked' : ''; |
1095 | 1097 | |
1096 | 1098 | // Prepare form for upload or upload/copy |
1097 | 1099 | if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) { |
— | — | @@ -1125,6 +1127,8 @@ |
1126 | 1128 | $warningRow = ''; |
1127 | 1129 | $destOnkeyup = ''; |
1128 | 1130 | } |
| 1131 | + # Uploading a new version? If so, the name is fixed. |
| 1132 | + $on = $this->mReUpload ? "disabled='disabled'" : ""; |
1129 | 1133 | |
1130 | 1134 | $encComment = htmlspecialchars( $this->mComment ); |
1131 | 1135 | |
— | — | @@ -1156,7 +1160,7 @@ |
1157 | 1161 | </td> |
1158 | 1162 | <td class='mw-input'> |
1159 | 1163 | <input tabindex='2' type='text' name='wpDestFile' id='wpDestFile' size='60' |
1160 | | - value=\"{$encDestName}\" onchange='toggleFilenameFiller()' $destOnkeyup /> |
| 1164 | + value=\"{$encDestName}\" onchange='toggleFilenameFiller()' $on $destOnkeyup /> |
1161 | 1165 | </td> |
1162 | 1166 | </tr> |
1163 | 1167 | <tr> |
— | — | @@ -1171,8 +1175,8 @@ |
1172 | 1176 | </tr> |
1173 | 1177 | <tr>" |
1174 | 1178 | ); |
1175 | | - |
1176 | | - if ( $licenseshtml != '' ) { |
| 1179 | + # Re-uploads should not need license info |
| 1180 | + if ( !$this->mReUpload && $licenseshtml != '' ) { |
1177 | 1181 | global $wgStylePath; |
1178 | 1182 | $wgOut->addHTML( " |
1179 | 1183 | <td class='mw-label'> |
— | — | @@ -1704,7 +1708,7 @@ |
1705 | 1709 | * @access private |
1706 | 1710 | */ |
1707 | 1711 | function cleanupTempFile() { |
1708 | | - if ( $this->mRemoveTempFile && file_exists( $this->mTempPath ) ) { |
| 1712 | + if ( $this->mRemoveTempFile && $this->mTempPath && file_exists( $this->mTempPath ) ) { |
1709 | 1713 | wfDebug( "SpecialUpload::cleanupTempFile: Removing temporary file {$this->mTempPath}\n" ); |
1710 | 1714 | unlink( $this->mTempPath ); |
1711 | 1715 | } |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1792,6 +1792,7 @@ |
1793 | 1793 | 'filename' => 'Filename', |
1794 | 1794 | 'filedesc' => 'Summary', |
1795 | 1795 | 'fileuploadsummary' => 'Summary:', |
| 1796 | +'filereuploadsummary' => 'File changes:', |
1796 | 1797 | 'filestatus' => 'Copyright status:', |
1797 | 1798 | 'filesource' => 'Source:', |
1798 | 1799 | 'uploadedfiles' => 'Uploaded files', |