Go to the documentation of this file.
53 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
56 $this->mWatch = !empty(
$options[
'watch'] );
57 $this->mForReUpload = !empty(
$options[
'forreupload'] );
58 $this->mSessionKey = isset(
$options[
'sessionkey'] ) ?
$options[
'sessionkey'] :
'';
59 $this->mHideIgnoreWarning = !empty(
$options[
'hideignorewarning'] );
60 $this->mDestWarningAck = !empty(
$options[
'destwarningack'] );
61 $this->mDestFile = isset(
$options[
'destfile'] ) ?
$options[
'destfile'] :
'';
63 $this->mComment = isset(
$options[
'description'] ) ?
66 $this->mTextTop = isset(
$options[
'texttop'] )
69 $this->mTextAfterSummary = isset(
$options[
'textaftersummary'] )
73 $descriptor = $sourceDescriptor
77 Hooks::run(
'UploadFormInitDescriptor', [ &$descriptor ] );
78 parent::__construct( $descriptor,
$context,
'upload' );
80 # Add a link to edit MediaWiki:Licenses
81 if ( $this->
getUser()->isAllowed(
'editinterface' ) ) {
82 $this->
getOutput()->addModuleStyles(
'mediawiki.special.upload.styles' );
84 $this->
msg(
'licenses' )->inContentLanguage()->
getTitle(),
85 $this->
msg(
'licenses-edit' )->
text(),
87 [
'action' =>
'edit' ]
89 $editLicenses =
'<p class="mw-upload-editlicenses">' . $licensesLink .
'</p>';
93 # Set some form properties
96 # Used message keys: 'accesskey-upload', 'tooltip-upload'
98 $this->
setId(
'mw-upload-form' );
100 # Build a list of IDs for javascript insertion
101 $this->mSourceIds = [];
102 foreach ( $sourceDescriptor
as $field ) {
103 if ( !empty( $field[
'id'] ) ) {
104 $this->mSourceIds[] = $field[
'id'];
116 if ( $this->mSessionKey ) {
124 'default' =>
'Stash',
131 && $this->
getConfig()->get(
'CopyUploadsFromSpecialUpload' );
132 $radio = $canUploadByUrl;
133 $selectedSourceType = strtolower( $this->
getRequest()->getText(
'wpSourceType',
'File' ) );
136 if ( $this->mTextTop ) {
137 $descriptor[
'UploadFormTextTop'] = [
139 'section' =>
'source',
145 $this->mMaxUploadSize[
'file'] = min(
146 UploadBase::getMaxUploadSize(
'file' ),
147 UploadBase::getMaxPhpUploadSize()
150 $help = $this->
msg(
'upload-maxfilesize',
156 if ( $canUploadByUrl ) {
157 $help .= $this->
msg(
'word-separator' )->escaped();
158 $help .= $this->
msg(
'upload_source_file' )->parse();
161 $descriptor[
'UploadFile'] = [
162 'class' =>
'UploadSourceField',
163 'section' =>
'source',
165 'id' =>
'wpUploadFile',
166 'radio-id' =>
'wpSourceTypeFile',
167 'label-message' =>
'sourcefilename',
168 'upload-type' =>
'File',
171 'checked' => $selectedSourceType ==
'file',
174 if ( $canUploadByUrl ) {
175 $this->mMaxUploadSize[
'url'] = UploadBase::getMaxUploadSize(
'url' );
176 $descriptor[
'UploadFileURL'] = [
177 'class' =>
'UploadSourceField',
178 'section' =>
'source',
179 'id' =>
'wpUploadFileURL',
180 'radio-id' =>
'wpSourceTypeurl',
181 'label-message' =>
'sourceurl',
182 'upload-type' =>
'url',
184 'help' => $this->
msg(
'upload-maxfilesize',
187 $this->
msg(
'word-separator' )->escaped() .
188 $this->
msg(
'upload_source_url' )->parse(),
189 'checked' => $selectedSourceType ==
'url',
192 Hooks::run(
'UploadFormSourceDescriptors', [ &$descriptor, &$radio, $selectedSourceType ] );
194 $descriptor[
'Extensions'] = [
196 'section' =>
'source',
210 # Print a list of allowed file extensions, if so configured. We ignore
211 # MIME type here, it's incomprehensible to most people and too long.
214 if ( $config->get(
'CheckFileExtensions' ) ) {
215 $fileExtensions = array_unique( $config->get(
'FileExtensions' ) );
216 if ( $config->get(
'StrictFileExtensions' ) ) {
217 # Everything not permitted is banned
219 '<div id="mw-upload-permitted">' .
220 $this->
msg(
'upload-permitted' )
221 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
222 ->numParams(
count( $fileExtensions ) )
226 # We have to list both preferred and prohibited
227 $fileBlacklist = array_unique( $config->get(
'FileBlacklist' ) );
229 '<div id="mw-upload-preferred">' .
230 $this->
msg(
'upload-preferred' )
231 ->params( $this->
getLanguage()->commaList( $fileExtensions ) )
232 ->numParams(
count( $fileExtensions ) )
235 '<div id="mw-upload-prohibited">' .
236 $this->
msg(
'upload-prohibited' )
237 ->params( $this->
getLanguage()->commaList( $fileBlacklist ) )
238 ->numParams(
count( $fileBlacklist ) )
243 # Everything is permitted.
244 $extensionsList =
'';
247 return $extensionsList;
258 if ( $this->mSessionKey ) {
261 $file = $stash->getFile( $this->mSessionKey );
262 }
catch ( Exception
$e ) {
268 $mto = $file->transform( [
'width' => 120 ] );
271 '<div class="thumb t' . $wgContLang->alignEnd() .
'">' .
273 'src' => $mto->getUrl(),
274 'class' =>
'thumbimage',
275 ] ) .
'</div>',
'description' );
283 'section' =>
'description',
284 'id' =>
'wpDestFile',
285 'label-message' =>
'destfilename',
288 # @todo FIXME: Hack to work around poor handling of the 'default' option in HTMLForm
289 'nodata' => strval( $this->mDestFile ) !==
'',
291 'UploadDescription' => [
292 'type' =>
'textarea',
293 'section' =>
'description',
294 'id' =>
'wpUploadDescription',
295 'label-message' => $this->mForReUpload
296 ?
'filereuploadsummary'
297 :
'fileuploadsummary',
303 if ( $this->mTextAfterSummary ) {
304 $descriptor[
'UploadFormTextAfterSummary'] = [
306 'section' =>
'description',
314 'type' =>
'edittools',
315 'section' =>
'description',
316 'message' =>
'edittools-upload',
320 if ( $this->mForReUpload ) {
321 $descriptor[
'DestFile'][
'readonly'] =
true;
323 $descriptor[
'License'] = [
325 'class' =>
'Licenses',
326 'section' =>
'description',
328 'label-message' =>
'license',
332 if ( $config->get(
'UseCopyrightUpload' ) ) {
333 $descriptor[
'UploadCopyStatus'] = [
335 'section' =>
'description',
336 'id' =>
'wpUploadCopyStatus',
337 'label-message' =>
'filestatus',
339 $descriptor[
'UploadSource'] = [
341 'section' =>
'description',
342 'id' =>
'wpUploadSource',
343 'label-message' =>
'filesource',
358 if (
$user->isLoggedIn() ) {
362 'id' =>
'wpWatchthis',
363 'label-message' =>
'watchthisupload',
364 'section' =>
'options',
369 if ( !$this->mHideIgnoreWarning ) {
370 $descriptor[
'IgnoreWarning'] = [
372 'id' =>
'wpIgnoreWarning',
373 'label-message' =>
'ignorewarnings',
374 'section' =>
'options',
378 $descriptor[
'DestFileWarningAck'] = [
380 'id' =>
'wpDestFileWarningAck',
381 'default' => $this->mDestWarningAck ?
'1' :
'',
384 if ( $this->mForReUpload ) {
385 $descriptor[
'ForReUpload'] = [
387 'id' =>
'wpForReUpload',
409 $useAjaxDestCheck = $config->get(
'UseAjax' ) && $config->get(
'AjaxUploadDestCheck' );
410 $useAjaxLicensePreview = $config->get(
'UseAjax' ) &&
411 $config->get(
'AjaxLicensePreview' ) && $config->get(
'EnableAPI' );
412 $this->mMaxUploadSize[
'*'] = UploadBase::getMaxUploadSize();
415 'wgAjaxUploadDestCheck' => $useAjaxDestCheck,
416 'wgAjaxLicensePreview' => $useAjaxLicensePreview,
417 'wgUploadAutoFill' => !$this->mForReUpload &&
420 $this->mDestFile ===
'',
422 'wgCheckFileExtensions' => $config->get(
'CheckFileExtensions' ),
423 'wgStrictFileExtensions' => $config->get(
'StrictFileExtensions' ),
424 'wgFileExtensions' => array_values( array_unique( $config->get(
'FileExtensions' ) ) ),
431 $out->addJsConfigVars( $scriptVars );
434 'mediawiki.special.upload',
getConfig()
Get the Config object.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
getContext()
Get the base IContextSource object.
static singleton()
Get a RepoGroup instance.
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
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
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
getRequest()
Get the WebRequest object.
getUser()
Get the User object.
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
getLanguage()
Get the Language object.
static isEnabled()
Checks if the upload from URL feature is enabled.
getOutput()
Get the OutputPage object.
when a variable name is used in a it is silently declared as a new masking the global
setContext(IContextSource $context)
Set the IContextSource object.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
static rotationEnabled()
Should we rotate images in the preview on Special:Upload.
Interface for objects which can provide a MediaWiki context on request.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static isCapitalized( $index)
Is the namespace first-letter capitalized?
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
static isAllowed( $user)
Checks if the user is allowed to use the upload-by-URL feature.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
the array() calling protocol came about after MediaWiki 1.4rc1.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out