MediaWiki  1.23.14
SpecialUpload.php
Go to the documentation of this file.
1 <?php
31 class SpecialUpload extends SpecialPage {
37  public function __construct( $request = null ) {
38  parent::__construct( 'Upload', 'upload' );
39  }
40 
44  public $mRequest;
45  public $mSourceType;
46 
48  public $mUpload;
49 
51  public $mLocalFile;
52  public $mUploadClicked;
53 
57  public $mDesiredDestName;
58  public $mComment;
59  public $mLicense;
60 
63  public $mIgnoreWarning;
64  public $mWatchthis;
65  public $mCopyrightStatus;
67 
71 
73  public $mForReUpload;
74 
77  public $mTokenOk;
78 
80  public $mUploadSuccessful = false;
81 
83  public $uploadFormTextTop;
85 
89  protected function loadRequest() {
90  $this->mRequest = $request = $this->getRequest();
91  $this->mSourceType = $request->getVal( 'wpSourceType', 'file' );
92  $this->mUpload = UploadBase::createFromRequest( $request );
93  $this->mUploadClicked = $request->wasPosted()
94  && ( $request->getCheck( 'wpUpload' )
95  || $request->getCheck( 'wpUploadIgnoreWarning' ) );
96 
97  // Guess the desired name from the filename if not provided
98  $this->mDesiredDestName = $request->getText( 'wpDestFile' );
99  if ( !$this->mDesiredDestName && $request->getFileName( 'wpUploadFile' ) !== null ) {
100  $this->mDesiredDestName = $request->getFileName( 'wpUploadFile' );
101  }
102  $this->mLicense = $request->getText( 'wpLicense' );
103 
104  $this->mDestWarningAck = $request->getText( 'wpDestFileWarningAck' );
105  $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' )
106  || $request->getCheck( 'wpUploadIgnoreWarning' );
107  $this->mWatchthis = $request->getBool( 'wpWatchthis' ) && $this->getUser()->isLoggedIn();
108  $this->mCopyrightStatus = $request->getText( 'wpUploadCopyStatus' );
109  $this->mCopyrightSource = $request->getText( 'wpUploadSource' );
110 
111  $this->mForReUpload = $request->getBool( 'wpForReUpload' ); // updating a file
112 
113  $commentDefault = '';
114  $commentMsg = wfMessage( 'upload-default-description' )->inContentLanguage();
115  if ( !$this->mForReUpload && !$commentMsg->isDisabled() ) {
116  $commentDefault = $commentMsg->plain();
117  }
118  $this->mComment = $request->getText( 'wpUploadDescription', $commentDefault );
119 
120  $this->mCancelUpload = $request->getCheck( 'wpCancelUpload' )
121  || $request->getCheck( 'wpReUpload' ); // b/w compat
122 
123  // If it was posted check for the token (no remote POST'ing with user credentials)
124  $token = $request->getVal( 'wpEditToken' );
125  $this->mTokenOk = $this->getUser()->matchEditToken( $token );
126 
127  $this->uploadFormTextTop = '';
128  $this->uploadFormTextAfterSummary = '';
129  }
130 
139  public function userCanExecute( User $user ) {
140  return UploadBase::isEnabled() && parent::userCanExecute( $user );
141  }
142 
146  public function execute( $par ) {
147  $this->setHeaders();
148  $this->outputHeader();
149 
150  # Check uploading enabled
151  if ( !UploadBase::isEnabled() ) {
152  throw new ErrorPageError( 'uploaddisabled', 'uploaddisabledtext' );
153  }
154 
155  # Check permissions
156  $user = $this->getUser();
157  $permissionRequired = UploadBase::isAllowed( $user );
158  if ( $permissionRequired !== true ) {
159  throw new PermissionsError( $permissionRequired );
160  }
161 
162  # Check blocks
163  if ( $user->isBlocked() ) {
164  throw new UserBlockedError( $user->getBlock() );
165  }
166 
167  # Check whether we actually want to allow changing stuff
168  $this->checkReadOnly();
169 
170  $this->loadRequest();
171 
172  # Unsave the temporary file in case this was a cancelled upload
173  if ( $this->mCancelUpload ) {
174  if ( !$this->unsaveUploadedFile() ) {
175  # Something went wrong, so unsaveUploadedFile showed a warning
176  return;
177  }
178  }
179 
180  # Process upload or show a form
181  if (
182  $this->mTokenOk && !$this->mCancelUpload &&
183  ( $this->mUpload && $this->mUploadClicked )
184  ) {
185  $this->processUpload();
186  } else {
187  # Backwards compatibility hook
188  if ( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) {
189  wfDebug( "Hook 'UploadForm:initial' broke output of the upload form\n" );
190 
191  return;
192  }
193  $this->showUploadForm( $this->getUploadForm() );
194  }
195 
196  # Cleanup
197  if ( $this->mUpload ) {
198  $this->mUpload->cleanupTempFile();
199  }
200  }
201 
207  protected function showUploadForm( $form ) {
208  # Add links if file was previously deleted
209  if ( $this->mDesiredDestName ) {
210  $this->showViewDeletedLinks();
211  }
212 
213  if ( $form instanceof HTMLForm ) {
214  $form->show();
215  } else {
216  $this->getOutput()->addHTML( $form );
217  }
218  }
219 
228  protected function getUploadForm( $message = '', $sessionKey = '', $hideIgnoreWarning = false ) {
229  # Initialize form
230  $context = new DerivativeContext( $this->getContext() );
231  $context->setTitle( $this->getPageTitle() ); // Remove subpage
232  $form = new UploadForm( array(
233  'watch' => $this->getWatchCheck(),
234  'forreupload' => $this->mForReUpload,
235  'sessionkey' => $sessionKey,
236  'hideignorewarning' => $hideIgnoreWarning,
237  'destwarningack' => (bool)$this->mDestWarningAck,
238 
239  'description' => $this->mComment,
240  'texttop' => $this->uploadFormTextTop,
241  'textaftersummary' => $this->uploadFormTextAfterSummary,
242  'destfile' => $this->mDesiredDestName,
243  ), $context );
244 
245  # Check the token, but only if necessary
246  if (
247  !$this->mTokenOk && !$this->mCancelUpload &&
248  ( $this->mUpload && $this->mUploadClicked )
249  ) {
250  $form->addPreText( $this->msg( 'session_fail_preview' )->parse() );
251  }
252 
253  # Give a notice if the user is uploading a file that has been deleted or moved
254  # Note that this is independent from the message 'filewasdeleted' that requires JS
255  $desiredTitleObj = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName );
256  $delNotice = ''; // empty by default
257  if ( $desiredTitleObj instanceof Title && !$desiredTitleObj->exists() ) {
258  LogEventsList::showLogExtract( $delNotice, array( 'delete', 'move' ),
259  $desiredTitleObj,
260  '', array( 'lim' => 10,
261  'conds' => array( "log_action != 'revision'" ),
262  'showIfEmpty' => false,
263  'msgKey' => array( 'upload-recreate-warning' ) )
264  );
265  }
266  $form->addPreText( $delNotice );
267 
268  # Add text to form
269  $form->addPreText( '<div id="uploadtext">' .
270  $this->msg( 'uploadtext', array( $this->mDesiredDestName ) )->parseAsBlock() .
271  '</div>' );
272  # Add upload error message
273  $form->addPreText( $message );
274 
275  # Add footer to form
276  $uploadFooter = $this->msg( 'uploadfooter' );
277  if ( !$uploadFooter->isDisabled() ) {
278  $form->addPostText( '<div id="mw-upload-footer-message">'
279  . $uploadFooter->parseAsBlock() . "</div>\n" );
280  }
281 
282  return $form;
283  }
284 
288  protected function showViewDeletedLinks() {
289  $title = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName );
290  $user = $this->getUser();
291  // Show a subtitle link to deleted revisions (to sysops et al only)
292  if ( $title instanceof Title ) {
293  $count = $title->isDeleted();
294  if ( $count > 0 && $user->isAllowed( 'deletedhistory' ) ) {
295  $restorelink = Linker::linkKnown(
296  SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedText() ),
297  $this->msg( 'restorelink' )->numParams( $count )->escaped()
298  );
299  $link = $this->msg( $user->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted' )
300  ->rawParams( $restorelink )->parseAsBlock();
301  $this->getOutput()->addHTML( "<div id=\"contentSub2\">{$link}</div>" );
302  }
303  }
304  }
305 
317  protected function showRecoverableUploadError( $message ) {
318  $sessionKey = $this->mUpload->stashSession();
319  $message = '<h2>' . $this->msg( 'uploaderror' )->escaped() . "</h2>\n" .
320  '<div class="error">' . $message . "</div>\n";
321 
322  $form = $this->getUploadForm( $message, $sessionKey );
323  $form->setSubmitText( $this->msg( 'upload-tryagain' )->escaped() );
324  $this->showUploadForm( $form );
325  }
326 
335  protected function showUploadWarning( $warnings ) {
336  # If there are no warnings, or warnings we can ignore, return early.
337  # mDestWarningAck is set when some javascript has shown the warning
338  # to the user. mForReUpload is set when the user clicks the "upload a
339  # new version" link.
340  if ( !$warnings || ( count( $warnings ) == 1
341  && isset( $warnings['exists'] )
342  && ( $this->mDestWarningAck || $this->mForReUpload ) )
343  ) {
344  return false;
345  }
346 
347  $sessionKey = $this->mUpload->stashSession();
348 
349  $warningHtml = '<h2>' . $this->msg( 'uploadwarning' )->escaped() . "</h2>\n"
350  . '<ul class="warning">';
351  foreach ( $warnings as $warning => $args ) {
352  if ( $warning == 'badfilename' ) {
353  $this->mDesiredDestName = Title::makeTitle( NS_FILE, $args )->getText();
354  }
355  if ( $warning == 'exists' ) {
356  $msg = "\t<li>" . self::getExistsWarning( $args ) . "</li>\n";
357  } elseif ( $warning == 'duplicate' ) {
358  $msg = $this->getDupeWarning( $args );
359  } elseif ( $warning == 'duplicate-archive' ) {
360  if ( $args === '' ) {
361  $msg = "\t<li>" . $this->msg( 'file-deleted-duplicate-notitle' )->parse()
362  . "</li>\n";
363  } else {
364  $msg = "\t<li>" . $this->msg( 'file-deleted-duplicate',
365  Title::makeTitle( NS_FILE, $args )->getPrefixedText() )->parse()
366  . "</li>\n";
367  }
368  } else {
369  if ( $args === true ) {
370  $args = array();
371  } elseif ( !is_array( $args ) ) {
372  $args = array( $args );
373  }
374  $msg = "\t<li>" . $this->msg( $warning, $args )->parse() . "</li>\n";
375  }
376  $warningHtml .= $msg;
377  }
378  $warningHtml .= "</ul>\n";
379  $warningHtml .= $this->msg( 'uploadwarning-text' )->parseAsBlock();
380 
381  $form = $this->getUploadForm( $warningHtml, $sessionKey, /* $hideIgnoreWarning */ true );
382  $form->setSubmitText( $this->msg( 'upload-tryagain' )->text() );
383  $form->addButton( 'wpUploadIgnoreWarning', $this->msg( 'ignorewarning' )->text() );
384  $form->addButton( 'wpCancelUpload', $this->msg( 'reuploaddesc' )->text() );
385 
386  $this->showUploadForm( $form );
387 
388  # Indicate that we showed a form
389  return true;
390  }
391 
397  protected function showUploadError( $message ) {
398  $message = '<h2>' . $this->msg( 'uploadwarning' )->escaped() . "</h2>\n" .
399  '<div class="error">' . $message . "</div>\n";
400  $this->showUploadForm( $this->getUploadForm( $message ) );
401  }
402 
407  protected function processUpload() {
408  // Fetch the file if required
409  $status = $this->mUpload->fetchFile();
410  if ( !$status->isOK() ) {
411  $this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
412 
413  return;
414  }
415 
416  if ( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) ) {
417  wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file.\n" );
418  // This code path is deprecated. If you want to break upload processing
419  // do so by hooking into the appropriate hooks in UploadBase::verifyUpload
420  // and UploadBase::verifyFile.
421  // If you use this hook to break uploading, the user will be returned
422  // an empty form with no error message whatsoever.
423  return;
424  }
425 
426  // Upload verification
427  $details = $this->mUpload->verifyUpload();
428  if ( $details['status'] != UploadBase::OK ) {
429  $this->processVerificationError( $details );
430 
431  return;
432  }
433 
434  // Verify permissions for this title
435  $permErrors = $this->mUpload->verifyTitlePermissions( $this->getUser() );
436  if ( $permErrors !== true ) {
437  $code = array_shift( $permErrors[0] );
438  $this->showRecoverableUploadError( $this->msg( $code, $permErrors[0] )->parse() );
439 
440  return;
441  }
442 
443  $this->mLocalFile = $this->mUpload->getLocalFile();
444 
445  // Check warnings if necessary
446  if ( !$this->mIgnoreWarning ) {
447  $warnings = $this->mUpload->checkWarnings();
448  if ( $this->showUploadWarning( $warnings ) ) {
449  return;
450  }
451  }
452 
453  // This is as late as we can throttle, after expected issues have been handled
454  if ( UploadBase::isThrottled( $this->getUser() ) ) {
456  $this->msg( 'actionthrottledtext' )->escaped()
457  );
458  return;
459  }
460 
461  // Get the page text if this is not a reupload
462  if ( !$this->mForReUpload ) {
463  $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
464  $this->mCopyrightStatus, $this->mCopyrightSource );
465  } else {
466  $pageText = false;
467  }
468 
469  $status = $this->mUpload->performUpload(
470  $this->mComment,
471  $pageText,
472  $this->mWatchthis,
473  $this->getUser()
474  );
475 
476  if ( !$status->isGood() ) {
477  $this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
478 
479  return;
480  }
481 
482  // Success, redirect to description page
483  $this->mUploadSuccessful = true;
484  wfRunHooks( 'SpecialUploadComplete', array( &$this ) );
485  $this->getOutput()->redirect( $this->mLocalFile->getTitle()->getFullURL() );
486  }
487 
496  public static function getInitialPageText( $comment = '', $license = '',
497  $copyStatus = '', $source = ''
498  ) {
499  global $wgUseCopyrightUpload, $wgForceUIMsgAsContentMsg;
500 
501  $msg = array();
502  /* These messages are transcluded into the actual text of the description page.
503  * Thus, forcing them as content messages makes the upload to produce an int: template
504  * instead of hardcoding it there in the uploader language.
505  */
506  foreach ( array( 'license-header', 'filedesc', 'filestatus', 'filesource' ) as $msgName ) {
507  if ( in_array( $msgName, (array)$wgForceUIMsgAsContentMsg ) ) {
508  $msg[$msgName] = "{{int:$msgName}}";
509  } else {
510  $msg[$msgName] = wfMessage( $msgName )->inContentLanguage()->text();
511  }
512  }
513 
514  if ( $wgUseCopyrightUpload ) {
515  $licensetxt = '';
516  if ( $license != '' ) {
517  $licensetxt = '== ' . $msg['license-header'] . " ==\n" . '{{' . $license . '}}' . "\n";
518  }
519  $pageText = '== ' . $msg['filedesc'] . " ==\n" . $comment . "\n" .
520  '== ' . $msg['filestatus'] . " ==\n" . $copyStatus . "\n" .
521  "$licensetxt" .
522  '== ' . $msg['filesource'] . " ==\n" . $source;
523  } else {
524  if ( $license != '' ) {
525  $filedesc = $comment == '' ? '' : '== ' . $msg['filedesc'] . " ==\n" . $comment . "\n";
526  $pageText = $filedesc .
527  '== ' . $msg['license-header'] . " ==\n" . '{{' . $license . '}}' . "\n";
528  } else {
529  $pageText = $comment;
530  }
531  }
532 
533  return $pageText;
534  }
535 
548  protected function getWatchCheck() {
549  if ( $this->getUser()->getOption( 'watchdefault' ) ) {
550  // Watch all edits!
551  return true;
552  }
553 
554  $desiredTitleObj = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName );
555  if ( $desiredTitleObj instanceof Title && $this->getUser()->isWatched( $desiredTitleObj ) ) {
556  // Already watched, don't change that
557  return true;
558  }
559 
560  $local = wfLocalFile( $this->mDesiredDestName );
561  if ( $local && $local->exists() ) {
562  // We're uploading a new version of an existing file.
563  // No creation, so don't watch it if we're not already.
564  return false;
565  } else {
566  // New page should get watched if that's our option.
567  return $this->getUser()->getOption( 'watchcreations' );
568  }
569  }
570 
577  protected function processVerificationError( $details ) {
579 
580  switch ( $details['status'] ) {
581 
583  case UploadBase::MIN_LENGTH_PARTNAME:
584  $this->showRecoverableUploadError( $this->msg( 'minlength1' )->escaped() );
585  break;
586  case UploadBase::ILLEGAL_FILENAME:
587  $this->showRecoverableUploadError( $this->msg( 'illegalfilename',
588  $details['filtered'] )->parse() );
589  break;
590  case UploadBase::FILENAME_TOO_LONG:
591  $this->showRecoverableUploadError( $this->msg( 'filename-toolong' )->escaped() );
592  break;
593  case UploadBase::FILETYPE_MISSING:
594  $this->showRecoverableUploadError( $this->msg( 'filetype-missing' )->parse() );
595  break;
596  case UploadBase::WINDOWS_NONASCII_FILENAME:
597  $this->showRecoverableUploadError( $this->msg( 'windows-nonascii-filename' )->parse() );
598  break;
599 
601  case UploadBase::EMPTY_FILE:
602  $this->showUploadError( $this->msg( 'emptyfile' )->escaped() );
603  break;
604  case UploadBase::FILE_TOO_LARGE:
605  $this->showUploadError( $this->msg( 'largefileserver' )->escaped() );
606  break;
607  case UploadBase::FILETYPE_BADTYPE:
608  $msg = $this->msg( 'filetype-banned-type' );
609  if ( isset( $details['blacklistedExt'] ) ) {
610  $msg->params( $this->getLanguage()->commaList( $details['blacklistedExt'] ) );
611  } else {
612  $msg->params( $details['finalExt'] );
613  }
614  $extensions = array_unique( $wgFileExtensions );
615  $msg->params( $this->getLanguage()->commaList( $extensions ),
616  count( $extensions ) );
617 
618  // Add PLURAL support for the first parameter. This results
619  // in a bit unlogical parameter sequence, but does not break
620  // old translations
621  if ( isset( $details['blacklistedExt'] ) ) {
622  $msg->params( count( $details['blacklistedExt'] ) );
623  } else {
624  $msg->params( 1 );
625  }
626 
627  $this->showUploadError( $msg->parse() );
628  break;
629  case UploadBase::VERIFICATION_ERROR:
630  unset( $details['status'] );
631  $code = array_shift( $details['details'] );
632  $this->showUploadError( $this->msg( $code, $details['details'] )->parse() );
633  break;
634  case UploadBase::HOOK_ABORTED:
635  if ( is_array( $details['error'] ) ) { # allow hooks to return error details in an array
636  $args = $details['error'];
637  $error = array_shift( $args );
638  } else {
639  $error = $details['error'];
640  $args = null;
641  }
642 
643  $this->showUploadError( $this->msg( $error, $args )->parse() );
644  break;
645  default:
646  throw new MWException( __METHOD__ . ": Unknown value `{$details['status']}`" );
647  }
648  }
649 
655  protected function unsaveUploadedFile() {
656  if ( !( $this->mUpload instanceof UploadFromStash ) ) {
657  return true;
658  }
659  $success = $this->mUpload->unsaveUploadedFile();
660  if ( !$success ) {
661  $this->getOutput()->showFileDeleteError( $this->mUpload->getTempPath() );
662 
663  return false;
664  } else {
665  return true;
666  }
667  }
668 
669  /*** Functions for formatting warnings ***/
670 
678  public static function getExistsWarning( $exists ) {
679  if ( !$exists ) {
680  return '';
681  }
682 
683  $file = $exists['file'];
684  $filename = $file->getTitle()->getPrefixedText();
685  $warning = '';
686 
687  if ( $exists['warning'] == 'exists' ) {
688  // Exact match
689  $warning = wfMessage( 'fileexists', $filename )->parse();
690  } elseif ( $exists['warning'] == 'page-exists' ) {
691  // Page exists but file does not
692  $warning = wfMessage( 'filepageexists', $filename )->parse();
693  } elseif ( $exists['warning'] == 'exists-normalized' ) {
694  $warning = wfMessage( 'fileexists-extension', $filename,
695  $exists['normalizedFile']->getTitle()->getPrefixedText() )->parse();
696  } elseif ( $exists['warning'] == 'thumb' ) {
697  // Swapped argument order compared with other messages for backwards compatibility
698  $warning = wfMessage( 'fileexists-thumbnail-yes',
699  $exists['thumbFile']->getTitle()->getPrefixedText(), $filename )->parse();
700  } elseif ( $exists['warning'] == 'thumb-name' ) {
701  // Image w/o '180px-' does not exists, but we do not like these filenames
702  $name = $file->getName();
703  $badPart = substr( $name, 0, strpos( $name, '-' ) + 1 );
704  $warning = wfMessage( 'file-thumbnail-no', $badPart )->parse();
705  } elseif ( $exists['warning'] == 'bad-prefix' ) {
706  $warning = wfMessage( 'filename-bad-prefix', $exists['prefix'] )->parse();
707  } elseif ( $exists['warning'] == 'was-deleted' ) {
708  # If the file existed before and was deleted, warn the user of this
709  $ltitle = SpecialPage::getTitleFor( 'Log' );
710  $llink = Linker::linkKnown(
711  $ltitle,
712  wfMessage( 'deletionlog' )->escaped(),
713  array(),
714  array(
715  'type' => 'delete',
716  'page' => $filename
717  )
718  );
719  $warning = wfMessage( 'filewasdeleted' )->rawParams( $llink )->parseAsBlock();
720  }
721 
722  return $warning;
723  }
724 
730  public function getDupeWarning( $dupes ) {
731  if ( !$dupes ) {
732  return '';
733  }
734 
735  $gallery = ImageGalleryBase::factory();
736  $gallery->setContext( $this->getContext() );
737  $gallery->setShowBytes( false );
738  foreach ( $dupes as $file ) {
739  $gallery->add( $file->getTitle() );
740  }
741 
742  return '<li>' .
743  wfMessage( 'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() .
744  $gallery->toHtml() . "</li>\n";
745  }
746 
747  protected function getGroupName() {
748  return 'media';
749  }
750 }
751 
755 class UploadForm extends HTMLForm {
756  protected $mWatch;
757  protected $mForReUpload;
758  protected $mSessionKey;
759  protected $mHideIgnoreWarning;
760  protected $mDestWarningAck;
761  protected $mDestFile;
762 
763  protected $mComment;
764  protected $mTextTop;
765  protected $mTextAfterSummary;
766 
767  protected $mSourceIds;
768 
769  protected $mMaxFileSize = array();
770 
771  protected $mMaxUploadSize = array();
772 
773  public function __construct( array $options = array(), IContextSource $context = null ) {
774  $this->mWatch = !empty( $options['watch'] );
775  $this->mForReUpload = !empty( $options['forreupload'] );
776  $this->mSessionKey = isset( $options['sessionkey'] ) ? $options['sessionkey'] : '';
777  $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] );
778  $this->mDestWarningAck = !empty( $options['destwarningack'] );
779  $this->mDestFile = isset( $options['destfile'] ) ? $options['destfile'] : '';
780 
781  $this->mComment = isset( $options['description'] ) ?
782  $options['description'] : '';
783 
784  $this->mTextTop = isset( $options['texttop'] )
785  ? $options['texttop'] : '';
786 
787  $this->mTextAfterSummary = isset( $options['textaftersummary'] )
788  ? $options['textaftersummary'] : '';
789 
790  $sourceDescriptor = $this->getSourceSection();
791  $descriptor = $sourceDescriptor
792  + $this->getDescriptionSection()
793  + $this->getOptionsSection();
794 
795  wfRunHooks( 'UploadFormInitDescriptor', array( &$descriptor ) );
796  parent::__construct( $descriptor, $context, 'upload' );
797 
798  # Set some form properties
799  $this->setSubmitText( $this->msg( 'uploadbtn' )->text() );
800  $this->setSubmitName( 'wpUpload' );
801  # Used message keys: 'accesskey-upload', 'tooltip-upload'
802  $this->setSubmitTooltip( 'upload' );
803  $this->setId( 'mw-upload-form' );
804 
805  # Build a list of IDs for javascript insertion
806  $this->mSourceIds = array();
807  foreach ( $sourceDescriptor as $field ) {
808  if ( !empty( $field['id'] ) ) {
809  $this->mSourceIds[] = $field['id'];
810  }
811  }
812  }
813 
820  protected function getSourceSection() {
821  global $wgCopyUploadsFromSpecialUpload;
822 
823  if ( $this->mSessionKey ) {
824  return array(
825  'SessionKey' => array(
826  'type' => 'hidden',
827  'default' => $this->mSessionKey,
828  ),
829  'SourceType' => array(
830  'type' => 'hidden',
831  'default' => 'Stash',
832  ),
833  );
834  }
835 
836  $canUploadByUrl = UploadFromUrl::isEnabled()
837  && UploadFromUrl::isAllowed( $this->getUser() )
838  && $wgCopyUploadsFromSpecialUpload;
839  $radio = $canUploadByUrl;
840  $selectedSourceType = strtolower( $this->getRequest()->getText( 'wpSourceType', 'File' ) );
841 
842  $descriptor = array();
843  if ( $this->mTextTop ) {
844  $descriptor['UploadFormTextTop'] = array(
845  'type' => 'info',
846  'section' => 'source',
847  'default' => $this->mTextTop,
848  'raw' => true,
849  );
850  }
851 
852  $this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize( 'file' );
853  # Limit to upload_max_filesize unless we are running under HipHop and
854  # that setting doesn't exist
855  if ( !wfIsHHVM() ) {
856  $this->mMaxUploadSize['file'] = min( $this->mMaxUploadSize['file'],
857  wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ),
858  wfShorthandToInteger( ini_get( 'post_max_size' ) )
859  );
860  }
861 
862  $descriptor['UploadFile'] = array(
863  'class' => 'UploadSourceField',
864  'section' => 'source',
865  'type' => 'file',
866  'id' => 'wpUploadFile',
867  'radio-id' => 'wpSourceTypeFile',
868  'label-message' => 'sourcefilename',
869  'upload-type' => 'File',
870  'radio' => &$radio,
871  'help' => $this->msg( 'upload-maxfilesize',
872  $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['file'] )
873  )->parse() .
874  $this->msg( 'word-separator' )->escaped() .
875  $this->msg( 'upload_source_file' )->escaped(),
876  'checked' => $selectedSourceType == 'file',
877  );
878 
879  if ( $canUploadByUrl ) {
880  $this->mMaxUploadSize['url'] = UploadBase::getMaxUploadSize( 'url' );
881  $descriptor['UploadFileURL'] = array(
882  'class' => 'UploadSourceField',
883  'section' => 'source',
884  'id' => 'wpUploadFileURL',
885  'radio-id' => 'wpSourceTypeurl',
886  'label-message' => 'sourceurl',
887  'upload-type' => 'url',
888  'radio' => &$radio,
889  'help' => $this->msg( 'upload-maxfilesize',
890  $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['url'] )
891  )->parse() .
892  $this->msg( 'word-separator' )->escaped() .
893  $this->msg( 'upload_source_url' )->escaped(),
894  'checked' => $selectedSourceType == 'url',
895  );
896  }
897  wfRunHooks( 'UploadFormSourceDescriptors', array( &$descriptor, &$radio, $selectedSourceType ) );
898 
899  $descriptor['Extensions'] = array(
900  'type' => 'info',
901  'section' => 'source',
902  'default' => $this->getExtensionsMessage(),
903  'raw' => true,
904  );
905 
906  return $descriptor;
907  }
908 
914  protected function getExtensionsMessage() {
915  # Print a list of allowed file extensions, if so configured. We ignore
916  # MIME type here, it's incomprehensible to most people and too long.
917  global $wgCheckFileExtensions, $wgStrictFileExtensions,
918  $wgFileExtensions, $wgFileBlacklist;
919 
920  if ( $wgCheckFileExtensions ) {
921  if ( $wgStrictFileExtensions ) {
922  # Everything not permitted is banned
923  $extensionsList =
924  '<div id="mw-upload-permitted">' .
925  $this->msg(
926  'upload-permitted',
927  $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) )
928  )->parseAsBlock() .
929  "</div>\n";
930  } else {
931  # We have to list both preferred and prohibited
932  $extensionsList =
933  '<div id="mw-upload-preferred">' .
934  $this->msg(
935  'upload-preferred',
936  $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) )
937  )->parseAsBlock() .
938  "</div>\n" .
939  '<div id="mw-upload-prohibited">' .
940  $this->msg(
941  'upload-prohibited',
942  $this->getContext()->getLanguage()->commaList( array_unique( $wgFileBlacklist ) )
943  )->parseAsBlock() .
944  "</div>\n";
945  }
946  } else {
947  # Everything is permitted.
948  $extensionsList = '';
949  }
950 
951  return $extensionsList;
952  }
953 
960  protected function getDescriptionSection() {
961  if ( $this->mSessionKey ) {
962  $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
963  try {
964  $file = $stash->getFile( $this->mSessionKey );
965  } catch ( MWException $e ) {
966  $file = null;
967  }
968  if ( $file ) {
970 
971  $mto = $file->transform( array( 'width' => 120 ) );
972  $this->addHeaderText(
973  '<div class="thumb t' . $wgContLang->alignEnd() . '">' .
974  Html::element( 'img', array(
975  'src' => $mto->getUrl(),
976  'class' => 'thumbimage',
977  ) ) . '</div>', 'description' );
978  }
979  }
980 
981  $descriptor = array(
982  'DestFile' => array(
983  'type' => 'text',
984  'section' => 'description',
985  'id' => 'wpDestFile',
986  'label-message' => 'destfilename',
987  'size' => 60,
988  'default' => $this->mDestFile,
989  # @todo FIXME: Hack to work around poor handling of the 'default' option in HTMLForm
990  'nodata' => strval( $this->mDestFile ) !== '',
991  ),
992  'UploadDescription' => array(
993  'type' => 'textarea',
994  'section' => 'description',
995  'id' => 'wpUploadDescription',
996  'label-message' => $this->mForReUpload
997  ? 'filereuploadsummary'
998  : 'fileuploadsummary',
999  'default' => $this->mComment,
1000  'cols' => $this->getUser()->getIntOption( 'cols' ),
1001  'rows' => 8,
1002  )
1003  );
1004  if ( $this->mTextAfterSummary ) {
1005  $descriptor['UploadFormTextAfterSummary'] = array(
1006  'type' => 'info',
1007  'section' => 'description',
1008  'default' => $this->mTextAfterSummary,
1009  'raw' => true,
1010  );
1011  }
1012 
1013  $descriptor += array(
1014  'EditTools' => array(
1015  'type' => 'edittools',
1016  'section' => 'description',
1017  'message' => 'edittools-upload',
1018  )
1019  );
1020 
1021  if ( $this->mForReUpload ) {
1022  $descriptor['DestFile']['readonly'] = true;
1023  } else {
1024  $descriptor['License'] = array(
1025  'type' => 'select',
1026  'class' => 'Licenses',
1027  'section' => 'description',
1028  'id' => 'wpLicense',
1029  'label-message' => 'license',
1030  );
1031  }
1032 
1033  global $wgUseCopyrightUpload;
1034  if ( $wgUseCopyrightUpload ) {
1035  $descriptor['UploadCopyStatus'] = array(
1036  'type' => 'text',
1037  'section' => 'description',
1038  'id' => 'wpUploadCopyStatus',
1039  'label-message' => 'filestatus',
1040  );
1041  $descriptor['UploadSource'] = array(
1042  'type' => 'text',
1043  'section' => 'description',
1044  'id' => 'wpUploadSource',
1045  'label-message' => 'filesource',
1046  );
1047  }
1048 
1049  return $descriptor;
1050  }
1058  protected function getOptionsSection() {
1059  $user = $this->getUser();
1060  if ( $user->isLoggedIn() ) {
1061  $descriptor = array(
1062  'Watchthis' => array(
1063  'type' => 'check',
1064  'id' => 'wpWatchthis',
1065  'label-message' => 'watchthisupload',
1066  'section' => 'options',
1067  'default' => $this->mWatch,
1068  )
1069  );
1070  }
1071  if ( !$this->mHideIgnoreWarning ) {
1072  $descriptor['IgnoreWarning'] = array(
1073  'type' => 'check',
1074  'id' => 'wpIgnoreWarning',
1075  'label-message' => 'ignorewarnings',
1076  'section' => 'options',
1077  );
1078  }
1079 
1080  $descriptor['DestFileWarningAck'] = array(
1081  'type' => 'hidden',
1082  'id' => 'wpDestFileWarningAck',
1083  'default' => $this->mDestWarningAck ? '1' : '',
1084  );
1085 
1086  if ( $this->mForReUpload ) {
1087  $descriptor['ForReUpload'] = array(
1088  'type' => 'hidden',
1089  'id' => 'wpForReUpload',
1090  'default' => '1',
1091  );
1092  }
1094  return $descriptor;
1095  }
1096 
1100  public function show() {
1101  $this->addUploadJS();
1102  parent::show();
1103  }
1104 
1108  protected function addUploadJS() {
1109  global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview,
1110  $wgEnableAPI, $wgStrictFileExtensions;
1111 
1112  $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
1113  $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI;
1114  $this->mMaxUploadSize['*'] = UploadBase::getMaxUploadSize();
1115 
1116  $scriptVars = array(
1117  'wgAjaxUploadDestCheck' => $useAjaxDestCheck,
1118  'wgAjaxLicensePreview' => $useAjaxLicensePreview,
1119  'wgUploadAutoFill' => !$this->mForReUpload &&
1120  // If we received mDestFile from the request, don't autofill
1121  // the wpDestFile textbox
1122  $this->mDestFile === '',
1123  'wgUploadSourceIds' => $this->mSourceIds,
1124  'wgStrictFileExtensions' => $wgStrictFileExtensions,
1125  'wgCapitalizeUploads' => MWNamespace::isCapitalized( NS_FILE ),
1126  'wgMaxUploadSize' => $this->mMaxUploadSize,
1127  );
1128 
1129  $out = $this->getOutput();
1130  $out->addJsConfigVars( $scriptVars );
1131 
1132  $out->addModules( array(
1133  'mediawiki.action.edit', // For <charinsert> support
1134  'mediawiki.legacy.upload', // Old form stuff...
1135  'mediawiki.special.upload', // Newer extras for thumbnail preview.
1136  ) );
1137  }
1138 
1144  function trySubmit() {
1145  return false;
1146  }
1147 }
1148 
1152 class UploadSourceField extends HTMLTextField {
1153 
1158  function getLabelHtml( $cellAttributes = array() ) {
1159  $id = $this->mParams['id'];
1160  $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel );
1161 
1162  if ( !empty( $this->mParams['radio'] ) ) {
1163  if ( isset( $this->mParams['radio-id'] ) ) {
1164  $radioId = $this->mParams['radio-id'];
1165  } else {
1166  // Old way. For the benefit of extensions that do not define
1167  // the 'radio-id' key.
1168  $radioId = 'wpSourceType' . $this->mParams['upload-type'];
1169  }
1170 
1171  $attribs = array(
1172  'name' => 'wpSourceType',
1173  'type' => 'radio',
1174  'id' => $radioId,
1175  'value' => $this->mParams['upload-type'],
1176  );
1177 
1178  if ( !empty( $this->mParams['checked'] ) ) {
1179  $attribs['checked'] = 'checked';
1180  }
1181 
1182  $label .= Html::element( 'input', $attribs );
1183  }
1185  return Html::rawElement( 'td', array( 'class' => 'mw-label' ) + $cellAttributes, $label );
1186  }
1187 
1191  function getSize() {
1192  return isset( $this->mParams['size'] )
1193  ? $this->mParams['size']
1194  : 60;
1195  }
1196 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:488
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:33
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
FauxRequest
WebRequest clone which takes values from a provided array.
Definition: WebRequest.php:1275
ContextSource\getContext
getContext()
Get the RequestContext object.
Definition: ContextSource.php:40
SpecialUpload\userCanExecute
userCanExecute(User $user)
This page can be shown if uploading is enabled.
Definition: SpecialUpload.php:132
of
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
Definition: globals.txt:10
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled also a ContextSource error or success you ll probably need to make sure the header is varied on WebRequest $request
Definition: hooks.txt:1961
RepoGroup\singleton
static singleton()
Get a RepoGroup instance.
Definition: RepoGroup.php:53
UploadForm\getDescriptionSection
getDescriptionSection()
Get the descriptor of the fieldset that contains the file description input.
Definition: SpecialUpload.php:953
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
UserBlockedError
Show an error when the user tries to do something whilst blocked.
Definition: UserBlockedError.php:27
HTMLForm\setSubmitName
setSubmitName( $name)
Definition: HTMLForm.php:997
ContextSource\msg
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:175
UploadForm\show
show()
Add the upload JS and show the form.
Definition: SpecialUpload.php:1093
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:535
UploadForm\getSourceSection
getSourceSection()
Get the descriptor of the fieldset that contains the file source selection.
Definition: SpecialUpload.php:813
SpecialUpload\$mSourceType
$mSourceType
Definition: SpecialUpload.php:44
SpecialPage\getTitle
getTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:477
SpecialUpload\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialUpload.php:740
HTMLForm\setSubmitTooltip
setSubmitTooltip( $name)
Definition: HTMLForm.php:1008
$extensions
$extensions
Definition: importImages.php:62
HTMLForm\addHeaderText
addHeaderText( $msg, $section=null)
Add header text, inside the form.
Definition: HTMLForm.php:550
UploadForm\$mForReUpload
$mForReUpload
Definition: SpecialUpload.php:750
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
$form
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead $form
Definition: hooks.txt:2584
SpecialUpload\$mUploadClicked
$mUploadClicked
Definition: SpecialUpload.php:49
UploadForm
Sub class of HTMLForm that provides the form section of SpecialUpload.
Definition: SpecialUpload.php:748
UploadSourceField\getSize
getSize()
Definition: SpecialUpload.php:1184
NS_FILE
const NS_FILE
Definition: Defines.php:85
ImageGalleryBase\factory
static factory( $mode=false)
Get a new image gallery.
Definition: ImageGalleryBase.php:66
SpecialUpload\processUpload
processUpload()
Do the upload.
Definition: SpecialUpload.php:400
SpecialUpload\$mCopyrightStatus
$mCopyrightStatus
Definition: SpecialUpload.php:61
SpecialUpload\unsaveUploadedFile
unsaveUploadedFile()
Remove a temporarily kept file stashed by saveTempUploadedFile().
Definition: SpecialUpload.php:648
UploadForm\$mComment
$mComment
Definition: SpecialUpload.php:756
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
UploadFromStash
Implements uploading from previously stored file.
Definition: UploadFromStash.php:30
SpecialUpload\$mLocalFile
LocalFile $mLocalFile
Definition: SpecialUpload.php:48
UploadForm\$mTextAfterSummary
$mTextAfterSummary
Definition: SpecialUpload.php:758
UploadSourceField
A form field that contains a radio box in the label.
Definition: SpecialUpload.php:1145
ContextSource\getRequest
getRequest()
Get the WebRequest object.
Definition: ContextSource.php:77
PermissionsError
Show an error when a user tries to do something they do not have the necessary permissions for.
Definition: PermissionsError.php:28
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:578
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:132
$link
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
Definition: hooks.txt:2160
UploadForm\$mDestFile
$mDestFile
Definition: SpecialUpload.php:754
SpecialUpload\showViewDeletedLinks
showViewDeletedLinks()
Shows the "view X deleted revivions link"".
Definition: SpecialUpload.php:281
Title\exists
exists()
Check if page exists.
Definition: Title.php:4502
SpecialUpload\$mDestWarningAck
$mDestWarningAck
Hidden variables.
Definition: SpecialUpload.php:66
Linker\linkKnown
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:264
SpecialUpload\getExistsWarning
static getExistsWarning( $exists)
Formats a result of UploadBase::getExistsWarning as HTML This check is static and can be done pre-upl...
Definition: SpecialUpload.php:671
HTMLTextField
Definition: HTMLTextField.php:3
UploadForm\trySubmit
trySubmit()
Empty function; submission is handled elsewhere.
Definition: SpecialUpload.php:1137
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:154
HTMLForm\setSubmitText
setSubmitText( $t)
Set the text for the submit button.
Definition: HTMLForm.php:962
SpecialUpload\showUploadWarning
showUploadWarning( $warnings)
Stashes the upload, shows the main form, but adds a "continue anyway button".
Definition: SpecialUpload.php:328
SpecialUpload\getDupeWarning
getDupeWarning( $dupes)
Construct a warning and a gallery from an array of duplicate files.
Definition: SpecialUpload.php:723
SpecialUpload\showRecoverableUploadError
showRecoverableUploadError( $message)
Stashes the upload and shows the main upload form.
Definition: SpecialUpload.php:310
UploadForm\getExtensionsMessage
getExtensionsMessage()
Get the messages indicating which extensions are preferred and prohibitted.
Definition: SpecialUpload.php:907
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:32
$success
$success
Definition: Utf8Test.php:91
UploadForm\$mHideIgnoreWarning
$mHideIgnoreWarning
Definition: SpecialUpload.php:752
MWException
MediaWiki exception.
Definition: MWException.php:26
$out
$out
Definition: UtfNormalGenerate.php:167
SpecialUpload\$mRequest
WebRequest FauxRequest $mRequest
Misc variables.
Definition: SpecialUpload.php:43
hooks
Using a hook running we can avoid having all this option specific stuff in our mainline code Using hooks
Definition: hooks.txt:73
Html\element
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:148
SpecialUpload\$mDesiredDestName
string $mDesiredDestName
User input variables from the "description" section.
Definition: SpecialUpload.php:53
SpecialUpload\$uploadFormTextAfterSummary
$uploadFormTextAfterSummary
Definition: SpecialUpload.php:77
UploadFromUrl\isEnabled
static isEnabled()
Checks if the upload from URL feature is enabled.
Definition: UploadFromUrl.php:59
SpecialUpload\$mCancelUpload
bool $mCancelUpload
The user clicked "Cancel and return to upload form" button *.
Definition: SpecialUpload.php:70
ContextSource\getOutput
getOutput()
Get the OutputPage object.
Definition: ContextSource.php:122
UploadSourceField\getLabelHtml
getLabelHtml( $cellAttributes=array())
Definition: SpecialUpload.php:1151
wfMessage
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4066
SpecialUpload\execute
execute( $par)
Special page entry point.
Definition: SpecialUpload.php:139
SpecialUpload\$mCopyrightSource
$mCopyrightSource
Definition: SpecialUpload.php:62
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:352
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:545
SpecialUpload\$mUpload
UploadBase $mUpload
Definition: SpecialUpload.php:46
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$comment
$comment
Definition: importImages.php:107
$wgFileExtensions
if(! $wgHtml5Version && $wgAllowRdfaAttributes) $wgFileExtensions
Definition: Setup.php:369
SpecialUpload\$mComment
$mComment
Definition: SpecialUpload.php:54
SpecialUpload\loadRequest
loadRequest()
Initialize instance variables from request and create an Upload handler.
Definition: SpecialUpload.php:82
LocalFile
Class to represent a local file in the wiki's own database.
Definition: LocalFile.php:46
UploadForm\addUploadJS
addUploadJS()
Add upload JS to the OutputPage.
Definition: SpecialUpload.php:1101
SpecialUpload
Form for handling uploads and special page.
Definition: SpecialUpload.php:31
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:508
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1530
SpecialUpload\$mForReUpload
bool $mForReUpload
The user followed an "overwrite this file" link *.
Definition: SpecialUpload.php:68
UploadForm\$mMaxFileSize
$mMaxFileSize
Definition: SpecialUpload.php:762
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:980
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:422
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
SpecialUpload\$mLicense
$mLicense
Definition: SpecialUpload.php:55
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:609
UploadForm\$mWatch
$mWatch
Definition: SpecialUpload.php:749
UploadForm\$mTextTop
$mTextTop
Definition: SpecialUpload.php:757
HTMLForm\setId
setId( $id)
Definition: HTMLForm.php:1064
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:33
SpecialUpload\getUploadForm
getUploadForm( $message='', $sessionKey='', $hideIgnoreWarning=false)
Get an UploadForm instance with title and text properly set.
Definition: SpecialUpload.php:221
SpecialUpload\showUploadError
showUploadError( $message)
Show the upload form with error message, but do not stash the file.
Definition: SpecialUpload.php:390
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:525
UploadForm\$mMaxUploadSize
$mMaxUploadSize
Definition: SpecialUpload.php:764
SpecialUpload\getInitialPageText
static getInitialPageText( $comment='', $license='', $copyStatus='', $source='')
Get the initial image page text based on a comment and optional file status information.
Definition: SpecialUpload.php:489
SpecialUpload\showUploadForm
showUploadForm( $form)
Show the main upload form.
Definition: SpecialUpload.php:200
UploadForm\__construct
__construct(array $options=array(), IContextSource $context=null)
Definition: SpecialUpload.php:766
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
IContextSource
Interface for objects which can provide a context on request.
Definition: IContextSource.php:29
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
Definition: WebRequest.php:38
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
$count
$count
Definition: UtfNormalTest2.php:96
UploadForm\$mSourceIds
$mSourceIds
Definition: SpecialUpload.php:760
$args
if( $line===false) $args
Definition: cdb.php:62
UploadForm\$mSessionKey
$mSessionKey
Definition: SpecialUpload.php:751
wfShorthandToInteger
wfShorthandToInteger( $string='', $default=-1)
Converts shorthand byte notation to integer form.
Definition: GlobalFunctions.php:3954
Title
Represents a title within MediaWiki.
Definition: Title.php:35
in
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning in
Definition: maintenance.txt:1
SpecialUpload\$mWatchthis
$mWatchthis
Definition: SpecialUpload.php:60
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
MWNamespace\isCapitalized
static isCapitalized( $index)
Is the namespace first-letter capitalized?
Definition: Namespace.php:378
$source
if(PHP_SAPI !='cli') $source
Definition: mwdoc-filter.php:18
SpecialUpload\__construct
__construct( $request=null)
Constructor : initialise object Get data POSTed through the form and assign them to the object.
Definition: SpecialUpload.php:37
UploadFromUrl\isAllowed
static isAllowed( $user)
Checks if the user is allowed to use the upload-by-URL feature.
Definition: UploadFromUrl.php:48
SpecialPage\checkReadOnly
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
Definition: SpecialPage.php:300
SpecialUpload\processVerificationError
processVerificationError( $details)
Provides output to the user for a result of UploadBase::verifyUpload.
Definition: SpecialUpload.php:570
$error
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
Definition: hooks.txt:2584
Html\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:124
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
wfIsHHVM
wfIsHHVM()
Check if we are running under HHVM.
Definition: GlobalFunctions.php:2584
$attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1530
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:59
UploadForm\getOptionsSection
getOptionsSection()
Get the descriptor of the fieldset that contains the upload options, such as "watch this file".
Definition: SpecialUpload.php:1051
wfLocalFile
wfLocalFile( $title)
Get an object referring to a locally registered file.
Definition: GlobalFunctions.php:3768
SpecialUpload\$uploadFormTextTop
$uploadFormTextTop
Text injection points for hooks not using HTMLForm.
Definition: SpecialUpload.php:76
SpecialUpload\$mUploadSuccessful
bool $mUploadSuccessful
Subclasses can use this to determine whether a file was uploaded *.
Definition: SpecialUpload.php:73
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:443
SpecialUpload\$mTokenOk
$mTokenOk
Definition: SpecialUpload.php:71
SpecialUpload\$mIgnoreWarning
$mIgnoreWarning
User input variables from the root section.
Definition: SpecialUpload.php:59
SpecialUpload\getWatchCheck
getWatchCheck()
See if we should check the 'watch this page' checkbox on the form based on the user's preferences and...
Definition: SpecialUpload.php:541
UploadForm\$mDestWarningAck
$mDestWarningAck
Definition: SpecialUpload.php:753
$license
$license
Definition: importImages.php:123
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:1632
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=array(), $page='', $user='', $param=array())
Show log extract.
Definition: LogEventsList.php:507
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition: HTMLForm.php:100