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
211 if ( !Hooks::run(
'UploadForm:initial', [ &$upload ] ) ) {
212 wfDebug(
"Hook 'UploadForm:initial' broke output of the upload form\n" );
220 if ( $this->mUpload ) {
221 $this->mUpload->cleanupTempFile();
231 # Add links if file was previously deleted
232 if ( $this->mDesiredDestName ) {
251 protected function getUploadForm( $message =
'', $sessionKey =
'', $hideIgnoreWarning =
false ) {
257 'forreupload' => $this->mForReUpload,
258 'sessionkey' => $sessionKey,
259 'hideignorewarning' => $hideIgnoreWarning,
260 'destwarningack' => (
bool)$this->mDestWarningAck,
262 'description' => $this->mComment,
263 'texttop' => $this->uploadFormTextTop,
264 'textaftersummary' => $this->uploadFormTextAfterSummary,
265 'destfile' => $this->mDesiredDestName,
268 # Check the token, but only if necessary
270 !$this->mTokenOk && !$this->mCancelUpload &&
271 ( $this->mUpload && $this->mUploadClicked )
273 $form->addPreText( $this->
msg(
'session_fail_preview' )->parse() );
276 # Give a notice if the user is uploading a file that has been deleted or moved
277 # Note that this is independent from the message 'filewasdeleted'
280 if ( $desiredTitleObj instanceof
Title && !$desiredTitleObj->
exists() ) {
284 'conds' => [
"log_action != 'revision'" ],
285 'showIfEmpty' =>
false,
286 'msgKey' => [
'upload-recreate-warning' ] ]
289 $form->addPreText( $delNotice );
292 $form->addPreText(
'<div id="uploadtext">' .
293 $this->
msg(
'uploadtext', [ $this->mDesiredDestName ] )->parseAsBlock() .
295 # Add upload error message
296 $form->addPreText( $message );
299 $uploadFooter = $this->
msg(
'uploadfooter' );
300 if ( !$uploadFooter->isDisabled() ) {
301 $form->addPostText(
'<div id="mw-upload-footer-message">'
302 . $uploadFooter->parseAsBlock() .
"</div>\n" );
317 if (
$count > 0 &&
$user->isAllowed(
'deletedhistory' ) ) {
320 $this->msg(
'restorelink' )->numParams(
$count )->escaped()
322 $link = $this->
msg(
$user->isAllowed(
'delete' ) ?
'thisisdeleted' :
'viewdeleted' )
323 ->rawParams( $restorelink )->parseAsBlock();
324 $this->
getOutput()->addHTML(
"<div id=\"contentSub2\">{$link}</div>" );
341 $sessionKey = $this->mUpload->stashSession();
342 $message =
'<h2>' . $this->
msg(
'uploaderror' )->escaped() .
"</h2>\n" .
343 '<div class="error">' . $message .
"</div>\n";
346 $form->setSubmitText( $this->
msg(
'upload-tryagain' )->escaped() );
359 # If there are no warnings, or warnings we can ignore, return early.
360 # mDestWarningAck is set when some javascript has shown the warning
361 # to the user. mForReUpload is set when the user clicks the "upload a
363 if ( !$warnings || ( count( $warnings ) == 1
364 && isset( $warnings[
'exists'] )
365 && ( $this->mDestWarningAck || $this->mForReUpload ) )
370 $sessionKey = $this->mUpload->stashSession();
373 $this->
getOutput()->addModuleStyles(
'mediawiki.special.upload' );
375 $warningHtml =
'<h2>' . $this->
msg(
'uploadwarning' )->escaped() .
"</h2>\n"
376 .
'<div class="mw-destfile-warning"><ul>';
377 foreach ( $warnings
as $warning =>
$args ) {
378 if ( $warning ==
'badfilename' ) {
381 if ( $warning ==
'exists' ) {
383 } elseif ( $warning ==
'was-deleted' ) {
384 # If the file existed before and was deleted, warn the user of this
395 $msg =
"\t<li>" .
wfMessage(
'filewasdeleted' )->rawParams( $llink )->parse() .
"</li>\n";
396 } elseif ( $warning ==
'duplicate' ) {
398 } elseif ( $warning ==
'duplicate-archive' ) {
399 if (
$args ===
'' ) {
400 $msg =
"\t<li>" . $this->
msg(
'file-deleted-duplicate-notitle' )->parse()
403 $msg =
"\t<li>" . $this->
msg(
'file-deleted-duplicate',
408 if (
$args ===
true ) {
410 } elseif ( !is_array(
$args ) ) {
413 $msg =
"\t<li>" . $this->
msg( $warning,
$args )->parse() .
"</li>\n";
415 $warningHtml .= $msg;
417 $warningHtml .=
"</ul></div>\n";
418 $warningHtml .= $this->
msg(
'uploadwarning-text' )->parseAsBlock();
420 $form = $this->
getUploadForm( $warningHtml, $sessionKey,
true );
421 $form->setSubmitText( $this->
msg(
'upload-tryagain' )->
text() );
423 'name' =>
'wpUploadIgnoreWarning',
424 'value' => $this->
msg(
'ignorewarning' )->
text()
427 'name' =>
'wpCancelUpload',
428 'value' => $this->
msg(
'reuploaddesc' )->
text()
433 # Indicate that we showed a form
443 $message =
'<h2>' . $this->
msg(
'uploadwarning' )->escaped() .
"</h2>\n" .
444 '<div class="error">' . $message .
"</div>\n";
454 $status = $this->mUpload->fetchFile();
462 if ( !Hooks::run(
'UploadForm:BeforeProcessing', [ &$upload ] ) ) {
463 wfDebug(
"Hook 'UploadForm:BeforeProcessing' broke processing the file.\n" );
473 $details = $this->mUpload->verifyUpload();
481 $permErrors = $this->mUpload->verifyTitlePermissions( $this->
getUser() );
482 if ( $permErrors !==
true ) {
483 $code = array_shift( $permErrors[0] );
489 $this->mLocalFile = $this->mUpload->getLocalFile();
492 if ( !$this->mIgnoreWarning ) {
493 $warnings = $this->mUpload->checkWarnings();
502 $this->
msg(
'actionthrottledtext' )->escaped()
508 if ( !$this->mForReUpload ) {
510 $this->mCopyrightStatus, $this->mCopyrightSource, $this->
getConfig() );
515 $changeTags = $this->
getRequest()->getVal(
'wpChangeTags' );
516 if ( is_null( $changeTags ) || $changeTags ===
'' ) {
519 $changeTags = array_filter( array_map(
'trim', explode(
',', $changeTags ) ) );
524 $changeTags, $this->
getUser() );
525 if ( !$changeTagsStatus->isOK() ) {
532 $status = $this->mUpload->performUpload(
547 $this->mUploadSuccessful =
true;
550 Hooks::run(
'SpecialUploadComplete', [ &$upload ] );
551 $this->
getOutput()->redirect( $this->mLocalFile->getTitle()->getFullURL() );
566 if ( $config ===
null ) {
567 wfDebug( __METHOD__ .
' called without a Config instance passed to it' );
568 $config = ConfigFactory::getDefaultInstance()->makeConfig(
'main' );
572 $forceUIMsgAsContentMsg = (
array)$config->get(
'ForceUIMsgAsContentMsg' );
577 foreach ( [
'license-header',
'filedesc',
'filestatus',
'filesource' ]
as $msgName ) {
578 if ( in_array( $msgName, $forceUIMsgAsContentMsg ) ) {
579 $msg[$msgName] =
"{{int:$msgName}}";
581 $msg[$msgName] =
wfMessage( $msgName )->inContentLanguage()->text();
585 if ( $config->get(
'UseCopyrightUpload' ) ) {
588 $licensetxt =
'== ' . $msg[
'license-header'] .
" ==\n" .
'{{' .
$license .
'}}' .
"\n";
590 $pageText =
'== ' . $msg[
'filedesc'] .
" ==\n" .
$comment .
"\n" .
591 '== ' . $msg[
'filestatus'] .
" ==\n" . $copyStatus .
"\n" .
593 '== ' . $msg[
'filesource'] .
" ==\n" .
$source;
596 $filedesc =
$comment ==
'' ?
'' :
'== ' . $msg[
'filedesc'] .
" ==\n" .
$comment .
"\n";
597 $pageText = $filedesc .
598 '== ' . $msg[
'license-header'] .
" ==\n" .
'{{' .
$license .
'}}' .
"\n";
620 if ( $this->
getUser()->getOption(
'watchdefault' ) ) {
626 if ( $desiredTitleObj instanceof
Title && $this->
getUser()->isWatched( $desiredTitleObj ) ) {
632 if ( $local && $local->exists() ) {
638 return $this->
getUser()->getOption(
'watchcreations' ) ||
639 $this->
getUser()->getOption(
'watchuploads' );
650 switch ( $details[
'status'] ) {
658 $details[
'filtered'] )->parse() );
678 $msg = $this->
msg(
'filetype-banned-type' );
679 if ( isset( $details[
'blacklistedExt'] ) ) {
680 $msg->params( $this->
getLanguage()->commaList( $details[
'blacklistedExt'] ) );
682 $msg->params( $details[
'finalExt'] );
691 if ( isset( $details[
'blacklistedExt'] ) ) {
692 $msg->params( count( $details[
'blacklistedExt'] ) );
700 unset( $details[
'status'] );
701 $code = array_shift( $details[
'details'] );
705 if ( is_array( $details[
'error'] ) ) { # allow
hooks to
return error details
in an
array
706 $args = $details[
'error'];
707 $error = array_shift(
$args );
709 $error = $details[
'error'];
716 throw new MWException( __METHOD__ .
": Unknown value `{$details['status']}`" );
729 $success = $this->mUpload->unsaveUploadedFile();
731 $this->
getOutput()->showFileDeleteError( $this->mUpload->getTempPath() );
753 $file = $exists[
'file'];
754 $filename = $file->getTitle()->getPrefixedText();
757 if ( $exists[
'warning'] ==
'exists' ) {
759 $warning =
wfMessage(
'fileexists', $filename )->parse();
760 } elseif ( $exists[
'warning'] ==
'page-exists' ) {
762 $warning =
wfMessage(
'filepageexists', $filename )->parse();
763 } elseif ( $exists[
'warning'] ==
'exists-normalized' ) {
764 $warning =
wfMessage(
'fileexists-extension', $filename,
765 $exists[
'normalizedFile']->
getTitle()->getPrefixedText() )->parse();
766 } elseif ( $exists[
'warning'] ==
'thumb' ) {
768 $warning =
wfMessage(
'fileexists-thumbnail-yes',
769 $exists[
'thumbFile']->
getTitle()->getPrefixedText(), $filename )->parse();
770 } elseif ( $exists[
'warning'] ==
'thumb-name' ) {
772 $name = $file->getName();
773 $badPart = substr(
$name, 0, strpos(
$name,
'-' ) + 1 );
774 $warning =
wfMessage(
'file-thumbnail-no', $badPart )->parse();
775 } elseif ( $exists[
'warning'] ==
'bad-prefix' ) {
776 $warning =
wfMessage(
'filename-bad-prefix', $exists[
'prefix'] )->parse();
793 $gallery->setShowBytes(
false );
794 foreach ( $dupes
as $file ) {
795 $gallery->add( $file->getTitle() );
799 $this->
msg(
'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() .
800 $gallery->toHTML() .
"</li>\n";
816 return $bitmapHandler->autoRotateEnabled();
846 $this->mWatch = !empty(
$options[
'watch'] );
847 $this->mForReUpload = !empty(
$options[
'forreupload'] );
848 $this->mSessionKey = isset(
$options[
'sessionkey'] ) ?
$options[
'sessionkey'] :
'';
849 $this->mHideIgnoreWarning = !empty(
$options[
'hideignorewarning'] );
850 $this->mDestWarningAck = !empty(
$options[
'destwarningack'] );
851 $this->mDestFile = isset(
$options[
'destfile'] ) ?
$options[
'destfile'] :
'';
853 $this->mComment = isset(
$options[
'description'] ) ?
856 $this->mTextTop = isset(
$options[
'texttop'] )
859 $this->mTextAfterSummary = isset(
$options[
'textaftersummary'] )
860 ?
$options[
'textaftersummary'] :
'';
863 $descriptor = $sourceDescriptor
867 Hooks::run(
'UploadFormInitDescriptor', [ &$descriptor ] );
868 parent::__construct( $descriptor,
$context,
'upload' );
870 # Add a link to edit MediaWik:Licenses
871 if ( $this->
getUser()->isAllowed(
'editinterface' ) ) {
872 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
874 $this->
msg(
'licenses' )->inContentLanguage()->
getTitle(),
875 $this->
msg(
'licenses-edit' )->escaped(),
877 [
'action' =>
'edit' ]
879 $editLicenses =
'<p class="mw-upload-editlicenses">' . $licensesLink .
'</p>';
883 # Set some form properties
886 # Used message keys: 'accesskey-upload', 'tooltip-upload'
888 $this->
setId(
'mw-upload-form' );
890 # Build a list of IDs for javascript insertion
891 $this->mSourceIds = [];
892 foreach ( $sourceDescriptor
as $field ) {
893 if ( !empty( $field[
'id'] ) ) {
894 $this->mSourceIds[] = $field[
'id'];
906 if ( $this->mSessionKey ) {
914 'default' =>
'Stash',
921 && $this->
getConfig()->get(
'CopyUploadsFromSpecialUpload' );
922 $radio = $canUploadByUrl;
923 $selectedSourceType = strtolower( $this->
getRequest()->getText(
'wpSourceType',
'File' ) );
926 if ( $this->mTextTop ) {
927 $descriptor[
'UploadFormTextTop'] = [
929 'section' =>
'source',
935 $this->mMaxUploadSize[
'file'] = min(
940 $help = $this->
msg(
'upload-maxfilesize',
946 if ( $canUploadByUrl ) {
947 $help .= $this->
msg(
'word-separator' )->escaped();
948 $help .= $this->
msg(
'upload_source_file' )->parse();
951 $descriptor[
'UploadFile'] = [
952 'class' =>
'UploadSourceField',
953 'section' =>
'source',
955 'id' =>
'wpUploadFile',
956 'radio-id' =>
'wpSourceTypeFile',
957 'label-message' =>
'sourcefilename',
958 'upload-type' =>
'File',
961 'checked' => $selectedSourceType ==
'file',
964 if ( $canUploadByUrl ) {
966 $descriptor[
'UploadFileURL'] = [
967 'class' =>
'UploadSourceField',
968 'section' =>
'source',
969 'id' =>
'wpUploadFileURL',
970 'radio-id' =>
'wpSourceTypeurl',
971 'label-message' =>
'sourceurl',
972 'upload-type' =>
'url',
974 'help' => $this->
msg(
'upload-maxfilesize',
977 $this->
msg(
'word-separator' )->escaped() .
978 $this->
msg(
'upload_source_url' )->parse(),
979 'checked' => $selectedSourceType ==
'url',
982 Hooks::run(
'UploadFormSourceDescriptors', [ &$descriptor, &$radio, $selectedSourceType ] );
984 $descriptor[
'Extensions'] = [
986 'section' =>
'source',
1000 # Print a list of allowed file extensions, if so configured. We ignore
1001 # MIME type here, it's incomprehensible to most people and too long.
1004 if ( $config->get(
'CheckFileExtensions' ) ) {
1005 $fileExtensions = array_unique( $config->get(
'FileExtensions' ) );
1006 if ( $config->get(
'StrictFileExtensions' ) ) {
1007 # Everything not permitted is banned
1009 '<div id="mw-upload-permitted">' .
1010 $this->
msg(
'upload-permitted' )
1011 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
1012 ->numParams( count( $fileExtensions ) )
1016 # We have to list both preferred and prohibited
1017 $fileBlacklist = array_unique( $config->get(
'FileBlacklist' ) );
1019 '<div id="mw-upload-preferred">' .
1020 $this->
msg(
'upload-preferred' )
1021 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
1022 ->numParams( count( $fileExtensions ) )
1025 '<div id="mw-upload-prohibited">' .
1026 $this->
msg(
'upload-prohibited' )
1027 ->params( $this->
getLanguage()->commaList( $fileBlacklist ) )
1028 ->numParams( count( $fileBlacklist ) )
1033 # Everything is permitted.
1034 $extensionsList =
'';
1037 return $extensionsList;
1048 if ( $this->mSessionKey ) {
1051 $file = $stash->getFile( $this->mSessionKey );
1052 }
catch ( Exception
$e ) {
1058 $mto = $file->transform( [
'width' => 120 ] );
1061 '<div class="thumb t' . $wgContLang->alignEnd() .
'">' .
1063 'src' => $mto->getUrl(),
1064 'class' =>
'thumbimage',
1065 ] ) .
'</div>',
'description' );
1073 'section' =>
'description',
1074 'id' =>
'wpDestFile',
1075 'label-message' =>
'destfilename',
1078 # @todo FIXME: Hack to work around poor handling of the 'default' option in HTMLForm
1079 'nodata' => strval( $this->mDestFile ) !==
'',
1081 'UploadDescription' => [
1082 'type' =>
'textarea',
1083 'section' =>
'description',
1084 'id' =>
'wpUploadDescription',
1085 'label-message' => $this->mForReUpload
1086 ?
'filereuploadsummary'
1087 :
'fileuploadsummary',
1089 'cols' => $this->
getUser()->getIntOption(
'cols' ),
1093 if ( $this->mTextAfterSummary ) {
1094 $descriptor[
'UploadFormTextAfterSummary'] = [
1096 'section' =>
'description',
1104 'type' =>
'edittools',
1105 'section' =>
'description',
1106 'message' =>
'edittools-upload',
1110 if ( $this->mForReUpload ) {
1111 $descriptor[
'DestFile'][
'readonly'] =
true;
1113 $descriptor[
'License'] = [
1115 'class' =>
'Licenses',
1116 'section' =>
'description',
1117 'id' =>
'wpLicense',
1118 'label-message' =>
'license',
1122 if ( $config->get(
'UseCopyrightUpload' ) ) {
1123 $descriptor[
'UploadCopyStatus'] = [
1125 'section' =>
'description',
1126 'id' =>
'wpUploadCopyStatus',
1127 'label-message' =>
'filestatus',
1129 $descriptor[
'UploadSource'] = [
1131 'section' =>
'description',
1132 'id' =>
'wpUploadSource',
1133 'label-message' =>
'filesource',
1148 if (
$user->isLoggedIn() ) {
1152 'id' =>
'wpWatchthis',
1153 'label-message' =>
'watchthisupload',
1154 'section' =>
'options',
1159 if ( !$this->mHideIgnoreWarning ) {
1160 $descriptor[
'IgnoreWarning'] = [
1162 'id' =>
'wpIgnoreWarning',
1163 'label-message' =>
'ignorewarnings',
1164 'section' =>
'options',
1168 $descriptor[
'DestFileWarningAck'] = [
1170 'id' =>
'wpDestFileWarningAck',
1171 'default' => $this->mDestWarningAck ?
'1' :
'',
1174 if ( $this->mForReUpload ) {
1175 $descriptor[
'ForReUpload'] = [
1177 'id' =>
'wpForReUpload',
1199 $useAjaxDestCheck = $config->get(
'UseAjax' ) && $config->get(
'AjaxUploadDestCheck' );
1200 $useAjaxLicensePreview = $config->get(
'UseAjax' ) &&
1201 $config->get(
'AjaxLicensePreview' ) && $config->get(
'EnableAPI' );
1205 'wgAjaxUploadDestCheck' => $useAjaxDestCheck,
1206 'wgAjaxLicensePreview' => $useAjaxLicensePreview,
1207 'wgUploadAutoFill' => !$this->mForReUpload &&
1210 $this->mDestFile ===
'',
1212 'wgCheckFileExtensions' => $config->get(
'CheckFileExtensions' ),
1213 'wgStrictFileExtensions' => $config->get(
'StrictFileExtensions' ),
1214 'wgFileExtensions' => array_values( array_unique( $config->get(
'FileExtensions' ) ) ),
1221 $out->addJsConfigVars( $scriptVars );
1224 'mediawiki.action.edit',
1225 'mediawiki.special.upload',
1249 $id = $this->mParams[
'id'];
1252 if ( !empty( $this->mParams[
'radio'] ) ) {
1253 if ( isset( $this->mParams[
'radio-id'] ) ) {
1254 $radioId = $this->mParams[
'radio-id'];
1258 $radioId =
'wpSourceType' . $this->mParams[
'upload-type'];
1262 'name' =>
'wpSourceType',
1265 'value' => $this->mParams[
'upload-type'],
1268 if ( !empty( $this->mParams[
'checked'] ) ) {
1275 return Html::rawElement(
'td', [
'class' =>
'mw-label' ] + $cellAttributes, $label );
1282 return isset( $this->mParams[
'size'] )
1283 ? $this->mParams[
'size']
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 element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
Class to represent a local file in the wiki's own database.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
static isCapitalized( $index)
Is the namespace first-letter capitalized?
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.
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.
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.
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
exists( $flags=0)
Check if page exists.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
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
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
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables 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
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
namespace and then decline to actually register it file or subcat img or subcat $title
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
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
Allows to change the fields on the form that will be generated $name
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.