Index: trunk/phase3/skins/common/wikibits.js |
— | — | @@ -612,10 +612,24 @@ |
613 | 613 | return true; |
614 | 614 | } |
615 | 615 | |
616 | | -function fillDestFilename() { |
| 616 | +function toggle_element_activation(ida,idb) { |
617 | 617 | if (!document.getElementById) |
618 | 618 | 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; |
620 | 634 | // Find trailing part |
621 | 635 | var slash = path.lastIndexOf('/'); |
622 | 636 | var backslash = path.lastIndexOf('\\'); |
Index: trunk/phase3/includes/SpecialUpload.php |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | $this->mUploadCopyStatus = $request->getText( 'wpUploadCopyStatus' ); |
58 | 58 | $this->mUploadSource = $request->getText( 'wpUploadSource' ); |
59 | 59 | $this->mWatchthis = $request->getBool( 'wpWatchthis' ); |
60 | | - $this->mSourceType = $request->getBool( 'wpSourceType' ); |
| 60 | + $this->mSourceType = $request->getText( 'wpSourceType' ); |
61 | 61 | wfDebug( "UploadForm: watchthis is: '$this->mWatchthis'\n" ); |
62 | 62 | |
63 | 63 | $this->mAction = $request->getVal( 'action' ); |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | */ |
111 | 111 | function initializeFromUrl( $request ) { |
112 | 112 | global $wgTmpDirectory, $wgMaxUploadSize; |
113 | | - $url = $request->getText( 'wpUploadFile' ); |
| 113 | + $url = $request->getText( 'wpUploadFileURL' ); |
114 | 114 | $local_file = tempnam( $wgTmpDirectory, 'WEBUPLOAD' ); |
115 | 115 | |
116 | 116 | $this->mUploadTempName = $local_file; |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | |
139 | 139 | # Maybe remove some pasting blanks :-) |
140 | 140 | $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://' ) { |
142 | 142 | # Only HTTP or FTP URLs |
143 | 143 | return true; |
144 | 144 | } |
— | — | @@ -724,22 +724,33 @@ |
725 | 725 | ? 'checked="checked"' |
726 | 726 | : ''; |
727 | 727 | |
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' ) ; |
732 | 740 | } 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' />" ; |
735 | 746 | } |
736 | 747 | |
737 | 748 | $wgOut->addHTML( " |
738 | 749 | <form id='upload' method='post' enctype='multipart/form-data' action=\"$action\"> |
739 | 750 | <table border='0'> |
740 | 751 | <tr> |
741 | | - <td align='right'><label for='wpUploadFile'>{$sourcefilename}:</label></td> |
| 752 | + <td align='right' valign='top'><label for='wpUploadFile'>{$sourcefilename}:</label></td> |
742 | 753 | <td align='left'> |
743 | | - <input tabindex='1' type='{$sourcetype}' name='wpUploadFile' id='wpUploadFile' " . ($this->mDestFile?"":"onchange='fillDestFilename()' ") . "size='40' />{$source_comment} |
| 754 | + {$filename_form} |
744 | 755 | </td> |
745 | 756 | </tr> |
746 | 757 | <tr> |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -157,7 +157,7 @@ |
158 | 158 | * Pass page title as parameters to "linkshere" and "nolinkshere" and update |
159 | 159 | default message text |
160 | 160 | * 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 |
162 | 162 | * (bug 832) Return to user page after emailing a user |
163 | 163 | * (bug 366) Add local-system-timezone equivalents for date/time variables |
164 | 164 | * (bug 7109) Fix Atom feed version number in header links |
Index: trunk/phase3/languages/MessagesEn.php |
— | — | @@ -1164,7 +1164,8 @@ |
1165 | 1165 | 'license' => 'Licensing', |
1166 | 1166 | 'nolicense' => 'None selected', |
1167 | 1167 | '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)', |
1169 | 1170 | |
1170 | 1171 | # Image list |
1171 | 1172 | # |