Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -3,9 +3,9 @@ |
4 | 4 | * @file |
5 | 5 | * @ingroup SpecialPage |
6 | 6 | * @ingroup Upload |
7 | | - * |
| 7 | + * |
8 | 8 | * Form for handling uploads and special page. |
9 | | - * |
| 9 | + * |
10 | 10 | */ |
11 | 11 | |
12 | 12 | class SpecialUpload extends SpecialPage { |
— | — | @@ -16,38 +16,38 @@ |
17 | 17 | */ |
18 | 18 | public function __construct( $request = null ) { |
19 | 19 | global $wgRequest; |
20 | | - |
| 20 | + |
21 | 21 | parent::__construct( 'Upload', 'upload' ); |
22 | | - |
| 22 | + |
23 | 23 | $this->loadRequest( is_null( $request ) ? $wgRequest : $request ); |
24 | 24 | } |
25 | | - |
| 25 | + |
26 | 26 | /** Misc variables **/ |
27 | 27 | protected $mRequest; // The WebRequest or FauxRequest this form is supposed to handle |
28 | 28 | protected $mSourceType; |
29 | 29 | protected $mUpload; |
30 | 30 | protected $mLocalFile; |
31 | 31 | protected $mUploadClicked; |
32 | | - |
| 32 | + |
33 | 33 | /** User input variables from the "description" section **/ |
34 | 34 | protected $mDesiredDestName; // The requested target file name |
35 | 35 | protected $mComment; |
36 | 36 | protected $mLicense; |
37 | | - |
| 37 | + |
38 | 38 | /** User input variables from the root section **/ |
39 | 39 | protected $mIgnoreWarning; |
40 | 40 | protected $mWatchThis; |
41 | 41 | protected $mCopyrightStatus; |
42 | 42 | protected $mCopyrightSource; |
43 | | - |
| 43 | + |
44 | 44 | /** Hidden variables **/ |
45 | 45 | protected $mForReUpload; // The user followed an "overwrite this file" link |
46 | 46 | protected $mCancelUpload; // The user clicked "Cancel and return to upload form" button |
47 | 47 | protected $mTokenOk; |
48 | | - |
| 48 | + |
49 | 49 | /** |
50 | 50 | * Initialize instance variables from request and create an Upload handler |
51 | | - * |
| 51 | + * |
52 | 52 | * @param WebRequest $request The request to extract variables from |
53 | 53 | */ |
54 | 54 | protected function loadRequest( $request ) { |
— | — | @@ -57,22 +57,22 @@ |
58 | 58 | $this->mSourceType = $request->getVal( 'wpSourceType', 'file' ); |
59 | 59 | $this->mUpload = UploadBase::createFromRequest( $request ); |
60 | 60 | $this->mUploadClicked = $request->getCheck( 'wpUpload' ) && $request->wasPosted(); |
61 | | - |
| 61 | + |
62 | 62 | // Guess the desired name from the filename if not provided |
63 | 63 | $this->mDesiredDestName = $request->getText( 'wpDestFile' ); |
64 | 64 | if( !$this->mDesiredDestName ) |
65 | 65 | $this->mDesiredDestName = $request->getText( 'wpUploadFile' ); |
66 | 66 | $this->mComment = $request->getText( 'wpUploadDescription' ); |
67 | | - $this->mLicense = $request->getText( 'wpLicense' ); |
68 | | - |
69 | | - |
| 67 | + $this->mLicense = $request->getText( 'wpLicense' ); |
| 68 | + |
| 69 | + |
70 | 70 | $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' ); |
71 | 71 | $this->mWatchthis = $request->getBool( 'wpWatchthis' ); |
72 | 72 | $this->mCopyrightStatus = $request->getText( 'wpUploadCopyStatus' ); |
73 | 73 | $this->mCopyrightSource = $request->getText( 'wpUploadSource' ); |
74 | 74 | |
75 | 75 | |
76 | | - $this->mForReUpload = $request->getBool( 'wpForReUpload' ); // updating a file |
| 76 | + $this->mForReUpload = $request->getBool( 'wpForReUpload' ); // updating a file |
77 | 77 | $this->mCancelUpload = $request->getCheck( 'wpCancelUpload' ) |
78 | 78 | || $request->getCheck( 'wpReUpload' ); // b/w compat |
79 | 79 | |
— | — | @@ -87,28 +87,28 @@ |
88 | 88 | $this->mTokenOk = $wgUser->matchEditToken( $token ); |
89 | 89 | } |
90 | 90 | } |
91 | | - |
| 91 | + |
92 | 92 | /** |
93 | 93 | * This page can be shown if uploading is enabled. |
94 | | - * Handle permission checking elsewhere in order to be able to show |
| 94 | + * Handle permission checking elsewhere in order to be able to show |
95 | 95 | * custom error messages. |
96 | | - * |
| 96 | + * |
97 | 97 | * @param User $user |
98 | 98 | * @return bool |
99 | 99 | */ |
100 | 100 | public function userCanExecute( $user ) { |
101 | 101 | return UploadBase::isEnabled() && parent::userCanExecute( $user ); |
102 | 102 | } |
103 | | - |
| 103 | + |
104 | 104 | /** |
105 | 105 | * Special page entry point |
106 | 106 | */ |
107 | 107 | public function execute( $par ) { |
108 | 108 | global $wgUser, $wgOut, $wgRequest; |
109 | | - |
| 109 | + |
110 | 110 | $this->setHeaders(); |
111 | 111 | $this->outputHeader(); |
112 | | - |
| 112 | + |
113 | 113 | # Check uploading enabled |
114 | 114 | if( !UploadBase::isEnabled() ) { |
115 | 115 | $wgOut->showErrorPage( 'uploaddisabled', 'uploaddisabledtext' ); |
— | — | @@ -139,31 +139,31 @@ |
140 | 140 | $wgOut->readOnlyPage(); |
141 | 141 | return; |
142 | 142 | } |
143 | | - |
| 143 | + |
144 | 144 | # Unsave the temporary file in case this was a cancelled upload |
145 | 145 | if ( $this->mCancelUpload ) { |
146 | 146 | if ( !$this->unsaveUploadedFile() ) |
147 | 147 | # Something went wrong, so unsaveUploadedFile showed a warning |
148 | 148 | return; |
149 | 149 | } |
150 | | - |
| 150 | + |
151 | 151 | # Process upload or show a form |
152 | | - if ( $this->mTokenOk && !$this->mCancelUpload |
153 | | - && ( $this->mUpload && $this->mUploadClicked ) ) { |
| 152 | + if ( $this->mTokenOk && !$this->mCancelUpload |
| 153 | + && ( $this->mUpload && $this->mUploadClicked ) ) { |
154 | 154 | $this->processUpload(); |
155 | 155 | } else { |
156 | 156 | $this->showUploadForm( $this->getUploadForm() ); |
157 | 157 | } |
158 | | - |
| 158 | + |
159 | 159 | # Cleanup |
160 | 160 | if ( $this->mUpload ) |
161 | 161 | $this->mUpload->cleanupTempFile(); |
162 | 162 | } |
163 | | - |
| 163 | + |
164 | 164 | /** |
165 | | - * Show the main upload form and optionally add the session key to the |
| 165 | + * Show the main upload form and optionally add the session key to the |
166 | 166 | * output. This hides the source selection. |
167 | | - * |
| 167 | + * |
168 | 168 | * @param string $message HTML message to be shown at top of form |
169 | 169 | * @param string $sessionKey Session key of the stashed upload |
170 | 170 | */ |
— | — | @@ -171,13 +171,13 @@ |
172 | 172 | # Add links if file was previously deleted |
173 | 173 | if ( !$this->mDesiredDestName ) |
174 | 174 | $this->showViewDeletedLinks(); |
175 | | - |
| 175 | + |
176 | 176 | $form->show(); |
177 | 177 | } |
178 | | - |
| 178 | + |
179 | 179 | /** |
180 | 180 | * Get an UploadForm instance with title and text properly set. |
181 | | - * |
| 181 | + * |
182 | 182 | * @param string $message HTML string to add to the form |
183 | 183 | * @param string $sessionKey Session key in case this is a stashed upload |
184 | 184 | * @return UploadForm |
— | — | @@ -186,26 +186,26 @@ |
187 | 187 | # Initialize form |
188 | 188 | $form = new UploadForm( $this->watchCheck(), $this->mForReUpload, $sessionKey ); |
189 | 189 | $form->setTitle( $this->getTitle() ); |
190 | | - |
| 190 | + |
191 | 191 | # Check the token, but only if necessary |
192 | | - if( !$this->mTokenOk && !$this->mCancelUpload |
193 | | - && ( $this->mUpload && $this->mUploadClicked ) ) |
| 192 | + if( !$this->mTokenOk && !$this->mCancelUpload |
| 193 | + && ( $this->mUpload && $this->mUploadClicked ) ) |
194 | 194 | $form->addPreText( wfMsgExt( 'session_fail_preview', 'parseinline' ) ); |
195 | 195 | |
196 | 196 | # Add text to form |
197 | 197 | $form->addPreText( '<div id="uploadtext">' . wfMsgExt( 'uploadtext', 'parse' ) . '</div>'); |
198 | 198 | # Add upload error message |
199 | | - $form->addPreText( $message ); |
200 | | - |
201 | | - return $form; |
| 199 | + $form->addPreText( $message ); |
| 200 | + |
| 201 | + return $form; |
202 | 202 | } |
203 | | - |
| 203 | + |
204 | 204 | /** |
205 | 205 | * TODO: DOCUMENT |
206 | 206 | */ |
207 | 207 | protected function showViewDeletedLinks() { |
208 | 208 | global $wgOut, $wgUser; |
209 | | - |
| 209 | + |
210 | 210 | $title = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName ); |
211 | 211 | // Show a subtitle link to deleted revisions (to sysops et al only) |
212 | 212 | if( $title instanceof Title && ( $count = $title->isDeleted() ) > 0 && $wgUser->isAllowed( 'deletedhistory' ) ) { |
— | — | @@ -225,16 +225,16 @@ |
226 | 226 | $this->showDeletionLog( $wgOut, $title->getPrefixedText() ); |
227 | 227 | } |
228 | 228 | } |
229 | | - |
| 229 | + |
230 | 230 | /** |
231 | 231 | * Stashes the upload and shows the main upload form. |
232 | | - * |
233 | | - * Note: only errors that can be handled by changing the name or |
| 232 | + * |
| 233 | + * Note: only errors that can be handled by changing the name or |
234 | 234 | * description should be redirected here. It should be assumed that the |
235 | | - * file itself is sane and has passed UploadBase::verifyFile. This |
236 | | - * essentially means that UploadBase::VERIFICATION_ERROR and |
| 235 | + * file itself is sane and has passed UploadBase::verifyFile. This |
| 236 | + * essentially means that UploadBase::VERIFICATION_ERROR and |
237 | 237 | * UploadBase::EMPTY_FILE should not be passed here. |
238 | | - * |
| 238 | + * |
239 | 239 | * @param string $message HTML message to be passed to mainUploadForm |
240 | 240 | */ |
241 | 241 | protected function recoverableUploadError( $message ) { |
— | — | @@ -243,19 +243,19 @@ |
244 | 244 | '<div class="error">' . $message . "</div>\n"; |
245 | 245 | $this->showUploadForm( $this->getUploadForm( $message, $sessionKey ) ); |
246 | 246 | } |
247 | | - /** |
| 247 | + /** |
248 | 248 | * Stashes the upload, shows the main form, but adds an "continue anyway button" |
249 | | - * |
| 249 | + * |
250 | 250 | * @param array $warnings |
251 | 251 | */ |
252 | 252 | protected function uploadWarning( $warnings ) { |
253 | 253 | global $wgUser; |
254 | | - |
| 254 | + |
255 | 255 | $sessionKey = $this->mUpload->stashSession(); |
256 | | - |
| 256 | + |
257 | 257 | $sk = $wgUser->getSkin(); |
258 | 258 | |
259 | | - $warningHtml = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" |
| 259 | + $warningHtml = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" |
260 | 260 | . '<ul class="warning">'; |
261 | 261 | foreach( $warnings as $warning => $args ) { |
262 | 262 | $msg = ''; |
— | — | @@ -264,8 +264,8 @@ |
265 | 265 | } elseif( $warning == 'duplicate' ) { |
266 | 266 | $msg = self::getDupeWarning( $args ); |
267 | 267 | } elseif( $warning == 'duplicate-archive' ) { |
268 | | - $msg = "\t<li>" . wfMsgExt( 'file-deleted-duplicate', 'parseinline', |
269 | | - array( Title::makeTitle( NS_FILE, $args )->getPrefixedText() ) ) |
| 268 | + $msg = "\t<li>" . wfMsgExt( 'file-deleted-duplicate', 'parseinline', |
| 269 | + array( Title::makeTitle( NS_FILE, $args )->getPrefixedText() ) ) |
270 | 270 | . "</li>\n"; |
271 | 271 | } else { |
272 | 272 | if ( is_bool( $args ) ) |
— | — | @@ -276,17 +276,18 @@ |
277 | 277 | } |
278 | 278 | $warningHtml .= $msg; |
279 | 279 | } |
280 | | - |
| 280 | + $warningHtml .= '</ul>'; |
| 281 | + |
281 | 282 | $form = $this->getUploadForm( $warningHtml, $sessionKey ); |
282 | 283 | $form->setSubmitText( wfMsg( 'ignorewarning' ) ); |
283 | 284 | $form->addButton( 'wpCancelUpload', wfMsg( 'reuploaddesc' ) ); |
284 | | - |
| 285 | + |
285 | 286 | $this->showUploadForm( $form ); |
286 | 287 | } |
287 | | - |
| 288 | + |
288 | 289 | /** |
289 | 290 | * Show the upload form with error message, but do not stash the file. |
290 | | - * |
| 291 | + * |
291 | 292 | * @param string $message |
292 | 293 | */ |
293 | 294 | protected function uploadError( $message ) { |
— | — | @@ -294,14 +295,14 @@ |
295 | 296 | '<div class="error">' . $message . "</div>\n"; |
296 | 297 | $this->showUploadForm( $this->getUploadForm( $message ) ); |
297 | 298 | } |
298 | | - |
| 299 | + |
299 | 300 | /** |
300 | 301 | * Do the upload. |
301 | 302 | * Checks are made in SpecialUpload::execute() |
302 | 303 | */ |
303 | 304 | protected function processUpload() { |
304 | 305 | global $wgUser, $wgOut; |
305 | | - |
| 306 | + |
306 | 307 | // Verify permissions |
307 | 308 | $permErrors = $this->mUpload->verifyPermissions( $wgUser ); |
308 | 309 | if( $permErrors !== true ) |
— | — | @@ -311,12 +312,12 @@ |
312 | 313 | $status = $this->mUpload->fetchFile(); |
313 | 314 | if( !$status->isOK() ) |
314 | 315 | return $this->mainUploadForm( $wgOut->parse( $status->getWikiText() ) ); |
315 | | - |
| 316 | + |
316 | 317 | // Upload verification |
317 | 318 | $details = $this->mUpload->verifyUpload(); |
318 | 319 | if ( $details['status'] != UploadBase::OK ) |
319 | 320 | return $this->processVerificationError( $details ); |
320 | | - |
| 321 | + |
321 | 322 | $this->mLocalFile = $this->mUpload->getLocalFile(); |
322 | 323 | |
323 | 324 | // Check warnings if necessary |
— | — | @@ -336,13 +337,13 @@ |
337 | 338 | $status = $this->mUpload->performUpload( $this->mComment, $pageText, $this->mWatchthis, $wgUser ); |
338 | 339 | if ( !$status->isGood() ) |
339 | 340 | return $this->uploadError( $wgOut->parse( $status->getWikiText() ) ); |
340 | | - |
| 341 | + |
341 | 342 | // Success, redirect to description page |
342 | 343 | wfRunHooks( 'SpecialUploadComplete', array( &$this ) ); |
343 | 344 | $wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() ); |
344 | 345 | |
345 | 346 | } |
346 | | - |
| 347 | + |
347 | 348 | /** |
348 | 349 | * Get the initial image page text based on a comment and optional file status information |
349 | 350 | */ |
— | — | @@ -368,7 +369,7 @@ |
369 | 370 | } |
370 | 371 | return $pageText; |
371 | 372 | } |
372 | | - |
| 373 | + |
373 | 374 | /** |
374 | 375 | * See if we should check the 'watch this page' checkbox on the form |
375 | 376 | * based on the user's preferences and whether we're being asked |
— | — | @@ -397,16 +398,16 @@ |
398 | 399 | return $wgUser->getOption( 'watchcreations' ); |
399 | 400 | } |
400 | 401 | } |
401 | | - |
402 | | - |
| 402 | + |
| 403 | + |
403 | 404 | /** |
404 | 405 | * Provides output to the user for a result of UploadBase::verifyUpload |
405 | | - * |
| 406 | + * |
406 | 407 | * @param array $details Result of UploadBase::verifyUpload |
407 | 408 | */ |
408 | 409 | protected function processVerificationError( $details ) { |
409 | 410 | global $wgFileExtensions, $wgLang; |
410 | | - |
| 411 | + |
411 | 412 | switch( $details['status'] ) { |
412 | 413 | |
413 | 414 | /** Statuses that only require name changing **/ |
— | — | @@ -422,7 +423,7 @@ |
423 | 424 | 'parseinline' ) ); |
424 | 425 | break; |
425 | 426 | case UploadBase::FILETYPE_MISSING: |
426 | | - $this->recoverableUploadError( wfMsgExt( 'filetype-missing', |
| 427 | + $this->recoverableUploadError( wfMsgExt( 'filetype-missing', |
427 | 428 | 'parseinline' ) ); |
428 | 429 | break; |
429 | 430 | |
— | — | @@ -457,7 +458,7 @@ |
458 | 459 | throw new MWException( __METHOD__ . ": Unknown value `{$details['status']}`" ); |
459 | 460 | } |
460 | 461 | } |
461 | | - |
| 462 | + |
462 | 463 | /** |
463 | 464 | * Remove a temporarily kept file stashed by saveTempUploadedFile(). |
464 | 465 | * @access private |
— | — | @@ -475,20 +476,20 @@ |
476 | 477 | return true; |
477 | 478 | } |
478 | 479 | } |
479 | | - |
| 480 | + |
480 | 481 | /*** Functions for formatting warnings ***/ |
481 | | - |
| 482 | + |
482 | 483 | /** |
483 | 484 | * Formats a result of UploadBase::getExistsWarning as HTML |
484 | 485 | * This check is static and can be done pre-upload via AJAX |
485 | | - * |
| 486 | + * |
486 | 487 | * @param array $exists The result of UploadBase::getExistsWarning |
487 | | - * @return string Empty string if there is no warning or an HTML fragment |
| 488 | + * @return string Empty string if there is no warning or an HTML fragment |
488 | 489 | * consisting of one or more <li> elements if there is a warning. |
489 | 490 | */ |
490 | 491 | public static function getExistsWarning( $exists ) { |
491 | 492 | global $wgUser, $wgContLang; |
492 | | - |
| 493 | + |
493 | 494 | if ( !$exists ) |
494 | 495 | return ''; |
495 | 496 | |
— | — | @@ -505,11 +506,11 @@ |
506 | 507 | // Page exists but file does not |
507 | 508 | $warning[] = '<li>' . wfMsgExt( 'filepageexists', 'parseinline', $filename ) . '</li>'; |
508 | 509 | } elseif ( $exists['warning'] == 'exists-normalized' ) { |
509 | | - $warning[] = '<li>' . wfMsgExt( 'fileexists-extension', 'parseinline', $filename, |
| 510 | + $warning[] = '<li>' . wfMsgExt( 'fileexists-extension', 'parseinline', $filename, |
510 | 511 | $exists['normalizedFile']->getTitle()->getPrefixedText() ) . '</li>'; |
511 | 512 | } elseif ( $exists['warning'] == 'thumb' ) { |
512 | 513 | // Swapped argument order compared with other messages for backwards compatibility |
513 | | - $warning[] = '<li>' . wfMsgExt( 'fileexists-thumbnail-yes', 'parseinline', |
| 514 | + $warning[] = '<li>' . wfMsgExt( 'fileexists-thumbnail-yes', 'parseinline', |
514 | 515 | $exists['thumbFile']->getTitle()->getPrefixedText(), $filename ) . '</li>'; |
515 | 516 | } elseif ( $exists['warning'] == 'thumb-name' ) { |
516 | 517 | // Image w/o '180px-' does not exists, but we do not like these filenames |
— | — | @@ -532,7 +533,7 @@ |
533 | 534 | ); |
534 | 535 | $warning[] = '<li>' . wfMsgWikiHtml( 'filewasdeleted', $llink ) . '</li>'; |
535 | 536 | } |
536 | | - |
| 537 | + |
537 | 538 | return implode( "\n", $warning ); |
538 | 539 | } |
539 | 540 | |
— | — | @@ -600,54 +601,54 @@ |
601 | 602 | return ''; |
602 | 603 | } |
603 | 604 | } |
604 | | - |
| 605 | + |
605 | 606 | } |
606 | 607 | |
607 | 608 | /** |
608 | | - * Sub class of HTMLForm that provides the form section of SpecialUpload |
| 609 | + * Sub class of HTMLForm that provides the form section of SpecialUpload |
609 | 610 | */ |
610 | 611 | class UploadForm extends HTMLForm { |
611 | 612 | protected $mWatch; |
612 | 613 | protected $mForReUpload; |
613 | 614 | protected $mSessionKey; |
614 | 615 | protected $mSourceIds; |
615 | | - |
| 616 | + |
616 | 617 | public function __construct( $watch, $forReUpload = false, $sessionKey = '' ) { |
617 | 618 | global $wgLang; |
618 | | - |
| 619 | + |
619 | 620 | $this->mWatch = $watch; |
620 | 621 | $this->mForReUpload = $forReUpload; |
621 | 622 | $this->mSessionKey = $sessionKey; |
622 | | - |
623 | | - $sourceDescriptor = $this->getSourceSection(); |
| 623 | + |
| 624 | + $sourceDescriptor = $this->getSourceSection(); |
624 | 625 | $descriptor = $sourceDescriptor |
625 | 626 | + $this->getDescriptionSection() |
626 | 627 | + $this->getOptionsSection(); |
627 | | - |
| 628 | + |
628 | 629 | wfRunHooks( 'UploadFormInitDescriptor', array( $descriptor ) ); |
629 | 630 | parent::__construct( $descriptor, 'upload' ); |
630 | | - |
| 631 | + |
631 | 632 | # Set some form properties |
632 | 633 | $this->setSubmitText( wfMsg( 'uploadbtn' ) ); |
633 | 634 | $this->setSubmitName( 'wpUpload' ); |
634 | 635 | $this->setSubmitTooltip( 'upload' ); |
635 | 636 | $this->setId( 'mw-upload-form' ); |
636 | | - |
| 637 | + |
637 | 638 | # Build a list of IDs for javascript insertion |
638 | 639 | $this->mSourceIds = array(); |
639 | 640 | foreach ( $sourceDescriptor as $key => $field ) { |
640 | 641 | if ( !empty( $field['id'] ) ) |
641 | 642 | $this->mSourceIds[] = $field['id']; |
642 | 643 | } |
643 | | - |
| 644 | + |
644 | 645 | } |
645 | | - |
| 646 | + |
646 | 647 | /** |
647 | | - * |
| 648 | + * |
648 | 649 | */ |
649 | 650 | protected function getSourceSection() { |
650 | 651 | global $wgLang, $wgUser, $wgRequest; |
651 | | - |
| 652 | + |
652 | 653 | if ( $this->mSessionKey ) { |
653 | 654 | return array( |
654 | 655 | 'wpSessionKey' => array( |
— | — | @@ -660,11 +661,11 @@ |
661 | 662 | ), |
662 | 663 | ); |
663 | 664 | } |
664 | | - |
| 665 | + |
665 | 666 | $canUploadByUrl = UploadFromUrl::isEnabled() && $wgUser->isAllowed( 'upload_by_url' ); |
666 | 667 | $radio = $canUploadByUrl; |
667 | 668 | $selectedSourceType = strtolower( $wgRequest->getText( 'wpSourceType', 'File' ) ); |
668 | | - |
| 669 | + |
669 | 670 | $descriptor = array(); |
670 | 671 | $descriptor['UploadFile'] = array( |
671 | 672 | 'class' => 'UploadSourceField', |
— | — | @@ -674,10 +675,10 @@ |
675 | 676 | 'label-message' => 'sourcefilename', |
676 | 677 | 'upload-type' => 'File', |
677 | 678 | 'radio' => &$radio, |
678 | | - 'help' => wfMsgExt( 'upload-maxfilesize', |
| 679 | + 'help' => wfMsgExt( 'upload-maxfilesize', |
679 | 680 | array( 'parseinline', 'escapenoentities' ), |
680 | | - $wgLang->formatSize( |
681 | | - wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ) |
| 681 | + $wgLang->formatSize( |
| 682 | + wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ) |
682 | 683 | ) |
683 | 684 | ) . ' ' . wfMsgHtml( 'upload_source_file' ), |
684 | 685 | 'checked' => $selectedSourceType == 'file', |
— | — | @@ -691,7 +692,7 @@ |
692 | 693 | 'label-message' => 'sourceurl', |
693 | 694 | 'upload-type' => 'Url', |
694 | 695 | 'radio' => &$radio, |
695 | | - 'help' => wfMsgExt( 'upload-maxfilesize', |
| 696 | + 'help' => wfMsgExt( 'upload-maxfilesize', |
696 | 697 | array( 'parseinline', 'escapenoentities' ), |
697 | 698 | $wgLang->formatSize( $wgMaxUploadSize ) |
698 | 699 | ) . ' ' . wfMsgHtml( 'upload_source_url' ), |
— | — | @@ -699,18 +700,18 @@ |
700 | 701 | ); |
701 | 702 | } |
702 | 703 | wfRunHooks( 'UploadFormSourceDescriptors', array( $descriptor, &$radio, $selectedSourceType ) ); |
703 | | - |
| 704 | + |
704 | 705 | $descriptor['Extensions'] = array( |
705 | 706 | 'type' => 'info', |
706 | 707 | 'section' => 'source', |
707 | 708 | 'default' => $this->getExtensionsMessage(), |
708 | 709 | 'raw' => true, |
709 | 710 | ); |
710 | | - return $descriptor; |
| 711 | + return $descriptor; |
711 | 712 | } |
712 | | - |
| 713 | + |
713 | 714 | /** |
714 | | - * |
| 715 | + * |
715 | 716 | */ |
716 | 717 | protected function getExtensionsMessage() { |
717 | 718 | # Print a list of allowed file extensions, if so configured. We ignore |
— | — | @@ -742,18 +743,18 @@ |
743 | 744 | } |
744 | 745 | return $extensionsList; |
745 | 746 | } |
746 | | - |
| 747 | + |
747 | 748 | /** |
748 | | - * |
| 749 | + * |
749 | 750 | */ |
750 | 751 | protected function getDescriptionSection() { |
751 | 752 | global $wgUser, $wgOut; |
752 | | - |
| 753 | + |
753 | 754 | $cols = intval( $wgUser->getOption( 'cols' ) ); |
754 | 755 | if( $wgUser->getOption( 'editwidth' ) ) { |
755 | 756 | $wgOut->addInlineStyle( '#mw-htmlform-description { width: 100%; }' ); |
756 | 757 | } |
757 | | - |
| 758 | + |
758 | 759 | $descriptor = array( |
759 | 760 | 'DestFile' => array( |
760 | 761 | 'type' => 'text', |
— | — | @@ -767,7 +768,7 @@ |
768 | 769 | 'section' => 'description', |
769 | 770 | 'id' => 'wpUploadDescription', |
770 | 771 | 'label-message' => $this->mForReUpload |
771 | | - ? 'filereuploadsummary' |
| 772 | + ? 'filereuploadsummary' |
772 | 773 | : 'fileuploadsummary', |
773 | 774 | 'cols' => $cols, |
774 | 775 | 'rows' => 8, |
— | — | @@ -782,14 +783,14 @@ |
783 | 784 | ); |
784 | 785 | if ( $this->mForReUpload ) |
785 | 786 | $descriptor['DestFile']['readonly'] = true; |
786 | | - |
| 787 | + |
787 | 788 | global $wgUseAjax, $wgAjaxLicensePreview; |
788 | 789 | if ( $wgUseAjax && $wgAjaxLicensePreview ) |
789 | | - $descriptor['AjaxLicensePreview'] = array( |
790 | | - 'class' => 'UploadAjaxLicensePreview', |
791 | | - 'section' => 'description' |
| 790 | + $descriptor['AjaxLicensePreview'] = array( |
| 791 | + 'class' => 'UploadAjaxLicensePreview', |
| 792 | + 'section' => 'description' |
792 | 793 | ); |
793 | | - |
| 794 | + |
794 | 795 | global $wgUseCopyrightUpload; |
795 | 796 | if ( $wgUseCopyrightUpload ) { |
796 | 797 | $descriptor['UploadCopyStatus'] = array( |
— | — | @@ -805,16 +806,16 @@ |
806 | 807 | 'label-message' => 'filesource', |
807 | 808 | ); |
808 | 809 | } |
809 | | - |
| 810 | + |
810 | 811 | return $descriptor; |
811 | 812 | } |
812 | | - |
| 813 | + |
813 | 814 | /** |
814 | | - * |
| 815 | + * |
815 | 816 | */ |
816 | 817 | protected function getOptionsSection() { |
817 | 818 | global $wgOut; |
818 | | - |
| 819 | + |
819 | 820 | $descriptor = array( |
820 | 821 | 'Watchthis' => array( |
821 | 822 | 'type' => 'check', |
— | — | @@ -833,7 +834,7 @@ |
834 | 835 | 'section' => 'options', |
835 | 836 | ), |
836 | 837 | ); |
837 | | - |
| 838 | + |
838 | 839 | $uploadFooter = wfMsgNoTrans( 'uploadfooter' ); |
839 | 840 | if ( $uploadFooter != '-' && !wfEmptyMsg( 'uploadfooter', $uploadFooter ) ) |
840 | 841 | $descriptor['UploadFooter'] = array( |
— | — | @@ -841,30 +842,30 @@ |
842 | 843 | 'id' => 'mw-upload-footer-message', |
843 | 844 | 'default' => $wgOut->parse( $uploadFooter ), |
844 | 845 | ); |
845 | | - |
| 846 | + |
846 | 847 | return $descriptor; |
847 | | - |
| 848 | + |
848 | 849 | } |
849 | | - |
| 850 | + |
850 | 851 | /** |
851 | | - * |
| 852 | + * |
852 | 853 | */ |
853 | 854 | public function show() { |
854 | 855 | $this->addUploadJS(); |
855 | 856 | parent::show(); |
856 | 857 | } |
857 | | - |
| 858 | + |
858 | 859 | /** |
859 | | - * |
| 860 | + * |
860 | 861 | */ |
861 | 862 | protected function addUploadJS( $autofill = true ) { |
862 | 863 | global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview; |
863 | 864 | global $wgEnableFirefogg, $wgEnableJS2system; |
864 | 865 | global $wgOut; |
865 | | - |
| 866 | + |
866 | 867 | $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck; |
867 | 868 | $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview; |
868 | | - |
| 869 | + |
869 | 870 | $scriptVars = array( |
870 | 871 | 'wgAjaxUploadDestCheck' => $wgUseAjax && $wgAjaxUploadDestCheck, |
871 | 872 | 'wgAjaxLicensePreview' => $wgUseAjax && $wgAjaxLicensePreview, |
— | — | @@ -884,7 +885,7 @@ |
885 | 886 | $wgOut->addScriptFile( 'edit.js' ); // For <charinsert> support |
886 | 887 | } |
887 | 888 | } |
888 | | - |
| 889 | + |
889 | 890 | function trySubmit() { |
890 | 891 | return false; |
891 | 892 | } |
— | — | @@ -896,11 +897,11 @@ |
897 | 898 | */ |
898 | 899 | class UploadSourceField extends HTMLTextField { |
899 | 900 | function getLabelHtml() { |
900 | | - $id = "wpSourceType{$this->mParams['upload-type']}"; |
| 901 | + $id = "wpSourceType{$this->mParams['upload-type']}"; |
901 | 902 | $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel ); |
902 | | - |
| 903 | + |
903 | 904 | if ( !empty( $this->mParams['radio'] ) ) { |
904 | | - $attribs = array( |
| 905 | + $attribs = array( |
905 | 906 | 'name' => 'wpSourceType', |
906 | 907 | 'type' => 'radio', |
907 | 908 | 'id' => $id, |
— | — | @@ -910,12 +911,12 @@ |
911 | 912 | $attribs['checked'] = 'checked'; |
912 | 913 | $label .= Html::element( 'input', $attribs ); |
913 | 914 | } |
914 | | - |
| 915 | + |
915 | 916 | return Html::rawElement( 'td', array( 'class' => 'mw-label' ), $label ); |
916 | 917 | } |
917 | 918 | function getSize() { |
918 | | - return isset( $this->mParams['size'] ) |
919 | | - ? $this->mParams['size'] |
| 919 | + return isset( $this->mParams['size'] ) |
| 920 | + ? $this->mParams['size'] |
920 | 921 | : 60; |
921 | 922 | } |
922 | 923 | } |