From 898e7c153a078a4e6cc0ba5347b3fe51e1676feb Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Thu, 31 Aug 2006 09:50:46 +0000 Subject: [PATCH] Improved form for URL-based upload --- RELEASE-NOTES | 2 +- includes/SpecialUpload.php | 33 ++++++++++++++++++++++----------- languages/MessagesEn.php | 3 ++- skins/common/wikibits.js | 18 ++++++++++++++++-- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c79926ca57..d1b4810e50 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -157,7 +157,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Pass page title as parameters to "linkshere" and "nolinkshere" and update default message text * Allows to upload from publicy accessible URL. Set $wgAllowCopyUploads = true ; in LocalSettings.php - Limited to $wgMaxUploadSize (default:100MB); URL upload is limited to sysops by default + Limited to $wgMaxUploadSize (default:100MB); URL upload is limited to sysops by default, and displayed as a second line if appropriate * (bug 832) Return to user page after emailing a user * (bug 366) Add local-system-timezone equivalents for date/time variables * (bug 7109) Fix Atom feed version number in header links diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index b6301f1ff8..0330bb09ca 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -56,7 +56,7 @@ class UploadForm { $this->mUploadCopyStatus = $request->getText( 'wpUploadCopyStatus' ); $this->mUploadSource = $request->getText( 'wpUploadSource' ); $this->mWatchthis = $request->getBool( 'wpWatchthis' ); - $this->mSourceType = $request->getBool( 'wpSourceType' ); + $this->mSourceType = $request->getText( 'wpSourceType' ); wfDebug( "UploadForm: watchthis is: '$this->mWatchthis'\n" ); $this->mAction = $request->getVal( 'action' ); @@ -109,7 +109,7 @@ class UploadForm { */ function initializeFromUrl( $request ) { global $wgTmpDirectory, $wgMaxUploadSize; - $url = $request->getText( 'wpUploadFile' ); + $url = $request->getText( 'wpUploadFileURL' ); $local_file = tempnam( $wgTmpDirectory, 'WEBUPLOAD' ); $this->mUploadTempName = $local_file; @@ -137,7 +137,7 @@ class UploadForm { # Maybe remove some pasting blanks :-) $url = strtolower( trim( $url ) ); - if( substr( $u, 0, 7 ) != 'http://' && substr( $u, 0, 6 ) != 'ftp://' ) { + if( substr( $url, 0, 7 ) != 'http://' && substr( $url, 0, 6 ) != 'ftp://' ) { # Only HTTP or FTP URLs return true; } @@ -724,22 +724,33 @@ class UploadForm { ? 'checked="checked"' : ''; - // Fixme: this is a crappy form - if( $wgAllowCopyUploads && $wgRequest->getVal( 'source' ) == 'web' && $wgUser->isAllowed( 'upload_by_url' ) ) { - $sourcetype = 'text'; - $source_comment = '' . wfMsgHtml( 'upload_source_url' ); + // Prepare form for upload or upload/copy + if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) { + $source_comment = wfMsgHtml( 'upload_source_url' ); + $filename_form = + "" . + "mDestFile?"":"onchange='fillDestFilename(\"wpUploadFile\")' ") . "size='40' />" . + wfMsgHTML( 'upload_source_file' ) . "
" . + "" . + "mDestFile?"":"onchange='fillDestFilename(\"wpUploadFileURL\")' ") . "size='40' DISABLED />" . + wfMsgHtml( 'upload_source_url' ) ; } else { - $sourcetype = 'file'; - $source_comment = ''; + $filename_form = + "mDestFile?"":"onchange='fillDestFilename(\"wpUploadFile\")' ") . + "size='40' />" . + "" ; } $wgOut->addHTML( "
- + diff --git a/languages/MessagesEn.php b/languages/MessagesEn.php index 93f17c4f6c..36a75b6e58 100644 --- a/languages/MessagesEn.php +++ b/languages/MessagesEn.php @@ -1164,7 +1164,8 @@ created and by whom, and anything else you may know about it. If this is an imag 'license' => 'Licensing', 'nolicense' => 'None selected', 'licenses' => '-', # Don't duplicate this in translations -'upload_source_url' => ' (vaild, publicy accessible URL)', +'upload_source_url' => ' (a vaild, publicy accessible URL)', +'upload_source_file' => ' (a file on your computer)', # Image list # diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 0cfb6002a7..3a8fd6c69c 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -612,10 +612,24 @@ function checkboxMouseupHandler(e) { return true; } -function fillDestFilename() { +function toggle_element_activation(ida,idb) { if (!document.getElementById) return; - var path = document.getElementById('wpUploadFile').value; + document.getElementById(ida).disabled=true; + document.getElementById(idb).disabled=false; +} + +function toggle_element_check(ida,idb) { + if (!document.getElementById) + return; + document.getElementById(ida).checked=true; + document.getElementById(idb).checked=false; +} + +function fillDestFilename(id) { + if (!document.getElementById) + return; + var path = document.getElementById(id).value; // Find trailing part var slash = path.lastIndexOf('/'); var backslash = path.lastIndexOf('\\'); -- 2.20.1
- mDestFile?"":"onchange='fillDestFilename()' ") . "size='40' />{$source_comment} + {$filename_form}