Go to the documentation of this file.
41 parent::__construct(
'Upload',
'upload' );
98 $this->mSourceType =
$request->getVal(
'wpSourceType',
'file' );
99 $this->mUpload = UploadBase::createFromRequest(
$request );
100 $this->mUploadClicked =
$request->wasPosted()
101 && (
$request->getCheck(
'wpUpload' )
102 ||
$request->getCheck(
'wpUploadIgnoreWarning' ) );
105 $this->mDesiredDestName =
$request->getText(
'wpDestFile' );
106 if ( !$this->mDesiredDestName &&
$request->getFileName(
'wpUploadFile' ) !== null ) {
107 $this->mDesiredDestName =
$request->getFileName(
'wpUploadFile' );
109 $this->mLicense =
$request->getText(
'wpLicense' );
111 $this->mDestWarningAck =
$request->getText(
'wpDestFileWarningAck' );
112 $this->mIgnoreWarning =
$request->getCheck(
'wpIgnoreWarning' )
113 ||
$request->getCheck(
'wpUploadIgnoreWarning' );
114 $this->mWatchthis =
$request->getBool(
'wpWatchthis' ) && $this->
getUser()->isLoggedIn();
115 $this->mCopyrightStatus =
$request->getText(
'wpUploadCopyStatus' );
116 $this->mCopyrightSource =
$request->getText(
'wpUploadSource' );
118 $this->mForReUpload =
$request->getBool(
'wpForReUpload' );
120 $commentDefault =
'';
121 $commentMsg =
wfMessage(
'upload-default-description' )->inContentLanguage();
122 if ( !$this->mForReUpload && !$commentMsg->isDisabled() ) {
123 $commentDefault = $commentMsg->plain();
125 $this->mComment =
$request->getText(
'wpUploadDescription', $commentDefault );
127 $this->mCancelUpload =
$request->getCheck(
'wpCancelUpload' )
128 ||
$request->getCheck(
'wpReUpload' );
131 $token =
$request->getVal(
'wpEditToken' );
132 $this->mTokenOk = $this->
getUser()->matchEditToken( $token );
134 $this->uploadFormTextTop =
'';
135 $this->uploadFormTextAfterSummary =
'';
147 return UploadBase::isEnabled() && parent::userCanExecute(
$user );
167 # Check uploading enabled
168 if ( !UploadBase::isEnabled() ) {
169 throw new ErrorPageError(
'uploaddisabled',
'uploaddisabledtext' );
176 $permissionRequired = UploadBase::isAllowed(
$user );
177 if ( $permissionRequired !==
true ) {
182 if (
$user->isBlocked() ) {
187 if (
$user->isBlockedGlobally() ) {
191 # Check whether we actually want to allow changing stuff
196 # Unsave the temporary file in case this was a cancelled upload
197 if ( $this->mCancelUpload ) {
199 # Something went wrong, so unsaveUploadedFile showed a warning
204 # Process upload or show a form
206 $this->mTokenOk && !$this->mCancelUpload &&
207 ( $this->mUpload && $this->mUploadClicked )
211 # Backwards compatibility hook
214 if ( !
Hooks::run(
'UploadForm:initial', [ &$upload ] ) ) {
215 wfDebug(
"Hook 'UploadForm:initial' broke output of the upload form\n" );
223 if ( $this->mUpload ) {
224 $this->mUpload->cleanupTempFile();
234 # Add links if file was previously deleted
235 if ( $this->mDesiredDestName ) {
254 protected function getUploadForm( $message =
'', $sessionKey =
'', $hideIgnoreWarning =
false ) {
260 'forreupload' => $this->mForReUpload,
261 'sessionkey' => $sessionKey,
262 'hideignorewarning' => $hideIgnoreWarning,
263 'destwarningack' => (
bool)$this->mDestWarningAck,
265 'description' => $this->mComment,
266 'texttop' => $this->uploadFormTextTop,
267 'textaftersummary' => $this->uploadFormTextAfterSummary,
268 'destfile' => $this->mDesiredDestName,
271 # Check the token, but only if necessary
273 !$this->mTokenOk && !$this->mCancelUpload &&
274 ( $this->mUpload && $this->mUploadClicked )
276 $form->addPreText( $this->
msg(
'session_fail_preview' )->parse() );
279 # Give a notice if the user is uploading a file that has been deleted or moved
280 # Note that this is independent from the message 'filewasdeleted'
283 if ( $desiredTitleObj instanceof
Title && !$desiredTitleObj->
exists() ) {
289 'conds' => [
'log_action != ' .
$dbr->addQuotes(
'revision' ) ],
290 'showIfEmpty' =>
false,
291 'msgKey' => [
'upload-recreate-warning' ] ]
294 $form->addPreText( $delNotice );
297 $form->addPreText(
'<div id="uploadtext">' .
298 $this->
msg(
'uploadtext', [ $this->mDesiredDestName ] )->parseAsBlock() .
300 # Add upload error message
301 $form->addPreText( $message );
304 $uploadFooter = $this->
msg(
'uploadfooter' );
305 if ( !$uploadFooter->isDisabled() ) {
306 $form->addPostText(
'<div id="mw-upload-footer-message">'
307 . $uploadFooter->parseAsBlock() .
"</div>\n" );
321 $count =
$title->isDeleted();
322 if ( $count > 0 &&
$user->isAllowed(
'deletedhistory' ) ) {
325 $this->
msg(
'restorelink' )->numParams( $count )->text()
327 $link = $this->
msg(
$user->isAllowed(
'delete' ) ?
'thisisdeleted' :
'viewdeleted' )
328 ->rawParams( $restorelink )->parseAsBlock();
329 $this->
getOutput()->addHTML(
"<div id=\"contentSub2\">{$link}</div>" );
346 $stashStatus = $this->mUpload->tryStashFile( $this->
getUser() );
347 if ( $stashStatus->isGood() ) {
348 $sessionKey = $stashStatus->getValue()->getFileKey();
353 $message =
'<h2>' . $this->
msg(
'uploaderror' )->escaped() .
"</h2>\n" .
354 '<div class="error">' . $message .
"</div>\n";
357 $form->setSubmitText( $this->
msg(
'upload-tryagain' )->escaped() );
370 # If there are no warnings, or warnings we can ignore, return early.
371 # mDestWarningAck is set when some javascript has shown the warning
372 # to the user. mForReUpload is set when the user clicks the "upload a
374 if ( !$warnings || (
count( $warnings ) == 1
375 && isset( $warnings[
'exists'] )
376 && ( $this->mDestWarningAck || $this->mForReUpload ) )
381 $stashStatus = $this->mUpload->tryStashFile( $this->
getUser() );
382 if ( $stashStatus->isGood() ) {
383 $sessionKey = $stashStatus->getValue()->getFileKey();
390 $this->
getOutput()->addModuleStyles(
'mediawiki.special.upload.styles' );
393 $warningHtml =
'<h2>' . $this->
msg(
'uploadwarning' )->escaped() .
"</h2>\n"
394 .
'<div class="mw-destfile-warning"><ul>';
395 foreach ( $warnings
as $warning =>
$args ) {
396 if ( $warning ==
'badfilename' ) {
399 if ( $warning ==
'exists' ) {
401 } elseif ( $warning ==
'no-change' ) {
403 $filename = $file->getTitle()->getPrefixedText();
404 $msg =
"\t<li>" .
wfMessage(
'fileexists-no-change', $filename )->parse() .
"</li>\n";
405 } elseif ( $warning ==
'duplicate-version' ) {
408 $filename = $file->getTitle()->getPrefixedText();
409 $message =
wfMessage(
'fileexists-duplicate-version' )
410 ->params( $filename )
411 ->numParams( $count );
412 $msg =
"\t<li>" . $message->parse() .
"</li>\n";
413 } elseif ( $warning ==
'was-deleted' ) {
414 # If the file existed before and was deleted, warn the user of this
425 $msg =
"\t<li>" .
wfMessage(
'filewasdeleted' )->rawParams( $llink )->parse() .
"</li>\n";
426 } elseif ( $warning ==
'duplicate' ) {
428 } elseif ( $warning ==
'duplicate-archive' ) {
429 if (
$args ===
'' ) {
430 $msg =
"\t<li>" . $this->
msg(
'file-deleted-duplicate-notitle' )->parse()
433 $msg =
"\t<li>" . $this->
msg(
'file-deleted-duplicate',
438 if (
$args ===
true ) {
440 } elseif ( !is_array(
$args ) ) {
443 $msg =
"\t<li>" . $this->
msg( $warning,
$args )->parse() .
"</li>\n";
445 $warningHtml .= $msg;
447 $warningHtml .=
"</ul></div>\n";
448 $warningHtml .= $this->
msg(
'uploadwarning-text' )->parseAsBlock();
450 $form = $this->
getUploadForm( $warningHtml, $sessionKey,
true );
451 $form->setSubmitText( $this->
msg(
'upload-tryagain' )->
text() );
453 'name' =>
'wpUploadIgnoreWarning',
454 'value' => $this->
msg(
'ignorewarning' )->
text()
457 'name' =>
'wpCancelUpload',
458 'value' => $this->
msg(
'reuploaddesc' )->
text()
463 # Indicate that we showed a form
473 $message =
'<h2>' . $this->
msg(
'uploadwarning' )->escaped() .
"</h2>\n" .
474 '<div class="error">' . $message .
"</div>\n";
484 $status = $this->mUpload->fetchFile();
492 if ( !
Hooks::run(
'UploadForm:BeforeProcessing', [ &$upload ] ) ) {
493 wfDebug(
"Hook 'UploadForm:BeforeProcessing' broke processing the file.\n" );
503 $details = $this->mUpload->verifyUpload();
504 if ( $details[
'status'] != UploadBase::OK ) {
511 $permErrors = $this->mUpload->verifyTitlePermissions( $this->
getUser() );
512 if ( $permErrors !==
true ) {
513 $code = array_shift( $permErrors[0] );
519 $this->mLocalFile = $this->mUpload->getLocalFile();
522 if ( !$this->mIgnoreWarning ) {
523 $warnings = $this->mUpload->checkWarnings();
530 if ( UploadBase::isThrottled( $this->
getUser() ) ) {
532 $this->
msg(
'actionthrottledtext' )->escaped()
538 if ( !$this->mForReUpload ) {
540 $this->mCopyrightStatus, $this->mCopyrightSource, $this->
getConfig() );
545 $changeTags = $this->
getRequest()->getVal(
'wpChangeTags' );
546 if ( is_null( $changeTags ) || $changeTags ===
'' ) {
549 $changeTags = array_filter( array_map(
'trim', explode(
',', $changeTags ) ) );
554 $changeTags, $this->
getUser() );
555 if ( !$changeTagsStatus->isOK() ) {
562 $status = $this->mUpload->performUpload(
577 $this->mUploadSuccessful =
true;
580 Hooks::run(
'SpecialUploadComplete', [ &$upload ] );
581 $this->
getOutput()->redirect( $this->mLocalFile->getTitle()->getFullURL() );
594 $copyStatus =
'',
$source =
'', Config $config =
null
596 if ( $config ===
null ) {
597 wfDebug( __METHOD__ .
' called without a Config instance passed to it' );
598 $config = MediaWikiServices::getInstance()->getMainConfig();
602 $forceUIMsgAsContentMsg = (
array)$config->get(
'ForceUIMsgAsContentMsg' );
607 foreach ( [
'license-header',
'filedesc',
'filestatus',
'filesource' ]
as $msgName ) {
608 if ( in_array( $msgName, $forceUIMsgAsContentMsg ) ) {
609 $msg[$msgName] =
"{{int:$msgName}}";
611 $msg[$msgName] =
wfMessage( $msgName )->inContentLanguage()->text();
615 if ( $config->get(
'UseCopyrightUpload' ) ) {
617 if ( $license !=
'' ) {
618 $licensetxt =
'== ' . $msg[
'license-header'] .
" ==\n" .
'{{' . $license .
'}}' .
"\n";
620 $pageText =
'== ' . $msg[
'filedesc'] .
" ==\n" . $comment .
"\n" .
621 '== ' . $msg[
'filestatus'] .
" ==\n" . $copyStatus .
"\n" .
623 '== ' . $msg[
'filesource'] .
" ==\n" .
$source;
625 if ( $license !=
'' ) {
626 $filedesc = $comment ==
'' ?
'' :
'== ' . $msg[
'filedesc'] .
" ==\n" . $comment .
"\n";
627 $pageText = $filedesc .
628 '== ' . $msg[
'license-header'] .
" ==\n" .
'{{' . $license .
'}}' .
"\n";
630 $pageText = $comment;
650 if ( $this->
getUser()->getOption(
'watchdefault' ) ) {
656 if ( $desiredTitleObj instanceof
Title && $this->
getUser()->isWatched( $desiredTitleObj ) ) {
662 if ( $local && $local->exists() ) {
668 return $this->
getUser()->getOption(
'watchcreations' ) ||
669 $this->
getUser()->getOption(
'watchuploads' );
680 switch ( $details[
'status'] ) {
683 case UploadBase::MIN_LENGTH_PARTNAME:
686 case UploadBase::ILLEGAL_FILENAME:
688 $details[
'filtered'] )->parse() );
690 case UploadBase::FILENAME_TOO_LONG:
693 case UploadBase::FILETYPE_MISSING:
696 case UploadBase::WINDOWS_NONASCII_FILENAME:
701 case UploadBase::EMPTY_FILE:
704 case UploadBase::FILE_TOO_LARGE:
707 case UploadBase::FILETYPE_BADTYPE:
708 $msg = $this->
msg(
'filetype-banned-type' );
709 if ( isset( $details[
'blacklistedExt'] ) ) {
710 $msg->params( $this->
getLanguage()->commaList( $details[
'blacklistedExt'] ) );
712 $msg->params( $details[
'finalExt'] );
714 $extensions = array_unique( $this->
getConfig()->
get(
'FileExtensions' ) );
715 $msg->params( $this->
getLanguage()->commaList( $extensions ),
716 count( $extensions ) );
721 if ( isset( $details[
'blacklistedExt'] ) ) {
722 $msg->params(
count( $details[
'blacklistedExt'] ) );
729 case UploadBase::VERIFICATION_ERROR:
730 unset( $details[
'status'] );
731 $code = array_shift( $details[
'details'] );
734 case UploadBase::HOOK_ABORTED:
735 if ( is_array( $details[
'error'] ) ) { # allow
hooks to
return error details
in an
array
736 $args = $details[
'error'];
737 $error = array_shift(
$args );
739 $error = $details[
'error'];
746 throw new MWException( __METHOD__ .
": Unknown value `{$details['status']}`" );
759 $success = $this->mUpload->unsaveUploadedFile();
761 $this->
getOutput()->showFileDeleteError( $this->mUpload->getTempPath() );
783 $file = $exists[
'file'];
784 $filename = $file->getTitle()->getPrefixedText();
787 if ( $exists[
'warning'] ==
'exists' ) {
789 $warnMsg =
wfMessage(
'fileexists', $filename );
790 } elseif ( $exists[
'warning'] ==
'page-exists' ) {
792 $warnMsg =
wfMessage(
'filepageexists', $filename );
793 } elseif ( $exists[
'warning'] ==
'exists-normalized' ) {
794 $warnMsg =
wfMessage(
'fileexists-extension', $filename,
795 $exists[
'normalizedFile']->
getTitle()->getPrefixedText() );
796 } elseif ( $exists[
'warning'] ==
'thumb' ) {
798 $warnMsg =
wfMessage(
'fileexists-thumbnail-yes',
799 $exists[
'thumbFile']->
getTitle()->getPrefixedText(), $filename );
800 } elseif ( $exists[
'warning'] ==
'thumb-name' ) {
802 $name = $file->getName();
803 $badPart = substr(
$name, 0, strpos(
$name,
'-' ) + 1 );
804 $warnMsg =
wfMessage(
'file-thumbnail-no', $badPart );
805 } elseif ( $exists[
'warning'] ==
'bad-prefix' ) {
806 $warnMsg =
wfMessage(
'filename-bad-prefix', $exists[
'prefix'] );
809 return $warnMsg ? $warnMsg->title( $file->getTitle() )->parse() :
'';
823 $gallery->setShowBytes(
false );
824 foreach ( $dupes
as $file ) {
825 $gallery->add( $file->getTitle() );
829 $this->
msg(
'file-exists-duplicate' )->numParams(
count( $dupes ) )->parse() .
830 $gallery->toHTML() .
"</li>\n";
846 return $bitmapHandler->autoRotateEnabled();
879 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
882 $this->mWatch = !empty(
$options[
'watch'] );
883 $this->mForReUpload = !empty(
$options[
'forreupload'] );
884 $this->mSessionKey = isset(
$options[
'sessionkey'] ) ?
$options[
'sessionkey'] :
'';
885 $this->mHideIgnoreWarning = !empty(
$options[
'hideignorewarning'] );
886 $this->mDestWarningAck = !empty(
$options[
'destwarningack'] );
887 $this->mDestFile = isset(
$options[
'destfile'] ) ?
$options[
'destfile'] :
'';
889 $this->mComment = isset(
$options[
'description'] ) ?
892 $this->mTextTop = isset(
$options[
'texttop'] )
895 $this->mTextAfterSummary = isset(
$options[
'textaftersummary'] )
896 ?
$options[
'textaftersummary'] :
'';
899 $descriptor = $sourceDescriptor
903 Hooks::run(
'UploadFormInitDescriptor', [ &$descriptor ] );
904 parent::__construct( $descriptor,
$context,
'upload' );
906 # Add a link to edit MediaWiki:Licenses
907 if ( $this->
getUser()->isAllowed(
'editinterface' ) ) {
908 $this->
getOutput()->addModuleStyles(
'mediawiki.special.upload.styles' );
910 $this->
msg(
'licenses' )->inContentLanguage()->
getTitle(),
911 $this->
msg(
'licenses-edit' )->
text(),
913 [
'action' =>
'edit' ]
915 $editLicenses =
'<p class="mw-upload-editlicenses">' . $licensesLink .
'</p>';
919 # Set some form properties
922 # Used message keys: 'accesskey-upload', 'tooltip-upload'
924 $this->
setId(
'mw-upload-form' );
926 # Build a list of IDs for javascript insertion
927 $this->mSourceIds = [];
928 foreach ( $sourceDescriptor
as $field ) {
929 if ( !empty( $field[
'id'] ) ) {
930 $this->mSourceIds[] = $field[
'id'];
942 if ( $this->mSessionKey ) {
950 'default' =>
'Stash',
957 && $this->
getConfig()->get(
'CopyUploadsFromSpecialUpload' );
958 $radio = $canUploadByUrl;
959 $selectedSourceType = strtolower( $this->
getRequest()->getText(
'wpSourceType',
'File' ) );
962 if ( $this->mTextTop ) {
963 $descriptor[
'UploadFormTextTop'] = [
965 'section' =>
'source',
971 $this->mMaxUploadSize[
'file'] = min(
972 UploadBase::getMaxUploadSize(
'file' ),
973 UploadBase::getMaxPhpUploadSize()
976 $help = $this->
msg(
'upload-maxfilesize',
982 if ( $canUploadByUrl ) {
983 $help .= $this->
msg(
'word-separator' )->escaped();
984 $help .= $this->
msg(
'upload_source_file' )->parse();
987 $descriptor[
'UploadFile'] = [
988 'class' =>
'UploadSourceField',
989 'section' =>
'source',
991 'id' =>
'wpUploadFile',
992 'radio-id' =>
'wpSourceTypeFile',
993 'label-message' =>
'sourcefilename',
994 'upload-type' =>
'File',
997 'checked' => $selectedSourceType ==
'file',
1000 if ( $canUploadByUrl ) {
1001 $this->mMaxUploadSize[
'url'] = UploadBase::getMaxUploadSize(
'url' );
1002 $descriptor[
'UploadFileURL'] = [
1003 'class' =>
'UploadSourceField',
1004 'section' =>
'source',
1005 'id' =>
'wpUploadFileURL',
1006 'radio-id' =>
'wpSourceTypeurl',
1007 'label-message' =>
'sourceurl',
1008 'upload-type' =>
'url',
1010 'help' => $this->
msg(
'upload-maxfilesize',
1013 $this->
msg(
'word-separator' )->escaped() .
1014 $this->
msg(
'upload_source_url' )->parse(),
1015 'checked' => $selectedSourceType ==
'url',
1018 Hooks::run(
'UploadFormSourceDescriptors', [ &$descriptor, &$radio, $selectedSourceType ] );
1020 $descriptor[
'Extensions'] = [
1022 'section' =>
'source',
1036 # Print a list of allowed file extensions, if so configured. We ignore
1037 # MIME type here, it's incomprehensible to most people and too long.
1040 if ( $config->get(
'CheckFileExtensions' ) ) {
1041 $fileExtensions = array_unique( $config->get(
'FileExtensions' ) );
1042 if ( $config->get(
'StrictFileExtensions' ) ) {
1043 # Everything not permitted is banned
1045 '<div id="mw-upload-permitted">' .
1046 $this->
msg(
'upload-permitted' )
1047 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
1048 ->numParams(
count( $fileExtensions ) )
1052 # We have to list both preferred and prohibited
1053 $fileBlacklist = array_unique( $config->get(
'FileBlacklist' ) );
1055 '<div id="mw-upload-preferred">' .
1056 $this->
msg(
'upload-preferred' )
1057 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
1058 ->numParams(
count( $fileExtensions ) )
1061 '<div id="mw-upload-prohibited">' .
1062 $this->
msg(
'upload-prohibited' )
1063 ->params( $this->
getLanguage()->commaList( $fileBlacklist ) )
1064 ->numParams(
count( $fileBlacklist ) )
1069 # Everything is permitted.
1070 $extensionsList =
'';
1073 return $extensionsList;
1084 if ( $this->mSessionKey ) {
1087 $file = $stash->getFile( $this->mSessionKey );
1088 }
catch ( Exception
$e ) {
1094 $mto = $file->transform( [
'width' => 120 ] );
1097 '<div class="thumb t' . $wgContLang->alignEnd() .
'">' .
1099 'src' => $mto->getUrl(),
1100 'class' =>
'thumbimage',
1101 ] ) .
'</div>',
'description' );
1109 'section' =>
'description',
1110 'id' =>
'wpDestFile',
1111 'label-message' =>
'destfilename',
1114 # @todo FIXME: Hack to work around poor handling of the 'default' option in HTMLForm
1115 'nodata' => strval( $this->mDestFile ) !==
'',
1117 'UploadDescription' => [
1118 'type' =>
'textarea',
1119 'section' =>
'description',
1120 'id' =>
'wpUploadDescription',
1121 'label-message' => $this->mForReUpload
1122 ?
'filereuploadsummary'
1123 :
'fileuploadsummary',
1129 if ( $this->mTextAfterSummary ) {
1130 $descriptor[
'UploadFormTextAfterSummary'] = [
1132 'section' =>
'description',
1140 'type' =>
'edittools',
1141 'section' =>
'description',
1142 'message' =>
'edittools-upload',
1146 if ( $this->mForReUpload ) {
1147 $descriptor[
'DestFile'][
'readonly'] =
true;
1149 $descriptor[
'License'] = [
1151 'class' =>
'Licenses',
1152 'section' =>
'description',
1153 'id' =>
'wpLicense',
1154 'label-message' =>
'license',
1158 if ( $config->get(
'UseCopyrightUpload' ) ) {
1159 $descriptor[
'UploadCopyStatus'] = [
1161 'section' =>
'description',
1162 'id' =>
'wpUploadCopyStatus',
1163 'label-message' =>
'filestatus',
1165 $descriptor[
'UploadSource'] = [
1167 'section' =>
'description',
1168 'id' =>
'wpUploadSource',
1169 'label-message' =>
'filesource',
1184 if (
$user->isLoggedIn() ) {
1188 'id' =>
'wpWatchthis',
1189 'label-message' =>
'watchthisupload',
1190 'section' =>
'options',
1195 if ( !$this->mHideIgnoreWarning ) {
1196 $descriptor[
'IgnoreWarning'] = [
1198 'id' =>
'wpIgnoreWarning',
1199 'label-message' =>
'ignorewarnings',
1200 'section' =>
'options',
1204 $descriptor[
'DestFileWarningAck'] = [
1206 'id' =>
'wpDestFileWarningAck',
1207 'default' => $this->mDestWarningAck ?
'1' :
'',
1210 if ( $this->mForReUpload ) {
1211 $descriptor[
'ForReUpload'] = [
1213 'id' =>
'wpForReUpload',
1235 $useAjaxDestCheck = $config->get(
'UseAjax' ) && $config->get(
'AjaxUploadDestCheck' );
1236 $useAjaxLicensePreview = $config->get(
'UseAjax' ) &&
1237 $config->get(
'AjaxLicensePreview' ) && $config->get(
'EnableAPI' );
1238 $this->mMaxUploadSize[
'*'] = UploadBase::getMaxUploadSize();
1241 'wgAjaxUploadDestCheck' => $useAjaxDestCheck,
1242 'wgAjaxLicensePreview' => $useAjaxLicensePreview,
1243 'wgUploadAutoFill' => !$this->mForReUpload &&
1246 $this->mDestFile ===
'',
1248 'wgCheckFileExtensions' => $config->get(
'CheckFileExtensions' ),
1249 'wgStrictFileExtensions' => $config->get(
'StrictFileExtensions' ),
1250 'wgFileExtensions' => array_values( array_unique( $config->get(
'FileExtensions' ) ) ),
1257 $out->addJsConfigVars( $scriptVars );
1260 'mediawiki.action.edit',
1261 'mediawiki.special.upload',
1285 $id = $this->mParams[
'id'];
1288 if ( !empty( $this->mParams[
'radio'] ) ) {
1289 if ( isset( $this->mParams[
'radio-id'] ) ) {
1290 $radioId = $this->mParams[
'radio-id'];
1294 $radioId =
'wpSourceType' . $this->mParams[
'upload-type'];
1298 'name' =>
'wpSourceType',
1301 'value' => $this->mParams[
'upload-type'],
1304 if ( !empty( $this->mParams[
'checked'] ) ) {
1311 return Html::rawElement(
'td', [
'class' =>
'mw-label' ] + $cellAttributes, $label );
1318 return isset( $this->mParams[
'size'] )
1319 ? $this->mParams[
'size']
getPageTitle( $subpage=false)
Get a self-referential title object.
getConfig()
Get the Config object.
static getInitialPageText( $comment='', $license='', $copyStatus='', $source='', Config $config=null)
Get the initial image page text based on a comment and optional file status information.
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
WebRequest clone which takes values from a provided array.
getContext()
Get the base IContextSource object.
userCanExecute(User $user)
This page can be shown if uploading is enabled.
error also a ContextSource you ll probably need to make sure the header is varied on $request
static singleton()
Get a RepoGroup instance.
Show an error when the user tries to do something whilst blocked.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Using a hook running we can avoid having all this option specific stuff in our mainline code Using hooks
getOutput()
Get the OutputPage being used for this instance.
getTitle( $subpage=false)
Get a self-referential title object.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
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
doesWrites()
Indicates whether this special page may perform database writes.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
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
processUpload()
Do the upload.
unsaveUploadedFile()
Remove a temporarily kept file stashed by saveTempUploadedFile().
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 before processing starts Return false to skip default processing and return $ret $linkRenderer
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Implements uploading from previously stored file.
A form field that contains a radio box in the label.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
Allows to change the fields on the form that will be generated $name
getRequest()
Get the WebRequest object.
Show an error when a user tries to do something they do not have the necessary permissions for.
getLanguage()
Shortcut to get user's language.
getUser()
Get the User object.
showViewDeletedLinks()
Shows the "view X deleted revivions link"".
$mDestWarningAck
Hidden variables.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static getExistsWarning( $exists)
Formats a result of UploadBase::getExistsWarning as HTML This check is static and can be done pre-upl...
getLanguage()
Get the Language object.
showUploadWarning( $warnings)
Stashes the upload, shows the main form, but adds a "continue anyway button".
getDupeWarning( $dupes)
Construct a warning and a gallery from an array of duplicate files.
showRecoverableUploadError( $message)
Stashes the upload and shows the main upload form.
An IContextSource implementation which will inherit context from another source but allow individual ...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getConfig()
Shortcut to get main config object.
namespace and then decline to actually register it file or subcat img or subcat $title
WebRequest FauxRequest $mRequest
Misc variables.
Generic handler for bitmap images.
string $mDesiredDestName
User input variables from the "description" section.
$uploadFormTextAfterSummary
static isEnabled()
Checks if the upload from URL feature is enabled.
bool $mCancelUpload
The user clicked "Cancel and return to upload form" button.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getOutput()
Get the OutputPage object.
null for the wiki Added in
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
execute( $par)
Special page entry point.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
loadRequest()
Initialize instance variables from request and create an Upload handler.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
setContext(IContextSource $context)
Set the IContextSource object.
Class to represent a local file in the wiki's own database.
Form for handling uploads and special page.
getContext()
Gets the context this SpecialPage is executed in.
bool $mForReUpload
The user followed an "overwrite this file" link.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
msg()
Wrapper around wfMessage that sets the current context.
Parent class for all special pages.
getUploadForm( $message='', $sessionKey='', $hideIgnoreWarning=false)
Get an UploadForm instance with title and text properly set.
static rotationEnabled()
Should we rotate images in the preview on Special:Upload.
showUploadError( $message)
Show the upload form with error message, but do not stash the file.
getRequest()
Get the WebRequest being used for this instance.
showUploadForm( $form)
Show the main upload form.
&</p >< p >< sup id="cite_ref-blank_1-1" class="reference">< a href="#cite_note-blank-1"> &</p >< div class="mw-references-wrap">< ol class="references">< li id="cite_note-blank-1">< span class="mw-cite-backlink"> ↑< sup >< a href="#cite_ref-blank_1-0"></a ></sup >< sup >< a href="#cite_ref-blank_1-1"></a ></sup ></span >< span class="reference-text">< span class="error mw-ext-cite-error" lang="en" dir="ltr"> Cite error
Interface for objects which can provide a MediaWiki context on request.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Represents a title within MediaWiki.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
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
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static isCapitalized( $index)
Is the namespace first-letter capitalized?
getLabelHtml( $cellAttributes=[])
exists( $flags=0)
Check if page exists.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
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 true
__construct( $request=null)
Constructor : initialise object Get data POSTed through the form and assign them to the object.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation 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 "<
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
static isAllowed( $user)
Checks if the user is allowed to use the upload-by-URL feature.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
processVerificationError( $details)
Provides output to the user for a result of UploadBase::verifyUpload.
MediaWiki Linker LinkRenderer null $linkRenderer
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
An error page which can definitely be safely rendered using the OutputPage.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
wfLocalFile( $title)
Get an object referring to a locally registered file.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
$uploadFormTextTop
Text injection points for hooks not using HTMLForm.
bool $mUploadSuccessful
Subclasses can use this to determine whether a file was uploaded.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
$mIgnoreWarning
User input variables from the root section.
getWatchCheck()
See if we should check the 'watch this page' checkbox on the form based on the user's preferences and...
the array() calling protocol came about after MediaWiki 1.4rc1.
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out