38 parent::__construct(
'Upload',
'upload' );
95 $this->mSourceType =
$request->getVal(
'wpSourceType',
'file' );
97 $this->mUploadClicked =
$request->wasPosted()
98 && (
$request->getCheck(
'wpUpload' )
99 ||
$request->getCheck(
'wpUploadIgnoreWarning' ) );
102 $this->mDesiredDestName =
$request->getText(
'wpDestFile' );
103 if ( !$this->mDesiredDestName &&
$request->getFileName(
'wpUploadFile' ) !== null ) {
104 $this->mDesiredDestName =
$request->getFileName(
'wpUploadFile' );
106 $this->mLicense =
$request->getText(
'wpLicense' );
108 $this->mDestWarningAck =
$request->getText(
'wpDestFileWarningAck' );
109 $this->mIgnoreWarning =
$request->getCheck(
'wpIgnoreWarning' )
110 ||
$request->getCheck(
'wpUploadIgnoreWarning' );
111 $this->mWatchthis =
$request->getBool(
'wpWatchthis' ) && $this->
getUser()->isLoggedIn();
112 $this->mCopyrightStatus =
$request->getText(
'wpUploadCopyStatus' );
113 $this->mCopyrightSource =
$request->getText(
'wpUploadSource' );
115 $this->mForReUpload =
$request->getBool(
'wpForReUpload' );
117 $commentDefault =
'';
118 $commentMsg =
wfMessage(
'upload-default-description' )->inContentLanguage();
119 if ( !$this->mForReUpload && !$commentMsg->isDisabled() ) {
120 $commentDefault = $commentMsg->plain();
122 $this->mComment =
$request->getText(
'wpUploadDescription', $commentDefault );
124 $this->mCancelUpload =
$request->getCheck(
'wpCancelUpload' )
125 ||
$request->getCheck(
'wpReUpload' );
128 $token =
$request->getVal(
'wpEditToken' );
129 $this->mTokenOk = $this->
getUser()->matchEditToken( $token );
131 $this->uploadFormTextTop =
'';
132 $this->uploadFormTextAfterSummary =
'';
164 # Check uploading enabled
166 throw new ErrorPageError(
'uploaddisabled',
'uploaddisabledtext' );
174 if ( $permissionRequired !==
true ) {
179 if (
$user->isBlocked() ) {
184 if (
$user->isBlockedGlobally() ) {
188 # Check whether we actually want to allow changing stuff
193 # Unsave the temporary file in case this was a cancelled upload
194 if ( $this->mCancelUpload ) {
196 # Something went wrong, so unsaveUploadedFile showed a warning
201 # Process upload or show a form
203 $this->mTokenOk && !$this->mCancelUpload &&
204 ( $this->mUpload && $this->mUploadClicked )
208 # Backwards compatibility hook
209 if ( !
Hooks::run(
'UploadForm:initial', [ &$this ] ) ) {
210 wfDebug(
"Hook 'UploadForm:initial' broke output of the upload form\n" );
218 if ( $this->mUpload ) {
219 $this->mUpload->cleanupTempFile();
229 # Add links if file was previously deleted
230 if ( $this->mDesiredDestName ) {
249 protected function getUploadForm( $message =
'', $sessionKey =
'', $hideIgnoreWarning =
false ) {
255 'forreupload' => $this->mForReUpload,
256 'sessionkey' => $sessionKey,
257 'hideignorewarning' => $hideIgnoreWarning,
258 'destwarningack' => (
bool)$this->mDestWarningAck,
260 'description' => $this->mComment,
261 'texttop' => $this->uploadFormTextTop,
262 'textaftersummary' => $this->uploadFormTextAfterSummary,
263 'destfile' => $this->mDesiredDestName,
266 # Check the token, but only if necessary
268 !$this->mTokenOk && !$this->mCancelUpload &&
269 ( $this->mUpload && $this->mUploadClicked )
271 $form->addPreText( $this->
msg(
'session_fail_preview' )->parse() );
274 # Give a notice if the user is uploading a file that has been deleted or moved
275 # Note that this is independent from the message 'filewasdeleted'
278 if ( $desiredTitleObj instanceof
Title && !$desiredTitleObj->
exists() ) {
282 'conds' => [
"log_action != 'revision'" ],
283 'showIfEmpty' =>
false,
284 'msgKey' => [
'upload-recreate-warning' ] ]
287 $form->addPreText( $delNotice );
290 $form->addPreText(
'<div id="uploadtext">' .
291 $this->
msg(
'uploadtext', [ $this->mDesiredDestName ] )->parseAsBlock() .
293 # Add upload error message
294 $form->addPreText( $message );
297 $uploadFooter = $this->
msg(
'uploadfooter' );
298 if ( !$uploadFooter->isDisabled() ) {
299 $form->addPostText(
'<div id="mw-upload-footer-message">'
300 . $uploadFooter->parseAsBlock() .
"</div>\n" );
315 if (
$count > 0 &&
$user->isAllowed(
'deletedhistory' ) ) {
318 $this->
msg(
'restorelink' )->numParams(
$count )->escaped()
320 $link = $this->
msg(
$user->isAllowed(
'delete' ) ?
'thisisdeleted' :
'viewdeleted' )
321 ->rawParams( $restorelink )->parseAsBlock();
322 $this->
getOutput()->addHTML(
"<div id=\"contentSub2\">{$link}</div>" );
339 $sessionKey = $this->mUpload->stashSession();
340 $message =
'<h2>' . $this->
msg(
'uploaderror' )->escaped() .
"</h2>\n" .
341 '<div class="error">' . $message .
"</div>\n";
344 $form->setSubmitText( $this->
msg(
'upload-tryagain' )->escaped() );
357 # If there are no warnings, or warnings we can ignore, return early.
358 # mDestWarningAck is set when some javascript has shown the warning
359 # to the user. mForReUpload is set when the user clicks the "upload a
361 if ( !$warnings || ( count( $warnings ) == 1
362 && isset( $warnings[
'exists'] )
363 && ( $this->mDestWarningAck || $this->mForReUpload ) )
368 $sessionKey = $this->mUpload->stashSession();
371 $this->
getOutput()->addModuleStyles(
'mediawiki.special.upload.styles' );
373 $warningHtml =
'<h2>' . $this->
msg(
'uploadwarning' )->escaped() .
"</h2>\n"
374 .
'<div class="mw-destfile-warning"><ul>';
375 foreach ( $warnings
as $warning =>
$args ) {
376 if ( $warning ==
'badfilename' ) {
379 if ( $warning ==
'exists' ) {
380 $msg =
"\t<li>" . self::getExistsWarning(
$args ) .
"</li>\n";
381 } elseif ( $warning ==
'was-deleted' ) {
382 # If the file existed before and was deleted, warn the user of this
393 $msg =
"\t<li>" .
wfMessage(
'filewasdeleted' )->rawParams( $llink )->parse() .
"</li>\n";
394 } elseif ( $warning ==
'duplicate' ) {
396 } elseif ( $warning ==
'duplicate-archive' ) {
397 if (
$args ===
'' ) {
398 $msg =
"\t<li>" . $this->
msg(
'file-deleted-duplicate-notitle' )->parse()
401 $msg =
"\t<li>" . $this->
msg(
'file-deleted-duplicate',
406 if (
$args ===
true ) {
408 } elseif ( !is_array(
$args ) ) {
411 $msg =
"\t<li>" . $this->
msg( $warning,
$args )->parse() .
"</li>\n";
413 $warningHtml .= $msg;
415 $warningHtml .=
"</ul></div>\n";
416 $warningHtml .= $this->
msg(
'uploadwarning-text' )->parseAsBlock();
418 $form = $this->
getUploadForm( $warningHtml, $sessionKey,
true );
419 $form->setSubmitText( $this->
msg(
'upload-tryagain' )->
text() );
421 'name' =>
'wpUploadIgnoreWarning',
422 'value' => $this->
msg(
'ignorewarning' )->
text()
425 'name' =>
'wpCancelUpload',
426 'value' => $this->
msg(
'reuploaddesc' )->
text()
431 # Indicate that we showed a form
441 $message =
'<h2>' . $this->
msg(
'uploadwarning' )->escaped() .
"</h2>\n" .
442 '<div class="error">' . $message .
"</div>\n";
452 $status = $this->mUpload->fetchFile();
459 if ( !
Hooks::run(
'UploadForm:BeforeProcessing', [ &$this ] ) ) {
460 wfDebug(
"Hook 'UploadForm:BeforeProcessing' broke processing the file.\n" );
470 $details = $this->mUpload->verifyUpload();
478 $permErrors = $this->mUpload->verifyTitlePermissions( $this->
getUser() );
479 if ( $permErrors !==
true ) {
480 $code = array_shift( $permErrors[0] );
486 $this->mLocalFile = $this->mUpload->getLocalFile();
489 if ( !$this->mIgnoreWarning ) {
490 $warnings = $this->mUpload->checkWarnings();
499 $this->
msg(
'actionthrottledtext' )->escaped()
505 if ( !$this->mForReUpload ) {
506 $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
507 $this->mCopyrightStatus, $this->mCopyrightSource, $this->
getConfig() );
512 $changeTags = $this->
getRequest()->getVal(
'wpChangeTags' );
513 if ( is_null( $changeTags ) || $changeTags ===
'' ) {
516 $changeTags = array_filter( array_map(
'trim', explode(
',', $changeTags ) ) );
521 $changeTags, $this->
getUser() );
522 if ( !$changeTagsStatus->isOK() ) {
529 $status = $this->mUpload->performUpload(
544 $this->mUploadSuccessful =
true;
545 Hooks::run(
'SpecialUploadComplete', [ &$this ] );
546 $this->
getOutput()->redirect( $this->mLocalFile->getTitle()->getFullURL() );
561 if ( $config === null ) {
562 wfDebug( __METHOD__ .
' called without a Config instance passed to it' );
567 $forceUIMsgAsContentMsg = (
array)$config->get(
'ForceUIMsgAsContentMsg' );
572 foreach ( [
'license-header',
'filedesc',
'filestatus',
'filesource' ]
as $msgName ) {
573 if ( in_array( $msgName, $forceUIMsgAsContentMsg ) ) {
574 $msg[$msgName] =
"{{int:$msgName}}";
576 $msg[$msgName] =
wfMessage( $msgName )->inContentLanguage()->text();
580 if ( $config->get(
'UseCopyrightUpload' ) ) {
583 $licensetxt =
'== ' . $msg[
'license-header'] .
" ==\n" .
'{{' .
$license .
'}}' .
"\n";
585 $pageText =
'== ' . $msg[
'filedesc'] .
" ==\n" .
$comment .
"\n" .
586 '== ' . $msg[
'filestatus'] .
" ==\n" . $copyStatus .
"\n" .
588 '== ' . $msg[
'filesource'] .
" ==\n" .
$source;
591 $filedesc =
$comment ==
'' ?
'' :
'== ' . $msg[
'filedesc'] .
" ==\n" .
$comment .
"\n";
592 $pageText = $filedesc .
593 '== ' . $msg[
'license-header'] .
" ==\n" .
'{{' .
$license .
'}}' .
"\n";
615 if ( $this->
getUser()->getOption(
'watchdefault' ) ) {
621 if ( $desiredTitleObj instanceof
Title && $this->
getUser()->isWatched( $desiredTitleObj ) ) {
627 if ( $local && $local->exists() ) {
633 return $this->
getUser()->getOption(
'watchcreations' ) ||
634 $this->
getUser()->getOption(
'watchuploads' );
645 switch ( $details[
'status'] ) {
653 $details[
'filtered'] )->parse() );
673 $msg = $this->
msg(
'filetype-banned-type' );
674 if ( isset( $details[
'blacklistedExt'] ) ) {
675 $msg->params( $this->
getLanguage()->commaList( $details[
'blacklistedExt'] ) );
677 $msg->params( $details[
'finalExt'] );
686 if ( isset( $details[
'blacklistedExt'] ) ) {
687 $msg->params( count( $details[
'blacklistedExt'] ) );
695 unset( $details[
'status'] );
696 $code = array_shift( $details[
'details'] );
701 $args = $details[
'error'];
702 $error = array_shift( $args );
704 $error = $details[
'error'];
711 throw new MWException( __METHOD__ .
": Unknown value `{$details['status']}`" );
724 $success = $this->mUpload->unsaveUploadedFile();
726 $this->
getOutput()->showFileDeleteError( $this->mUpload->getTempPath() );
748 $file = $exists[
'file'];
749 $filename = $file->getTitle()->getPrefixedText();
752 if ( $exists[
'warning'] ==
'exists' ) {
754 $warning =
wfMessage(
'fileexists', $filename )->parse();
755 } elseif ( $exists[
'warning'] ==
'page-exists' ) {
757 $warning =
wfMessage(
'filepageexists', $filename )->parse();
758 } elseif ( $exists[
'warning'] ==
'exists-normalized' ) {
759 $warning =
wfMessage(
'fileexists-extension', $filename,
760 $exists[
'normalizedFile']->
getTitle()->getPrefixedText() )->parse();
761 } elseif ( $exists[
'warning'] ==
'thumb' ) {
763 $warning =
wfMessage(
'fileexists-thumbnail-yes',
764 $exists[
'thumbFile']->
getTitle()->getPrefixedText(), $filename )->parse();
765 } elseif ( $exists[
'warning'] ==
'thumb-name' ) {
767 $name = $file->getName();
768 $badPart = substr(
$name, 0, strpos(
$name,
'-' ) + 1 );
769 $warning =
wfMessage(
'file-thumbnail-no', $badPart )->parse();
770 } elseif ( $exists[
'warning'] ==
'bad-prefix' ) {
771 $warning =
wfMessage(
'filename-bad-prefix', $exists[
'prefix'] )->parse();
788 $gallery->setShowBytes(
false );
789 foreach ( $dupes
as $file ) {
790 $gallery->add( $file->getTitle() );
794 $this->
msg(
'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() .
795 $gallery->toHTML() .
"</li>\n";
811 return $bitmapHandler->autoRotateEnabled();
841 $this->mWatch = !empty(
$options[
'watch'] );
842 $this->mForReUpload = !empty(
$options[
'forreupload'] );
843 $this->mSessionKey = isset(
$options[
'sessionkey'] ) ?
$options[
'sessionkey'] :
'';
844 $this->mHideIgnoreWarning = !empty(
$options[
'hideignorewarning'] );
845 $this->mDestWarningAck = !empty(
$options[
'destwarningack'] );
846 $this->mDestFile = isset(
$options[
'destfile'] ) ?
$options[
'destfile'] :
'';
848 $this->mComment = isset(
$options[
'description'] ) ?
851 $this->mTextTop = isset(
$options[
'texttop'] )
854 $this->mTextAfterSummary = isset(
$options[
'textaftersummary'] )
855 ?
$options[
'textaftersummary'] :
'';
858 $descriptor = $sourceDescriptor
862 Hooks::run(
'UploadFormInitDescriptor', [ &$descriptor ] );
863 parent::__construct( $descriptor,
$context,
'upload' );
865 # Add a link to edit MediaWik:Licenses
866 if ( $this->
getUser()->isAllowed(
'editinterface' ) ) {
867 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
869 $this->
msg(
'licenses' )->inContentLanguage()->
getTitle(),
870 $this->
msg(
'licenses-edit' )->escaped(),
872 [
'action' =>
'edit' ]
874 $editLicenses =
'<p class="mw-upload-editlicenses">' . $licensesLink .
'</p>';
878 # Set some form properties
881 # Used message keys: 'accesskey-upload', 'tooltip-upload'
883 $this->
setId(
'mw-upload-form' );
885 # Build a list of IDs for javascript insertion
886 $this->mSourceIds = [];
887 foreach ( $sourceDescriptor
as $field ) {
888 if ( !empty( $field[
'id'] ) ) {
889 $this->mSourceIds[] = $field[
'id'];
901 if ( $this->mSessionKey ) {
909 'default' =>
'Stash',
916 && $this->
getConfig()->get(
'CopyUploadsFromSpecialUpload' );
917 $radio = $canUploadByUrl;
918 $selectedSourceType = strtolower( $this->
getRequest()->getText(
'wpSourceType',
'File' ) );
921 if ( $this->mTextTop ) {
922 $descriptor[
'UploadFormTextTop'] = [
924 'section' =>
'source',
930 $this->mMaxUploadSize[
'file'] = min(
935 $help = $this->
msg(
'upload-maxfilesize',
941 if ( $canUploadByUrl ) {
942 $help .= $this->
msg(
'word-separator' )->escaped();
943 $help .= $this->
msg(
'upload_source_file' )->parse();
946 $descriptor[
'UploadFile'] = [
947 'class' =>
'UploadSourceField',
948 'section' =>
'source',
950 'id' =>
'wpUploadFile',
951 'radio-id' =>
'wpSourceTypeFile',
952 'label-message' =>
'sourcefilename',
953 'upload-type' =>
'File',
956 'checked' => $selectedSourceType ==
'file',
959 if ( $canUploadByUrl ) {
961 $descriptor[
'UploadFileURL'] = [
962 'class' =>
'UploadSourceField',
963 'section' =>
'source',
964 'id' =>
'wpUploadFileURL',
965 'radio-id' =>
'wpSourceTypeurl',
966 'label-message' =>
'sourceurl',
967 'upload-type' =>
'url',
969 'help' => $this->
msg(
'upload-maxfilesize',
972 $this->
msg(
'word-separator' )->escaped() .
973 $this->
msg(
'upload_source_url' )->parse(),
974 'checked' => $selectedSourceType ==
'url',
977 Hooks::run(
'UploadFormSourceDescriptors', [ &$descriptor, &$radio, $selectedSourceType ] );
979 $descriptor[
'Extensions'] = [
981 'section' =>
'source',
995 # Print a list of allowed file extensions, if so configured. We ignore
996 # MIME type here, it's incomprehensible to most people and too long.
999 if ( $config->get(
'CheckFileExtensions' ) ) {
1000 $fileExtensions = array_unique( $config->get(
'FileExtensions' ) );
1001 if ( $config->get(
'StrictFileExtensions' ) ) {
1002 # Everything not permitted is banned
1004 '<div id="mw-upload-permitted">' .
1005 $this->
msg(
'upload-permitted' )
1006 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
1007 ->numParams( count( $fileExtensions ) )
1011 # We have to list both preferred and prohibited
1012 $fileBlacklist = array_unique( $config->get(
'FileBlacklist' ) );
1014 '<div id="mw-upload-preferred">' .
1015 $this->
msg(
'upload-preferred' )
1016 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
1017 ->numParams( count( $fileExtensions ) )
1020 '<div id="mw-upload-prohibited">' .
1021 $this->
msg(
'upload-prohibited' )
1022 ->params( $this->
getLanguage()->commaList( $fileBlacklist ) )
1023 ->numParams( count( $fileBlacklist ) )
1028 # Everything is permitted.
1029 $extensionsList =
'';
1032 return $extensionsList;
1043 if ( $this->mSessionKey ) {
1046 $file = $stash->getFile( $this->mSessionKey );
1047 }
catch ( Exception
$e ) {
1053 $mto = $file->transform( [
'width' => 120 ] );
1055 '<div class="thumb t' . $wgContLang->alignEnd() .
'">' .
1057 'src' => $mto->getUrl(),
1058 'class' =>
'thumbimage',
1059 ] ) .
'</div>',
'description' );
1066 'section' =>
'description',
1067 'id' =>
'wpDestFile',
1068 'label-message' =>
'destfilename',
1071 # @todo FIXME: Hack to work around poor handling of the 'default' option in HTMLForm
1072 'nodata' => strval( $this->mDestFile ) !==
'',
1074 'UploadDescription' => [
1075 'type' =>
'textarea',
1076 'section' =>
'description',
1077 'id' =>
'wpUploadDescription',
1078 'label-message' => $this->mForReUpload
1079 ?
'filereuploadsummary'
1080 :
'fileuploadsummary',
1082 'cols' => $this->
getUser()->getIntOption(
'cols' ),
1086 if ( $this->mTextAfterSummary ) {
1087 $descriptor[
'UploadFormTextAfterSummary'] = [
1089 'section' =>
'description',
1097 'type' =>
'edittools',
1098 'section' =>
'description',
1099 'message' =>
'edittools-upload',
1103 if ( $this->mForReUpload ) {
1104 $descriptor[
'DestFile'][
'readonly'] =
true;
1106 $descriptor[
'License'] = [
1108 'class' =>
'Licenses',
1109 'section' =>
'description',
1110 'id' =>
'wpLicense',
1111 'label-message' =>
'license',
1115 if ( $config->get(
'UseCopyrightUpload' ) ) {
1116 $descriptor[
'UploadCopyStatus'] = [
1118 'section' =>
'description',
1119 'id' =>
'wpUploadCopyStatus',
1120 'label-message' =>
'filestatus',
1122 $descriptor[
'UploadSource'] = [
1124 'section' =>
'description',
1125 'id' =>
'wpUploadSource',
1126 'label-message' =>
'filesource',
1141 if (
$user->isLoggedIn() ) {
1145 'id' =>
'wpWatchthis',
1146 'label-message' =>
'watchthisupload',
1147 'section' =>
'options',
1152 if ( !$this->mHideIgnoreWarning ) {
1153 $descriptor[
'IgnoreWarning'] = [
1155 'id' =>
'wpIgnoreWarning',
1156 'label-message' =>
'ignorewarnings',
1157 'section' =>
'options',
1161 $descriptor[
'DestFileWarningAck'] = [
1163 'id' =>
'wpDestFileWarningAck',
1164 'default' => $this->mDestWarningAck ?
'1' :
'',
1167 if ( $this->mForReUpload ) {
1168 $descriptor[
'ForReUpload'] = [
1170 'id' =>
'wpForReUpload',
1192 $useAjaxDestCheck = $config->get(
'UseAjax' ) && $config->get(
'AjaxUploadDestCheck' );
1193 $useAjaxLicensePreview = $config->get(
'UseAjax' ) &&
1194 $config->get(
'AjaxLicensePreview' ) && $config->get(
'EnableAPI' );
1198 'wgAjaxUploadDestCheck' => $useAjaxDestCheck,
1199 'wgAjaxLicensePreview' => $useAjaxLicensePreview,
1200 'wgUploadAutoFill' => !$this->mForReUpload &&
1203 $this->mDestFile ===
'',
1205 'wgCheckFileExtensions' => $config->get(
'CheckFileExtensions' ),
1206 'wgStrictFileExtensions' => $config->get(
'StrictFileExtensions' ),
1207 'wgFileExtensions' => array_values( array_unique( $config->get(
'FileExtensions' ) ) ),
1214 $out->addJsConfigVars( $scriptVars );
1217 'mediawiki.action.edit',
1218 'mediawiki.special.upload',
1242 $id = $this->mParams[
'id'];
1245 if ( !empty( $this->mParams[
'radio'] ) ) {
1246 if ( isset( $this->mParams[
'radio-id'] ) ) {
1247 $radioId = $this->mParams[
'radio-id'];
1251 $radioId =
'wpSourceType' . $this->mParams[
'upload-type'];
1255 'name' =>
'wpSourceType',
1258 'value' => $this->mParams[
'upload-type'],
1261 if ( !empty( $this->mParams[
'checked'] ) ) {
1268 return Html::rawElement(
'td', [
'class' =>
'mw-label' ] + $cellAttributes, $label );
1275 return isset( $this->mParams[
'size'] )
1276 ? $this->mParams[
'size']
setContext(IContextSource $context)
Set the IContextSource object.
static getExistsWarning($exists)
Formats a result of UploadBase::getExistsWarning as HTML This check is static and can be done pre-upl...
getDupeWarning($dupes)
Construct a warning and a gallery from an array of duplicate files.
static rotationEnabled()
Should we rotate images in the preview on Special:Upload.
Interface for objects which can provide a MediaWiki context on request.
exists($flags=0)
Check if page exists.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
getLanguage()
Get the Language object.
and *available in your language For system and upgrade details
getContext()
Gets the context this SpecialPage is executed in.
Implements uploading from previously stored file.
getWatchCheck()
See if we should check the 'watch this page' checkbox on the form based on the user's preferences and...
static createFromRequest(&$request, $type=null)
Create a form of UploadBase depending on wpSourceType and initializes it.
static isAllowed($user)
Returns true if the user can use this upload module or else a string identifying the missing permissi...
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name.
showUploadForm($form)
Show the main upload form.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
An IContextSource implementation which will inherit context from another source but allow individual ...
null for the local wiki Added in
execute($par)
Special page entry point.
A form field that contains a radio box in the label.
bool $mForReUpload
The user followed an "overwrite this file" link.
showViewDeletedLinks()
Shows the "view X deleted revivions link"".
$uploadFormTextAfterSummary
msg()
Wrapper around wfMessage that sets the current context.
unsaveUploadedFile()
Remove a temporarily kept file stashed by saveTempUploadedFile().
getOutput()
Get the OutputPage being used for this instance.
Represents a title within MediaWiki.
when a variable name is used in a it is silently declared as a new local masking the global
wfLocalFile($title)
Get an object referring to a locally registered file.
bool $mUploadSuccessful
Subclasses can use this to determine whether a file was uploaded.
addHelpLink($to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static getMaxUploadSize($forType=null)
Get the MediaWiki maximum uploaded file size for given type of upload, based on $wgMaxUploadSize.
static showLogExtract(&$out, $types=[], $page= '', $user= '', $param=[])
Show log extract.
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
__construct($request=null)
Constructor : initialise object Get data POSTed through the form and assign them to the object...
userCanExecute(User $user)
This page can be shown if uploading is enabled.
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
static isCapitalized($index)
Is the namespace first-letter capitalized?
getRequest()
Get the WebRequest object.
static factory($mode=false, IContextSource $context=null)
Get a new image gallery.
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
getLabelHtml($cellAttributes=[])
static isThrottled($user)
Returns true if the user has surpassed the upload rate limit, false otherwise.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Parent class for all special pages.
static isEnabled()
Checks if the upload from URL feature is enabled.
string $mDesiredDestName
User input variables from the "description" section.
Interface for configuration instances.
An error page which can definitely be safely rendered using the OutputPage.
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
processVerificationError($details)
Provides output to the user for a result of UploadBase::verifyUpload.
static singleton()
Get a RepoGroup instance.
Form for handling uploads and special page.
$uploadFormTextTop
Text injection points for hooks not using HTMLForm.
getConfig()
Get the Config object.
getContext()
Get the base IContextSource object.
getTitle($subpage=false)
Get a self-referential title 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.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
WebRequest FauxRequest $mRequest
Misc variables.
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 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 after processing 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 unsetoffset-wrap String Wrap the message in html(usually something like"<
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead.&$feedLinks conditions will AND in the final query as a Content object as a Content object $title
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using hooks
const MIN_LENGTH_PARTNAME
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
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
Show an error when the user tries to do something whilst blocked.
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 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
static isEnabled()
Returns true if uploads are enabled.
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
showUploadError($message)
Show the upload form with error message, but do not stash the file.
static getDefaultInstance()
static isAllowed($user)
Checks if the user is allowed to use the upload-by-URL feature.
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
$mIgnoreWarning
User input variables from the root section.
loadRequest()
Initialize instance variables from request and create an Upload handler.
error also a ContextSource you ll probably need to make sure the header is varied on $request
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getUser()
Shortcut to get the User executing this instance.
getConfig()
Shortcut to get main config object.
Show an error when a user tries to do something they do not have the necessary permissions for...
const WINDOWS_NONASCII_FILENAME
getLanguage()
Shortcut to get user's language.
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
Generic handler for bitmap images.
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
static getMaxPhpUploadSize()
Get the PHP maximum uploaded file size, based on ini settings.
showRecoverableUploadError($message)
Stashes the upload and shows the main upload form.
bool $mCancelUpload
The user clicked "Cancel and return to upload form" button.
processUpload()
Do the upload.
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
getRequest()
Get the WebRequest being used for this instance.
$mDestWarningAck
Hidden variables.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
showUploadWarning($warnings)
Stashes the upload, shows the main form, but adds a "continue anyway button".
getUser()
Get the User object.
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
getUploadForm($message= '', $sessionKey= '', $hideIgnoreWarning=false)
Get an UploadForm instance with title and text properly set.
getPageTitle($subpage=false)
Get a self-referential title object.
getOutput()
Get the OutputPage object.
Allows to change the fields on the form that will be generated $name