Index: trunk/extensions/ImportFreeImages/ImportFreeImages.body.php |
— | — | @@ -177,7 +177,7 @@ |
178 | 178 | |
179 | 179 | /** |
180 | 180 | * Shows a custom upload warning |
181 | | - * @param $u UploadForm object |
| 181 | + * @param $u UploadFromFile object |
182 | 182 | * @param $warning Mixed: warning message (MediaWiki:Fileexists plus some other stuff) |
183 | 183 | */ |
184 | 184 | function wfIFI_uploadWarning( $u, $warning ) { |
— | — | @@ -185,6 +185,11 @@ |
186 | 186 | |
187 | 187 | wfLoadExtensionMessages( 'ImportFreeImages' ); |
188 | 188 | |
| 189 | + $form = new UploadForm(); |
| 190 | + $form->mUpload = $u; |
| 191 | + $form->uploadWarning(); |
| 192 | + return; |
| 193 | + |
189 | 194 | $u->mSessionKey = $u->stashSession(); |
190 | 195 | if( !$u->mSessionKey ) { |
191 | 196 | # Couldn't save file; an error has been displayed so let's go. |
— | — | @@ -304,20 +309,6 @@ |
305 | 310 | $caption = trim($caption); |
306 | 311 | } |
307 | 312 | |
308 | | - // UploadForm class should be autoloaded by now on MediaWiki 1.13+ |
309 | | - // But on older versions, we need to require_once() it manually |
310 | | - if( !class_exists( 'UploadForm' ) ){ |
311 | | - require_once('includes/SpecialUpload.php'); |
312 | | - } |
313 | | - $u = new UploadForm($wgRequest); |
314 | | - // TODO: we should use FauxRequest here instead of accessing member variables. |
315 | | - // But FauxRequest doesn't yet allow us to pass files around |
316 | | - $u->mTempPath = $tempname; |
317 | | - $u->mFileSize = $size; |
318 | | - $u->mComment = $caption; |
319 | | - $u->mRemoveTempFile = true; |
320 | | - $u->mIgnoreWarning = true; |
321 | | - |
322 | 313 | $filename = $ititle . ($wgIFI_AppendRandomNumber ? "-" . rand(0, 9999) : "") . $fileext; |
323 | 314 | $filename = preg_replace('/ +/', ' ', $filename); |
324 | 315 | /** |
— | — | @@ -331,7 +322,8 @@ |
332 | 323 | $wgOut->showErrorPage( 'error', 'illegalfilename', array( wfEscapeWikiText( $filename ) ) ); |
333 | 324 | return false; |
334 | 325 | } |
335 | | - $u->mSrcName = $filename; |
| 326 | + $u = new UploadFromFile(); |
| 327 | + $u->initialize($filename, $tempname, $size, true); |
336 | 328 | |
337 | 329 | if( $nt->getArticleID() > 0 ) { |
338 | 330 | $sk = $wgUser->getSkin(); |
— | — | @@ -345,8 +337,16 @@ |
346 | 338 | $wgOut->showPermissionsErrorPage( $nt->getUserPermissionsErrors( 'create', $wgUser ) ); |
347 | 339 | return false; |
348 | 340 | } else { |
349 | | - $u->execute(); |
350 | | - return true; |
| 341 | + $status = $u->performUpload(wfMsg('importfreeimages_comment'), $caption, false, $wgUser); |
| 342 | + if ( !$status->isGood() ) { |
| 343 | + $form = new UploadForm(); |
| 344 | + $form->mUppload = $u; |
| 345 | + $form->uploadError( $wgOut->parse( $status->getWikiText() ) ); |
| 346 | + } |
| 347 | + // Success, redirect to description page |
| 348 | + wfRunHooks( 'SpecialUploadComplete', array( &$this ) ); |
| 349 | + $local = $u->getLocalFile(); |
| 350 | + $wgOut->redirect( $local->getTitle()->getFullURL() ); |
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
Index: trunk/extensions/ImportFreeImages/ImportFreeImages.i18n.php |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | 'importfreeimages_promptuserforfilename' => 'Please enter a destination filename:', |
28 | 28 | 'importfreeimages_returntoform' => 'Or, click <a href=\'$1\'>here</a> to return to your search results', |
29 | 29 | 'importfreeimages_nophpflickr' => 'You have not installed phpFlickr, please set $wgIFphpFlickr in your LocalSettings.php.', |
| 30 | + 'importfreeimages_comment' => "Importing image from Flickr", |
30 | 31 | ); |
31 | 32 | |
32 | 33 | /** Message documentation (Message documentation) |