r16292 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16291‎ | r16292 | r16293 >
Date:09:50, 31 August 2006
Author:magnusmanske
Status:old
Tags:
Comment:
Improved form for URL-based upload
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)
  • /trunk/phase3/languages/MessagesEn.php (modified) (history)
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -612,10 +612,24 @@
613613 return true;
614614 }
615615
616 -function fillDestFilename() {
 616+function toggle_element_activation(ida,idb) {
617617 if (!document.getElementById)
618618 return;
619 - var path = document.getElementById('wpUploadFile').value;
 619+ document.getElementById(ida).disabled=true;
 620+ document.getElementById(idb).disabled=false;
 621+}
 622+
 623+function toggle_element_check(ida,idb) {
 624+ if (!document.getElementById)
 625+ return;
 626+ document.getElementById(ida).checked=true;
 627+ document.getElementById(idb).checked=false;
 628+}
 629+
 630+function fillDestFilename(id) {
 631+ if (!document.getElementById)
 632+ return;
 633+ var path = document.getElementById(id).value;
620634 // Find trailing part
621635 var slash = path.lastIndexOf('/');
622636 var backslash = path.lastIndexOf('\\');
Index: trunk/phase3/includes/SpecialUpload.php
@@ -56,7 +56,7 @@
5757 $this->mUploadCopyStatus = $request->getText( 'wpUploadCopyStatus' );
5858 $this->mUploadSource = $request->getText( 'wpUploadSource' );
5959 $this->mWatchthis = $request->getBool( 'wpWatchthis' );
60 - $this->mSourceType = $request->getBool( 'wpSourceType' );
 60+ $this->mSourceType = $request->getText( 'wpSourceType' );
6161 wfDebug( "UploadForm: watchthis is: '$this->mWatchthis'\n" );
6262
6363 $this->mAction = $request->getVal( 'action' );
@@ -109,7 +109,7 @@
110110 */
111111 function initializeFromUrl( $request ) {
112112 global $wgTmpDirectory, $wgMaxUploadSize;
113 - $url = $request->getText( 'wpUploadFile' );
 113+ $url = $request->getText( 'wpUploadFileURL' );
114114 $local_file = tempnam( $wgTmpDirectory, 'WEBUPLOAD' );
115115
116116 $this->mUploadTempName = $local_file;
@@ -137,7 +137,7 @@
138138
139139 # Maybe remove some pasting blanks :-)
140140 $url = strtolower( trim( $url ) );
141 - if( substr( $u, 0, 7 ) != 'http://' && substr( $u, 0, 6 ) != 'ftp://' ) {
 141+ if( substr( $url, 0, 7 ) != 'http://' && substr( $url, 0, 6 ) != 'ftp://' ) {
142142 # Only HTTP or FTP URLs
143143 return true;
144144 }
@@ -724,22 +724,33 @@
725725 ? 'checked="checked"'
726726 : '';
727727
728 - // Fixme: this is a crappy form
729 - if( $wgAllowCopyUploads && $wgRequest->getVal( 'source' ) == 'web' && $wgUser->isAllowed( 'upload_by_url' ) ) {
730 - $sourcetype = 'text';
731 - $source_comment = '<input type="hidden" name="wpSourceType" value="web" />' . wfMsgHtml( 'upload_source_url' );
 728+ // Prepare form for upload or upload/copy
 729+ if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) {
 730+ $source_comment = wfMsgHtml( 'upload_source_url' );
 731+ $filename_form =
 732+ "<input type='radio' id='wpSourceTypeFile' name='wpSourceType' value='file' onchange='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\")' checked />" .
 733+ "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' onfocus='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\");toggle_element_check(\"wpSourceTypeFile\",\"wpSourceTypeURL\")'" .
 734+ ($this->mDestFile?"":"onchange='fillDestFilename(\"wpUploadFile\")' ") . "size='40' />" .
 735+ wfMsgHTML( 'upload_source_file' ) . "<br/>" .
 736+ "<input type='radio' id='wpSourceTypeURL' name='wpSourceType' value='web' onchange='toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\")' />" .
 737+ "<input tabindex='1' type='text' name='wpUploadFileURL' id='wpUploadFileURL' onfocus='toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\");toggle_element_check(\"wpSourceTypeURL\",\"wpSourceTypeFile\")'" .
 738+ ($this->mDestFile?"":"onchange='fillDestFilename(\"wpUploadFileURL\")' ") . "size='40' DISABLED />" .
 739+ wfMsgHtml( 'upload_source_url' ) ;
732740 } else {
733 - $sourcetype = 'file';
734 - $source_comment = '';
 741+ $filename_form =
 742+ "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " .
 743+ ($this->mDestFile?"":"onchange='fillDestFilename(\"wpUploadFile\")' ") .
 744+ "size='40' />" .
 745+ "<input type='hidden' name='wpSourceType' value='file' />" ;
735746 }
736747
737748 $wgOut->addHTML( "
738749 <form id='upload' method='post' enctype='multipart/form-data' action=\"$action\">
739750 <table border='0'>
740751 <tr>
741 - <td align='right'><label for='wpUploadFile'>{$sourcefilename}:</label></td>
 752+ <td align='right' valign='top'><label for='wpUploadFile'>{$sourcefilename}:</label></td>
742753 <td align='left'>
743 - <input tabindex='1' type='{$sourcetype}' name='wpUploadFile' id='wpUploadFile' " . ($this->mDestFile?"":"onchange='fillDestFilename()' ") . "size='40' />{$source_comment}
 754+ {$filename_form}
744755 </td>
745756 </tr>
746757 <tr>
Index: trunk/phase3/RELEASE-NOTES
@@ -157,7 +157,7 @@
158158 * Pass page title as parameters to "linkshere" and "nolinkshere" and update
159159 default message text
160160 * Allows to upload from publicy accessible URL. Set $wgAllowCopyUploads = true ; in LocalSettings.php
161 - Limited to $wgMaxUploadSize (default:100MB); URL upload is limited to sysops by default
 161+ Limited to $wgMaxUploadSize (default:100MB); URL upload is limited to sysops by default, and displayed as a second line if appropriate
162162 * (bug 832) Return to user page after emailing a user
163163 * (bug 366) Add local-system-timezone equivalents for date/time variables
164164 * (bug 7109) Fix Atom feed version number in header links
Index: trunk/phase3/languages/MessagesEn.php
@@ -1164,7 +1164,8 @@
11651165 'license' => 'Licensing',
11661166 'nolicense' => 'None selected',
11671167 'licenses' => '-', # Don't duplicate this in translations
1168 -'upload_source_url' => ' (vaild, publicy accessible URL)',
 1168+'upload_source_url' => ' (a vaild, publicy accessible URL)',
 1169+'upload_source_file' => ' (a file on your computer)',
11691170
11701171 # Image list
11711172 #