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(
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::class,
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 ) {
176 $descriptor[
'UploadFileURL'] = [
177 'class' => UploadSourceField::class,
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() .
'">' .
272 Html::element(
'img', [
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::class,
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' );
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' ) ) ),
425 'wgCapitalizeUploads' => MWNamespace::isCapitalized(
NS_FILE ),
431 $out->addJsConfigVars( $scriptVars );
434 'mediawiki.special.upload',
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
static singleton()
Get a RepoGroup instance.
static rotationEnabled()
Should we rotate images in the preview on Special:Upload.
static getMaxUploadSize( $forType=null)
Get the MediaWiki maximum uploaded file size for given type of upload, based on $wgMaxUploadSize.
static getMaxPhpUploadSize()
Get the PHP maximum uploaded file size, based on ini settings.
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.
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
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
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
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
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
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
Interface for objects which can provide a MediaWiki context on request.