Revision: 45963
Author:   aaron
Date:     2009-01-21 15:46:48 +0000 (Wed, 21 Jan 2009)

Log Message:
-----------
(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

Modified Paths:
--------------
    trunk/phase3/includes/ImagePage.php
    trunk/phase3/includes/specials/SpecialUpload.php
    trunk/phase3/languages/messages/MessagesEn.php

Modified: trunk/phase3/includes/ImagePage.php
===================================================================
--- trunk/phase3/includes/ImagePage.php 2009-01-21 15:13:12 UTC (rev 45962)
+++ trunk/phase3/includes/ImagePage.php 2009-01-21 15:46:48 UTC (rev 45963)
@@ -557,7 +557,7 @@
        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' );
        }
 
        /**

Modified: trunk/phase3/includes/specials/SpecialUpload.php
===================================================================
--- trunk/phase3/includes/specials/SpecialUpload.php    2009-01-21 15:13:12 UTC 
(rev 45962)
+++ trunk/phase3/includes/specials/SpecialUpload.php    2009-01-21 15:46:48 UTC 
(rev 45963)
@@ -62,6 +62,7 @@
                $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 @@
         */
        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 @@
                $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 @@
 
                $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 @@
                        $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 @@
                                </td>
                                <td class='mw-input'>
                                        <input tabindex='2' type='text' 
name='wpDestFile' id='wpDestFile' size='60'
-                                               value=\"{$encDestName}\" 
onchange='toggleFilenameFiller()' $destOnkeyup />
+                                               value=\"{$encDestName}\" 
onchange='toggleFilenameFiller()' $on $destOnkeyup />
                                </td>
                        </tr>
                        <tr>
@@ -1171,8 +1175,8 @@
                        </tr>
                        <tr>"
                );
-
-               if ( $licenseshtml != '' ) {
+               # Re-uploads should not need license info
+               if ( !$this->mReUpload && $licenseshtml != '' ) {
                        global $wgStylePath;
                        $wgOut->addHTML( "
                                        <td class='mw-label'>
@@ -1704,7 +1708,7 @@
         * @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 );
                }

Modified: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php      2009-01-21 15:13:12 UTC 
(rev 45962)
+++ trunk/phase3/languages/messages/MessagesEn.php      2009-01-21 15:46:48 UTC 
(rev 45963)
@@ -1792,6 +1792,7 @@
 'filename'                    => 'Filename',
 'filedesc'                    => 'Summary',
 'fileuploadsummary'           => 'Summary:',
+'filereuploadsummary'         => 'File changes:',
 'filestatus'                  => 'Copyright status:',
 'filesource'                  => 'Source:',
 'uploadedfiles'               => 'Uploaded files',



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to