Extension:UploadWizard - MediaWiki (original) (raw)

Languages:

MediaWiki extensions manual

UploadWizard Release status: stable
Implementation Media, Special page
Description Multi-file, step-by-step upload wizard
Author(s) Neil Kandalgaonkar, Jeroen De Dauw, Mark Holmquist, Ryan Kaldari, Ankur Anand, Yuvi Panda, Michael Dale,
Latest version continuous updates
MediaWiki >= 1.43
Database changes Yes
Tables uw_campaigns
License GNU General Public License 2.0 or later
Download Download extension Git [?]: Download Git master browse repository (GitHub) commit history repository contributors (GitHub) code reviewREADME
Namespace Campaign
Parameters $wgUploadWizardConfig
Added rights upwizcampaigns mass-upload
Hooks used ArticleDeleteComplete BeforePageDisplay ChangeTagsAllowedAdd ChangeTagsListActive CodeEditorGetPageLanguage ContentModelCanBeUsedOn EditFilterMergedContent GetPreferences IsUploadAllowedFromUrl LinksUpdateComplete ListDefinedTags LoadExtensionSchemaUpdates PageMoveComplete PageSaveComplete PreferencesGetIcon
Quarterly downloads 192 (Ranked 31st)
Translate the UploadWizard extension if it is available at translatewiki.net
Vagrant role uploadwizard
Issues Open tasks · Report a bug

The UploadWizard extension allows a user to upload multiple files with a step-by-step JavaScript wizard.

See also: Upload Wizard description page on Wikimedia Commons

Enabling uploads and thumbnails

[edit]

Your MediaWiki will need to be capable of hosting media files and creating thumbnails (smaller previews of media files). If you can upload images and see smaller previews on their File page, you're already ready. If not, for full instructions, see Manual:Image administration , particularly image thumbnailing.

For GNU/Linux or macOS users

$wgEnableUploads = true; $wgUseImageMagick = true; $wgImageMagickConvertCommand = ; # Only needs to be set if different from /usr/bin/convert

wfLoadExtension( 'UploadWizard' );

You should also install the EventLogging extension. This is used only if you use the campaigns feature, and should be made a soft dependency at some point in the future.

If you use Internet Explorer, you'll also need to change the following core configuration variable. See phab:T41877:

$wgApiFrameOptions = 'SAMEORIGIN';

Enabling Flickr uploads

[edit]

You can also use UploadWizard to transfer files directly from Flickr. To enable this option, first you'll need to get an API key from Flickr:

  1. Log in to Flickr;
  2. Go to the Apps By You page in the Flickr App Garden;
  3. Click on 'Get another key';
  4. Choose 'Apply for a non-commercial key';
  5. Enter a name and a description and check the two waiver checkboxes before submitting.

Once you have a key, append the following to your LocalSettings.php:

$wgAllowCopyUploads = true; $wgGroupPermissions['user']['upload_by_url'] = true; $wgCopyUploadsDomains = ['.flickr.com', '.staticflickr.com']; $wgUploadWizardConfig['flickrApiKey'] = 'YOUR_FLICKR_KEY_HERE';

Other configuration

[edit]

$wgExtensionFunctions[] = function() { $GLOBALS['wgUploadNavigationUrl'] = SpecialPage::getTitleFor( 'UploadWizard' )->getLocalURL(); return true; };

This modifies the sidebar's "Upload file" link - probably in other places as well. More at Manual:$wgUploadNavigationUrl .

Several other options are available through a configuration array. For example:

$wgUploadWizardConfig = [ 'debug' => false, 'autoAdd' => [ 'wikitext' => [ 'This file was uploaded with the UploadWizard extension.' ], 'categories' => [ 'Uploaded with UploadWizard' ], ], // Should be localised to the language of your wiki instance 'feedbackPage' => 'Feedback about UploadWizard', 'altUploadForm' => 'Special:Upload', 'feedbackLink' => false, // Disable the link for feedback (default: points to Commons) 'alternativeUploadToolsPage' => false, // Disable the link to alternative upload tools (default: points to Commons) 'enableFormData' => true, // Enable FileAPI uploads be used on supported browsers 'enableMultipleFiles' => true, 'enableMultiFileSelect' => false, 'uwLanguages' => [ 'ar' => 'العربية', 'de' => 'Deutsch', 'en' => 'English' ], // Selectable languages for file descriptions - defaults to 'en' 'tutorial' => [ 'skip' => true ], // Skip the tutorial 'maxUploads' => 15, // Number of uploads with one form - defaults to 50 'fileExtensions' => $wgFileExtensions // omitting this may cause errors ];

Usage in license-free environments

[edit]

If you are installing UploadWizard in an environment where licenses are not used, you may want to add the configuration below to LocalSettings.php. This will limit the license choices to a single default that references the wiki's generic disclaimer. Note that there are many other configuration settings to add depending on your use case.

$wgUploadWizardConfig = [ 'licensing' => [ 'ownWorkDefault' => 'own', 'ownWork' => [ 'type' => 'or', 'template' => 'licensing', // this adds a link to Template:Licensing to the file info page 'licenses' => [ 'generic', ], ], ], ];

These are just some sample settings. See the UploadWizard.config.php file (starting around line 80) for many more options supported in the $wgUploadWizardConfig array.

Modifying the generic UI messages

[edit]

If you wish to modify the generic messages, you can do so within the wiki itself editing the following pages:

Modifying file pages created by Upload Wizard

[edit]

To modify the wikitext of file pages created by UploadWizard, add a hook to LocalSettings.php that fires on every page save, then check if the page has the structure of a page created by UploadWizard, and modify it to your liking. For example: wgHooks[′ParserPreSaveTransformComplete′][]=function(ParserwgHooks['ParserPreSaveTransformComplete'][] = function ( Parser wgHooks[ParserPreSaveTransformComplete][]=function(Parserparser, string &$text ) { if ( preg_match( '/=={{int:filedesc}}== {{Information |description=(.) |date=(.) |source=(.) |author=(.) |permission=(.) |other versions=(.) }}

=={{int:license-header}}== {{(.*)}} (.)/', text,text, text,matches ) ) {

    // Get data
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi><mi>e</mi><mi>s</mi><mi>c</mi><mi>r</mi><mi>i</mi><mi>p</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">description = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">d</span><span class="mord mathnormal" style="margin-right:0.02778em;">escr</span><span class="mord mathnormal">i</span><span class="mord mathnormal">pt</span><span class="mord mathnormal">i</span><span class="mord mathnormal">o</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>matches[1];
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi><mi>a</mi><mi>t</mi><mi>e</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">date = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span><span class="mord mathnormal">a</span><span class="mord mathnormal">t</span><span class="mord mathnormal">e</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>matches[2];
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>s</mi><mi>o</mi><mi>u</mi><mi>r</mi><mi>c</mi><mi>e</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">source = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">so</span><span class="mord mathnormal">u</span><span class="mord mathnormal">rce</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>matches[3];
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi>u</mi><mi>t</mi><mi>h</mi><mi>o</mi><mi>r</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">author = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mord mathnormal">u</span><span class="mord mathnormal">t</span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.02778em;">or</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>matches[4];
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mi>e</mi><mi>r</mi><mi>m</mi><mi>i</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">permission = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.854em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.02778em;">er</span><span class="mord mathnormal">mi</span><span class="mord mathnormal">ss</span><span class="mord mathnormal">i</span><span class="mord mathnormal">o</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>matches[5];
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>o</mi><mi>t</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>V</mi><mi>e</mi><mi>r</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>s</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">otherVersions = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">o</span><span class="mord mathnormal">t</span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.02778em;">er</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord mathnormal">ers</span><span class="mord mathnormal">i</span><span class="mord mathnormal">o</span><span class="mord mathnormal">n</span><span class="mord mathnormal">s</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>matches[6];
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>l</mi><mi>i</mi><mi>c</mi><mi>e</mi><mi>n</mi><mi>s</mi><mi>e</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">license = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">i</span><span class="mord mathnormal">ce</span><span class="mord mathnormal">n</span><span class="mord mathnormal">se</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>matches[7];
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>l</mi><mi>i</mi><mi>c</mi><mi>e</mi><mi>n</mi><mi>s</mi><mi>e</mi><mi>D</mi><mi>e</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>l</mi><mi>s</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">licenseDetails = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">i</span><span class="mord mathnormal">ce</span><span class="mord mathnormal">n</span><span class="mord mathnormal">seDe</span><span class="mord mathnormal">t</span><span class="mord mathnormal">ai</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">s</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>matches[8];

    // Process data
    if ( $source === '{{own}}' ) {
        $source = 'Own work';
    }
    if ( preg_match( '/\[\[([^|]+)\|[^]]+\]\]/', <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi>u</mi><mi>t</mi><mi>h</mi><mi>o</mi><mi>r</mi><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">author, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">a</span><span class="mord mathnormal">u</span><span class="mord mathnormal">t</span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.02778em;">or</span><span class="mpunct">,</span></span></span></span>matches ) ) {
     <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi>u</mi><mi>t</mi><mi>h</mi><mi>o</mi><mi>r</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">author = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mord mathnormal">u</span><span class="mord mathnormal">t</span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.02778em;">or</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>matches[1]; // Unlink the author
    }
    if ( $licenseDetails ) {
     <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>l</mi><mi>i</mi><mi>c</mi><mi>e</mi><mi>n</mi><mi>s</mi><mi>e</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">license = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">i</span><span class="mord mathnormal">ce</span><span class="mord mathnormal">n</span><span class="mord mathnormal">se</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>licenseDetails;
    }

    // Build wikitext
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>t</mi><mi>e</mi><mi>x</mi><mi>t</mi><mo>=</mo><mi mathvariant="normal">&quot;</mi></mrow><annotation encoding="application/x-tex">text = &quot;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord mathnormal">t</span><span class="mord mathnormal">e</span><span class="mord mathnormal">x</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&quot;</span></span></span></span>description

{{File data | date = $date | author = $author | source = $source | license = $license }}"; } };

There are several URL arguments that can be specified to alter the behaviour of the UploadWizard:

(e.g. fields[]=value_first&fields[]=value_second)

These arguments can be specified as follows: if you have an argument named campaign and want to provide the value foobar, then append campaign=foobar to the url. For example wiki/Special:UploadWizard?campaign=foobar or w/index.php?title=Special:UploadWizard&campaign=foobar.

The following URL arguments are still supported for existing URLs, but deprecated:

Upload Wizard provides a way to store “object references” - references to list templates in Wiki pages - in the file description page. These may be used by bots to insert a thumbnail image into a list page. A bot that is doing this for monument lists of German Wikipedia is running on tool labs. Its code is hosted on GitHub. Though its purpose is to update monument lists on Wikipedia it can be adopted to serve in different scenarios.

This feature uses the parameters objref and updateList. If both parameters are passed, the Upload Wizard shows a checkbox for each upload, which can be used to select the image that the object reference is added to. If the parameter updateList is omitted, the checkboxes will be disabled and an additional notice is being displayed stating that an image for the object already exists in the list.

If you're testing UploadWizard for whatever reason, and you've run out of "real" images to upload as test cases, you can always use the handy MediaWiki utility for creating test images. Open a terminal emulator, get into a directory where you want to store a bunch of test JPG files, and run

$ php path/to/mediawiki/tests/phpunit/includes/api/generateRandomImages.php

Here's a Bash script that should make it easier to do all of this without much trouble. It's a good idea to put this in your PATH and/or make a handy shortcut to it somewhere that will make it trivial to update your images with new ones.

#!/bin/bash

Declare some paths (easier to configure)

PICPATH=/path/to/image/directory MW_INSTALL_PATH=/path/to/mediawiki

Get to the pic path, and remove old test images

cd $PICPATH rm *.jpg

Run the generate script three times to give us a bunch of images

php $MW_INSTALL_PATH/tests/phpunit/includes/api/generateRandomImages.php php $MW_INSTALL_PATH/tests/phpunit/includes/api/generateRandomImages.php php $MW_INSTALL_PATH/tests/phpunit/includes/api/generateRandomImages.php

Warning Warning: This list is not complete and more templates are required, otherwise you will end with SCRIPT error or other error messages not in English!

Upload Wizard will insert a few templates into generated file description pages, which need to exist on the wiki in order for the description pages to be rendered correctly. The templates used include:

This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page.
This extension is included in the following wiki farms/hosts and/or packages: Canasta Miraheze MyWikis WikiForge This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm.