41 parent::__construct(
'Upload',
'upload' );
98 $this->mSourceType =
$request->getVal(
'wpSourceType',
'file' );
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 =
'';
167 # Check uploading enabled
169 throw new ErrorPageError(
'uploaddisabled',
'uploaddisabledtext' );
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
212 if ( !Hooks::run(
'UploadForm:initial', [ &$this ] ) ) {
213 wfDebug(
"Hook 'UploadForm:initial' broke output of the upload form\n" );
221 if ( $this->mUpload ) {
222 $this->mUpload->cleanupTempFile();
232 # Add links if file was previously deleted
233 if ( $this->mDesiredDestName ) {
252 protected function getUploadForm( $message =
'', $sessionKey =
'', $hideIgnoreWarning =
false ) {
258 'forreupload' => $this->mForReUpload,
259 'sessionkey' => $sessionKey,
260 'hideignorewarning' => $hideIgnoreWarning,
261 'destwarningack' => (
bool)$this->mDestWarningAck,
263 'description' => $this->mComment,
264 'texttop' => $this->uploadFormTextTop,
265 'textaftersummary' => $this->uploadFormTextAfterSummary,
266 'destfile' => $this->mDesiredDestName,
269 # Check the token, but only if necessary
271 !$this->mTokenOk && !$this->mCancelUpload &&
272 ( $this->mUpload && $this->mUploadClicked )
274 $form->addPreText( $this->
msg(
'session_fail_preview' )->parse() );
277 # Give a notice if the user is uploading a file that has been deleted or moved
278 # Note that this is independent from the message 'filewasdeleted'
279 $desiredTitleObj = Title::makeTitleSafe(
NS_FILE, $this->mDesiredDestName );
281 if ( $desiredTitleObj instanceof
Title && !$desiredTitleObj->
exists() ) {
285 'conds' => [
"log_action != 'revision'" ],
286 'showIfEmpty' =>
false,
287 'msgKey' => [
'upload-recreate-warning' ] ]
290 $form->addPreText( $delNotice );
293 $form->addPreText(
'<div id="uploadtext">' .
294 $this->
msg(
'uploadtext', [ $this->mDesiredDestName ] )->parseAsBlock() .
296 # Add upload error message
297 $form->addPreText( $message );
300 $uploadFooter = $this->
msg(
'uploadfooter' );
301 if ( !$uploadFooter->isDisabled() ) {
302 $form->addPostText(
'<div id="mw-upload-footer-message">'
303 . $uploadFooter->parseAsBlock() .
"</div>\n" );
313 $title = Title::makeTitleSafe(
NS_FILE, $this->mDesiredDestName );
318 if (
$count > 0 &&
$user->isAllowed(
'deletedhistory' ) ) {
321 $this->msg(
'restorelink' )->numParams(
$count )->text()
323 $link = $this->
msg(
$user->isAllowed(
'delete' ) ?
'thisisdeleted' :
'viewdeleted' )
324 ->rawParams( $restorelink )->parseAsBlock();
325 $this->
getOutput()->addHTML(
"<div id=\"contentSub2\">{$link}</div>" );
342 $stashStatus = $this->mUpload->tryStashFile( $this->
getUser() );
343 if ( $stashStatus->isGood() ) {
344 $sessionKey = $stashStatus->getValue()->getFileKey();
349 $message =
'<h2>' . $this->
msg(
'uploaderror' )->escaped() .
"</h2>\n" .
350 '<div class="error">' . $message .
"</div>\n";
353 $form->setSubmitText( $this->
msg(
'upload-tryagain' )->escaped() );
366 # If there are no warnings, or warnings we can ignore, return early.
367 # mDestWarningAck is set when some javascript has shown the warning
368 # to the user. mForReUpload is set when the user clicks the "upload a
370 if ( !$warnings || ( count( $warnings ) == 1
371 && isset( $warnings[
'exists'] )
372 && ( $this->mDestWarningAck || $this->mForReUpload ) )
377 $stashStatus = $this->mUpload->tryStashFile( $this->
getUser() );
378 if ( $stashStatus->isGood() ) {
379 $sessionKey = $stashStatus->getValue()->getFileKey();
386 $this->
getOutput()->addModuleStyles(
'mediawiki.special.upload.styles' );
389 $warningHtml =
'<h2>' . $this->
msg(
'uploadwarning' )->escaped() .
"</h2>\n"
390 .
'<div class="mw-destfile-warning"><ul>';
391 foreach ( $warnings
as $warning =>
$args ) {
392 if ( $warning ==
'badfilename' ) {
393 $this->mDesiredDestName = Title::makeTitle(
NS_FILE,
$args )->getText();
395 if ( $warning ==
'exists' ) {
397 } elseif ( $warning ==
'no-change' ) {
399 $filename = $file->getTitle()->getPrefixedText();
400 $msg =
"\t<li>" .
wfMessage(
'fileexists-no-change', $filename )->parse() .
"</li>\n";
401 } elseif ( $warning ==
'duplicate-version' ) {
404 $filename = $file->getTitle()->getPrefixedText();
405 $message =
wfMessage(
'fileexists-duplicate-version' )
406 ->params( $filename )
408 $msg =
"\t<li>" . $message->parse() .
"</li>\n";
409 } elseif ( $warning ==
'was-deleted' ) {
410 # If the file existed before and was deleted, warn the user of this
418 'page' => Title::makeTitle(
NS_FILE,
$args )->getPrefixedText(),
421 $msg =
"\t<li>" .
wfMessage(
'filewasdeleted' )->rawParams( $llink )->parse() .
"</li>\n";
422 } elseif ( $warning ==
'duplicate' ) {
424 } elseif ( $warning ==
'duplicate-archive' ) {
425 if (
$args ===
'' ) {
426 $msg =
"\t<li>" . $this->
msg(
'file-deleted-duplicate-notitle' )->parse()
429 $msg =
"\t<li>" . $this->
msg(
'file-deleted-duplicate',
430 Title::makeTitle(
NS_FILE,
$args )->getPrefixedText() )->parse()
434 if (
$args ===
true ) {
436 } elseif ( !is_array(
$args ) ) {
439 $msg =
"\t<li>" . $this->
msg( $warning,
$args )->parse() .
"</li>\n";
441 $warningHtml .= $msg;
443 $warningHtml .=
"</ul></div>\n";
444 $warningHtml .= $this->
msg(
'uploadwarning-text' )->parseAsBlock();
446 $form = $this->
getUploadForm( $warningHtml, $sessionKey,
true );
447 $form->setSubmitText( $this->
msg(
'upload-tryagain' )->
text() );
449 'name' =>
'wpUploadIgnoreWarning',
450 'value' => $this->
msg(
'ignorewarning' )->
text()
453 'name' =>
'wpCancelUpload',
454 'value' => $this->
msg(
'reuploaddesc' )->
text()
459 # Indicate that we showed a form
469 $message =
'<h2>' . $this->
msg(
'uploadwarning' )->escaped() .
"</h2>\n" .
470 '<div class="error">' . $message .
"</div>\n";
480 $status = $this->mUpload->fetchFile();
487 if ( !Hooks::run(
'UploadForm:BeforeProcessing', [ &$this ] ) ) {
488 wfDebug(
"Hook 'UploadForm:BeforeProcessing' broke processing the file.\n" );
498 $details = $this->mUpload->verifyUpload();
506 $permErrors = $this->mUpload->verifyTitlePermissions( $this->
getUser() );
507 if ( $permErrors !==
true ) {
508 $code = array_shift( $permErrors[0] );
514 $this->mLocalFile = $this->mUpload->getLocalFile();
517 if ( !$this->mIgnoreWarning ) {
518 $warnings = $this->mUpload->checkWarnings();
527 $this->
msg(
'actionthrottledtext' )->escaped()
533 if ( !$this->mForReUpload ) {
535 $this->mCopyrightStatus, $this->mCopyrightSource, $this->
getConfig() );
540 $changeTags = $this->
getRequest()->getVal(
'wpChangeTags' );
541 if ( is_null( $changeTags ) || $changeTags ===
'' ) {
544 $changeTags = array_filter( array_map(
'trim', explode(
',', $changeTags ) ) );
549 $changeTags, $this->
getUser() );
550 if ( !$changeTagsStatus->isOK() ) {
557 $status = $this->mUpload->performUpload(
572 $this->mUploadSuccessful =
true;
573 Hooks::run(
'SpecialUploadComplete', [ &$this ] );
574 $this->
getOutput()->redirect( $this->mLocalFile->getTitle()->getFullURL() );
589 if ( $config ===
null ) {
590 wfDebug( __METHOD__ .
' called without a Config instance passed to it' );
591 $config = ConfigFactory::getDefaultInstance()->makeConfig(
'main' );
595 $forceUIMsgAsContentMsg = (
array)$config->get(
'ForceUIMsgAsContentMsg' );
600 foreach ( [
'license-header',
'filedesc',
'filestatus',
'filesource' ]
as $msgName ) {
601 if ( in_array( $msgName, $forceUIMsgAsContentMsg ) ) {
602 $msg[$msgName] =
"{{int:$msgName}}";
604 $msg[$msgName] =
wfMessage( $msgName )->inContentLanguage()->text();
608 if ( $config->get(
'UseCopyrightUpload' ) ) {
611 $licensetxt =
'== ' . $msg[
'license-header'] .
" ==\n" .
'{{' .
$license .
'}}' .
"\n";
613 $pageText =
'== ' . $msg[
'filedesc'] .
" ==\n" .
$comment .
"\n" .
614 '== ' . $msg[
'filestatus'] .
" ==\n" . $copyStatus .
"\n" .
616 '== ' . $msg[
'filesource'] .
" ==\n" .
$source;
619 $filedesc =
$comment ==
'' ?
'' :
'== ' . $msg[
'filedesc'] .
" ==\n" .
$comment .
"\n";
620 $pageText = $filedesc .
621 '== ' . $msg[
'license-header'] .
" ==\n" .
'{{' .
$license .
'}}' .
"\n";
643 if ( $this->
getUser()->getOption(
'watchdefault' ) ) {
648 $desiredTitleObj = Title::makeTitleSafe(
NS_FILE, $this->mDesiredDestName );
649 if ( $desiredTitleObj instanceof
Title && $this->
getUser()->isWatched( $desiredTitleObj ) ) {
655 if ( $local && $local->exists() ) {
661 return $this->
getUser()->getOption(
'watchcreations' ) ||
662 $this->
getUser()->getOption(
'watchuploads' );
673 switch ( $details[
'status'] ) {
681 $details[
'filtered'] )->parse() );
701 $msg = $this->
msg(
'filetype-banned-type' );
702 if ( isset( $details[
'blacklistedExt'] ) ) {
703 $msg->params( $this->
getLanguage()->commaList( $details[
'blacklistedExt'] ) );
705 $msg->params( $details[
'finalExt'] );
714 if ( isset( $details[
'blacklistedExt'] ) ) {
715 $msg->params( count( $details[
'blacklistedExt'] ) );
723 unset( $details[
'status'] );
724 $code = array_shift( $details[
'details'] );
728 if ( is_array( $details[
'error'] ) ) { # allow
hooks to
return error details
in an
array
729 $args = $details[
'error'];
730 $error = array_shift(
$args );
732 $error = $details[
'error'];
739 throw new MWException( __METHOD__ .
": Unknown value `{$details['status']}`" );
752 $success = $this->mUpload->unsaveUploadedFile();
754 $this->
getOutput()->showFileDeleteError( $this->mUpload->getTempPath() );
776 $file = $exists[
'file'];
777 $filename = $file->getTitle()->getPrefixedText();
780 if ( $exists[
'warning'] ==
'exists' ) {
782 $warnMsg =
wfMessage(
'fileexists', $filename );
783 } elseif ( $exists[
'warning'] ==
'page-exists' ) {
785 $warnMsg =
wfMessage(
'filepageexists', $filename );
786 } elseif ( $exists[
'warning'] ==
'exists-normalized' ) {
787 $warnMsg =
wfMessage(
'fileexists-extension', $filename,
788 $exists[
'normalizedFile']->
getTitle()->getPrefixedText() );
789 } elseif ( $exists[
'warning'] ==
'thumb' ) {
791 $warnMsg =
wfMessage(
'fileexists-thumbnail-yes',
792 $exists[
'thumbFile']->
getTitle()->getPrefixedText(), $filename );
793 } elseif ( $exists[
'warning'] ==
'thumb-name' ) {
795 $name = $file->getName();
796 $badPart = substr(
$name, 0, strpos(
$name,
'-' ) + 1 );
797 $warnMsg =
wfMessage(
'file-thumbnail-no', $badPart );
798 } elseif ( $exists[
'warning'] ==
'bad-prefix' ) {
799 $warnMsg =
wfMessage(
'filename-bad-prefix', $exists[
'prefix'] );
802 return $warnMsg ? $warnMsg->title( $file->getTitle() )->parse() :
'';
816 $gallery->setShowBytes(
false );
817 foreach ( $dupes
as $file ) {
818 $gallery->add( $file->getTitle() );
822 $this->
msg(
'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() .
823 $gallery->toHTML() .
"</li>\n";
839 return $bitmapHandler->autoRotateEnabled();
872 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
875 $this->mWatch = !empty(
$options[
'watch'] );
876 $this->mForReUpload = !empty(
$options[
'forreupload'] );
877 $this->mSessionKey = isset(
$options[
'sessionkey'] ) ?
$options[
'sessionkey'] :
'';
878 $this->mHideIgnoreWarning = !empty(
$options[
'hideignorewarning'] );
879 $this->mDestWarningAck = !empty(
$options[
'destwarningack'] );
880 $this->mDestFile = isset(
$options[
'destfile'] ) ?
$options[
'destfile'] :
'';
882 $this->mComment = isset(
$options[
'description'] ) ?
885 $this->mTextTop = isset(
$options[
'texttop'] )
888 $this->mTextAfterSummary = isset(
$options[
'textaftersummary'] )
889 ?
$options[
'textaftersummary'] :
'';
892 $descriptor = $sourceDescriptor
896 Hooks::run(
'UploadFormInitDescriptor', [ &$descriptor ] );
897 parent::__construct( $descriptor,
$context,
'upload' );
899 # Add a link to edit MediaWiki:Licenses
900 if ( $this->
getUser()->isAllowed(
'editinterface' ) ) {
901 $this->
getOutput()->addModuleStyles(
'mediawiki.special.upload.styles' );
903 $this->
msg(
'licenses' )->inContentLanguage()->
getTitle(),
904 $this->
msg(
'licenses-edit' )->
text(),
906 [
'action' =>
'edit' ]
908 $editLicenses =
'<p class="mw-upload-editlicenses">' . $licensesLink .
'</p>';
912 # Set some form properties
915 # Used message keys: 'accesskey-upload', 'tooltip-upload'
917 $this->
setId(
'mw-upload-form' );
919 # Build a list of IDs for javascript insertion
920 $this->mSourceIds = [];
921 foreach ( $sourceDescriptor
as $field ) {
922 if ( !empty( $field[
'id'] ) ) {
923 $this->mSourceIds[] = $field[
'id'];
935 if ( $this->mSessionKey ) {
943 'default' =>
'Stash',
950 && $this->
getConfig()->get(
'CopyUploadsFromSpecialUpload' );
951 $radio = $canUploadByUrl;
952 $selectedSourceType = strtolower( $this->
getRequest()->getText(
'wpSourceType',
'File' ) );
955 if ( $this->mTextTop ) {
956 $descriptor[
'UploadFormTextTop'] = [
958 'section' =>
'source',
964 $this->mMaxUploadSize[
'file'] = min(
969 $help = $this->
msg(
'upload-maxfilesize',
975 if ( $canUploadByUrl ) {
976 $help .= $this->
msg(
'word-separator' )->escaped();
977 $help .= $this->
msg(
'upload_source_file' )->parse();
980 $descriptor[
'UploadFile'] = [
981 'class' =>
'UploadSourceField',
982 'section' =>
'source',
984 'id' =>
'wpUploadFile',
985 'radio-id' =>
'wpSourceTypeFile',
986 'label-message' =>
'sourcefilename',
987 'upload-type' =>
'File',
990 'checked' => $selectedSourceType ==
'file',
993 if ( $canUploadByUrl ) {
995 $descriptor[
'UploadFileURL'] = [
996 'class' =>
'UploadSourceField',
997 'section' =>
'source',
998 'id' =>
'wpUploadFileURL',
999 'radio-id' =>
'wpSourceTypeurl',
1000 'label-message' =>
'sourceurl',
1001 'upload-type' =>
'url',
1003 'help' => $this->
msg(
'upload-maxfilesize',
1006 $this->
msg(
'word-separator' )->escaped() .
1007 $this->
msg(
'upload_source_url' )->parse(),
1008 'checked' => $selectedSourceType ==
'url',
1011 Hooks::run(
'UploadFormSourceDescriptors', [ &$descriptor, &$radio, $selectedSourceType ] );
1013 $descriptor[
'Extensions'] = [
1015 'section' =>
'source',
1029 # Print a list of allowed file extensions, if so configured. We ignore
1030 # MIME type here, it's incomprehensible to most people and too long.
1033 if ( $config->get(
'CheckFileExtensions' ) ) {
1034 $fileExtensions = array_unique( $config->get(
'FileExtensions' ) );
1035 if ( $config->get(
'StrictFileExtensions' ) ) {
1036 # Everything not permitted is banned
1038 '<div id="mw-upload-permitted">' .
1039 $this->
msg(
'upload-permitted' )
1040 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
1041 ->numParams( count( $fileExtensions ) )
1045 # We have to list both preferred and prohibited
1046 $fileBlacklist = array_unique( $config->get(
'FileBlacklist' ) );
1048 '<div id="mw-upload-preferred">' .
1049 $this->
msg(
'upload-preferred' )
1050 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
1051 ->numParams( count( $fileExtensions ) )
1054 '<div id="mw-upload-prohibited">' .
1055 $this->
msg(
'upload-prohibited' )
1056 ->params( $this->
getLanguage()->commaList( $fileBlacklist ) )
1057 ->numParams( count( $fileBlacklist ) )
1062 # Everything is permitted.
1063 $extensionsList =
'';
1066 return $extensionsList;
1077 if ( $this->mSessionKey ) {
1080 $file = $stash->getFile( $this->mSessionKey );
1081 }
catch ( Exception
$e ) {
1087 $mto = $file->transform( [
'width' => 120 ] );
1090 '<div class="thumb t' . $wgContLang->alignEnd() .
'">' .
1091 Html::element(
'img', [
1092 'src' => $mto->getUrl(),
1093 'class' =>
'thumbimage',
1094 ] ) .
'</div>',
'description' );
1102 'section' =>
'description',
1103 'id' =>
'wpDestFile',
1104 'label-message' =>
'destfilename',
1107 # @todo FIXME: Hack to work around poor handling of the 'default' option in HTMLForm
1108 'nodata' => strval( $this->mDestFile ) !==
'',
1110 'UploadDescription' => [
1111 'type' =>
'textarea',
1112 'section' =>
'description',
1113 'id' =>
'wpUploadDescription',
1114 'label-message' => $this->mForReUpload
1115 ?
'filereuploadsummary'
1116 :
'fileuploadsummary',
1118 'cols' => $this->
getUser()->getIntOption(
'cols' ),
1122 if ( $this->mTextAfterSummary ) {
1123 $descriptor[
'UploadFormTextAfterSummary'] = [
1125 'section' =>
'description',
1133 'type' =>
'edittools',
1134 'section' =>
'description',
1135 'message' =>
'edittools-upload',
1139 if ( $this->mForReUpload ) {
1140 $descriptor[
'DestFile'][
'readonly'] =
true;
1142 $descriptor[
'License'] = [
1144 'class' =>
'Licenses',
1145 'section' =>
'description',
1146 'id' =>
'wpLicense',
1147 'label-message' =>
'license',
1151 if ( $config->get(
'UseCopyrightUpload' ) ) {
1152 $descriptor[
'UploadCopyStatus'] = [
1154 'section' =>
'description',
1155 'id' =>
'wpUploadCopyStatus',
1156 'label-message' =>
'filestatus',
1158 $descriptor[
'UploadSource'] = [
1160 'section' =>
'description',
1161 'id' =>
'wpUploadSource',
1162 'label-message' =>
'filesource',
1177 if (
$user->isLoggedIn() ) {
1181 'id' =>
'wpWatchthis',
1182 'label-message' =>
'watchthisupload',
1183 'section' =>
'options',
1188 if ( !$this->mHideIgnoreWarning ) {
1189 $descriptor[
'IgnoreWarning'] = [
1191 'id' =>
'wpIgnoreWarning',
1192 'label-message' =>
'ignorewarnings',
1193 'section' =>
'options',
1197 $descriptor[
'DestFileWarningAck'] = [
1199 'id' =>
'wpDestFileWarningAck',
1200 'default' => $this->mDestWarningAck ?
'1' :
'',
1203 if ( $this->mForReUpload ) {
1204 $descriptor[
'ForReUpload'] = [
1206 'id' =>
'wpForReUpload',
1228 $useAjaxDestCheck = $config->get(
'UseAjax' ) && $config->get(
'AjaxUploadDestCheck' );
1229 $useAjaxLicensePreview = $config->get(
'UseAjax' ) &&
1230 $config->get(
'AjaxLicensePreview' ) && $config->get(
'EnableAPI' );
1234 'wgAjaxUploadDestCheck' => $useAjaxDestCheck,
1235 'wgAjaxLicensePreview' => $useAjaxLicensePreview,
1236 'wgUploadAutoFill' => !$this->mForReUpload &&
1239 $this->mDestFile ===
'',
1241 'wgCheckFileExtensions' => $config->get(
'CheckFileExtensions' ),
1242 'wgStrictFileExtensions' => $config->get(
'StrictFileExtensions' ),
1243 'wgFileExtensions' => array_values( array_unique( $config->get(
'FileExtensions' ) ) ),
1244 'wgCapitalizeUploads' => MWNamespace::isCapitalized(
NS_FILE ),
1250 $out->addJsConfigVars( $scriptVars );
1253 'mediawiki.action.edit',
1254 'mediawiki.special.upload',
1278 $id = $this->mParams[
'id'];
1279 $label = Html::rawElement(
'label', [
'for' => $id ], $this->mLabel );
1281 if ( !empty( $this->mParams[
'radio'] ) ) {
1282 if ( isset( $this->mParams[
'radio-id'] ) ) {
1283 $radioId = $this->mParams[
'radio-id'];
1287 $radioId =
'wpSourceType' . $this->mParams[
'upload-type'];
1291 'name' =>
'wpSourceType',
1294 'value' => $this->mParams[
'upload-type'],
1297 if ( !empty( $this->mParams[
'checked'] ) ) {
1301 $label .= Html::element(
'input',
$attribs );
1304 return Html::rawElement(
'td', [
'class' =>
'mw-label' ] + $cellAttributes, $label );
1311 return isset( $this->mParams[
'size'] )
1312 ? $this->mParams[
'size']
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfLocalFile( $title)
Get an object referring to a locally registered file.
Generic handler for bitmap images.
getUser()
Get the User object.
getRequest()
Get the WebRequest object.
getConfig()
Get the Config object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getOutput()
Get the OutputPage object.
getLanguage()
Get the Language object.
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
Set the IContextSource object.
An IContextSource implementation which will inherit context from another source but allow individual ...
An error page which can definitely be safely rendered using the OutputPage.
WebRequest clone which takes values from a provided array.
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
Class to represent a local file in the wiki's own database.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Show an error when a user tries to do something they do not have the necessary permissions for.
static singleton()
Get a RepoGroup instance.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
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,...
getContext()
Gets the context this SpecialPage is executed in.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getPageTitle( $subpage=false)
Get a self-referential title object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
msg()
Wrapper around wfMessage that sets the current context.
MediaWiki Linker LinkRenderer null $linkRenderer
getTitle( $subpage=false)
Get a self-referential title object.
Form for handling uploads and special page.
processVerificationError( $details)
Provides output to the user for a result of UploadBase::verifyUpload.
showViewDeletedLinks()
Shows the "view X deleted revivions link"".
getWatchCheck()
See if we should check the 'watch this page' checkbox on the form based on the user's preferences and...
loadRequest()
Initialize instance variables from request and create an Upload handler.
static getInitialPageText( $comment='', $license='', $copyStatus='', $source='', Config $config=null)
Get the initial image page text based on a comment and optional file status information.
showUploadWarning( $warnings)
Stashes the upload, shows the main form, but adds a "continue anyway button".
$uploadFormTextTop
Text injection points for hooks not using HTMLForm.
bool $mCancelUpload
The user clicked "Cancel and return to upload form" button.
unsaveUploadedFile()
Remove a temporarily kept file stashed by saveTempUploadedFile().
userCanExecute(User $user)
This page can be shown if uploading is enabled.
static getExistsWarning( $exists)
Formats a result of UploadBase::getExistsWarning as HTML This check is static and can be done pre-upl...
string $mDesiredDestName
User input variables from the "description" section.
showRecoverableUploadError( $message)
Stashes the upload and shows the main upload form.
$mDestWarningAck
Hidden variables.
getDupeWarning( $dupes)
Construct a warning and a gallery from an array of duplicate files.
showUploadForm( $form)
Show the main upload form.
__construct( $request=null)
Constructor : initialise object Get data POSTed through the form and assign them to the object.
WebRequest FauxRequest $mRequest
Misc variables.
processUpload()
Do the upload.
bool $mUploadSuccessful
Subclasses can use this to determine whether a file was uploaded.
$uploadFormTextAfterSummary
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
Special page entry point.
getUploadForm( $message='', $sessionKey='', $hideIgnoreWarning=false)
Get an UploadForm instance with title and text properly set.
doesWrites()
Indicates whether this special page may perform database writes.
bool $mForReUpload
The user followed an "overwrite this file" link.
$mIgnoreWarning
User input variables from the root section.
showUploadError( $message)
Show the upload form with error message, but do not stash the file.
static rotationEnabled()
Should we rotate images in the preview on Special:Upload.
Represents a title within MediaWiki.
exists( $flags=0)
Check if page exists.
UploadBase and subclasses are the backend of MediaWiki's file uploads.
static createFromRequest(&$request, $type=null)
Create a form of UploadBase depending on wpSourceType and initializes it.
static isEnabled()
Returns true if uploads are enabled.
const WINDOWS_NONASCII_FILENAME
static getMaxUploadSize( $forType=null)
Get the MediaWiki maximum uploaded file size for given type of upload, based on $wgMaxUploadSize.
static isThrottled( $user)
Returns true if the user has surpassed the upload rate limit, false otherwise.
const MIN_LENGTH_PARTNAME
static isAllowed( $user)
Returns true if the user can use this upload module or else a string identifying the missing permissi...
static getMaxPhpUploadSize()
Get the PHP maximum uploaded file size, based on ini settings.
Implements uploading from previously stored file.
static isAllowed( $user)
Checks if the user is allowed to use the upload-by-URL feature.
static isEnabled()
Checks if the upload from URL feature is enabled.
A form field that contains a radio box in the label.
getLabelHtml( $cellAttributes=[])
Show an error when the user tries to do something whilst blocked.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
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 local content language as $wgContLang
when a variable name is used in a it is silently declared as a new local masking the global
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
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
the array() calling protocol came about after MediaWiki 1.4rc1.
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 local account $user
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
null for the local 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 true
error also a ContextSource you ll probably need to make sure the header is varied on $request
Using a hook running we can avoid having all this option specific stuff in our mainline code Using hooks
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
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 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
Allows to change the fields on the form that will be generated $name
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
returning false will NOT prevent logging $e
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
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
Interface for configuration instances.
Interface for objects which can provide a MediaWiki context on request.