Extension:上传向导
UploadWizard 发行状态: 稳定版 |
|
---|---|
实现 | 媒体, 特殊页面 |
描述 | 多文件分步上傳嚮導 |
作者 | Neil Kandalgaonkar, Jeroen De Dauw, Mark Holmquist, Ryan Kaldari, Ankur Anand, Yuvi Panda, Michael Dale, |
最新版本 | continuous updates |
MediaWiki | >= 1.43 |
数据库更改 | 是 |
表 | uw_campaigns |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下載 | README |
Campaign |
|
|
|
|
|
季度下載量 | 141 (Ranked 41st) |
前往translatewiki.net翻譯UploadWizard扩展 | |
Vagrant角色 | uploadwizard |
問題 | 开启的任务 · 报告错误 |
UploadWizard擴展允許用戶使用分步JavaScript嚮導上傳多個文件。
安裝
启用上传和缩略图
您的MediaWiki需要能夠託管媒體文件並創建縮略圖(媒體文件的較小預覽)。 如果您可以上傳圖像並在其文件頁面上查看較小的預覽,那麼您就已經準備好了。 如果沒有,有關完整說明,請參閱Manual:图片管理 ,尤其是圖像縮略圖。
- 對於GNU/Linux或Mac OS X用戶
- 確保
images
目錄可由您的Web服務器寫入。 - 安裝ImageMagick庫和二進製文件。
- 下載並提取此處指定的UploadWizard文件: Special:ExtensionDistributor/UploadWizard
- 將以下配置添加到LocalSettings.php中:
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = <path to your convert command>; # 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';
启用Flickr上传
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:
- Log in to Flickr;
- Go to the Apps By You page in the Flickr App Garden;
- Click on 'Get another key';
- Choose 'Apply for a non-commercial key';
- 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';
其他配置
- You need to have 即时共享资源 enabled in order to access the licensing tutorial. To enable InstantCommons add to LocalSettings.php.
$wgUseInstantCommons = true;
- You may want to set in LocalSettings.php, where
$wgUploadNavigationUrl = '/wiki/Special:UploadWizard';
/wiki/
is the correct path for your wiki. A more general way of doing this that works for whatever path configuration you have, but that requires PHP 5.3 or later is:
$wgExtensionFunctions[] = function() {
$GLOBALS['wgUploadNavigationUrl'] = SpecialPage::getTitleFor( 'UploadWizard' )->getLocalURL();
return true;
};
This modifies the sidebar's "上传文件" 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
];
在免許可證環境中的使用
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',
],
],
],
];
$wgUploadWizardConfig
array.
修改通用UI消息
If you wish to modify the generic messages, you can do so within the wiki itself editing the following pages:
- MediaWiki:Mwe-upwiz-source-ownwork
- MediaWiki:Mwe-upwiz-source-ownwork-assert-generic
- MediaWiki:Mwe-upwiz-source-ownwork-generic-explain
Modifying file pages created by Upload Wizard
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 ( Parser $parser, string &$text ) {
if ( preg_match( '/=={{int:filedesc}}==
{{Information
\|description=(.*)
\|date=(.*)
\|source=(.*)
\|author=(.*)
\|permission=(.*)
\|other versions=(.*)
}}
=={{int:license-header}}==
{{(.*)}}
*(.*)/', $text, $matches ) ) {
// Get data
$description = $matches[1];
$date = $matches[2];
$source = $matches[3];
$author = $matches[4];
$permission = $matches[5];
$otherVersions = $matches[6];
$license = $matches[7];
$licenseDetails = $matches[8];
// Process data
if ( $source === '{{own}}' ) {
$source = 'Own work';
}
if ( preg_match( '/\[\[([^|]+)\|[^]]+\]\]/', $author, $matches ) ) {
$author = $matches[1]; // Unlink the author
}
if ( $licenseDetails ) {
$license = $licenseDetails;
}
// Build wikitext
$text = "$description
{{File data
| date = $date
| author = $author
| source = $source
| license = $license
}}";
}
};
用法
URL参数
There are several URL arguments that can be specified to alter the behaviour of the UploadWizard:
- campaign - Specifies which upload campaign to use.
- caption - Sets the initial value for the caption field (structural data). Note that by default this will be copied to the description.
- captionlang - Sets the language of the first caption field.
- description - Sets the initial value for the description field. Note that setting the description will disable copying the caption to the description.
- descriptionlang - Sets the language of the first description field.
- lat - Sets the initial value for the latitude field.
- lon - Sets the initial value for the longitude field.
- alt - Sets the initial value for the altitude field.
- categories - Sets the initial value for the categories field, multiple categories separated by
|
. - fields[] - The initial values of additional fields defined by a campaign. Values of multiple fields must be passed in the exact same order as defined in the campaign.
- (e.g.
fields[]=value_first&fields[]=value_second
)
- objref - Specifies an object reference that can be used to update a page with a thumbnail of an uploaded image. See #Object references for further details.
- updateList - Specifies whether a list page should be updated at all. This parameter only works in combination with
objref
. See #Object references for further details.
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:
- id: If specified, this value is used instead of the first
fields[]
value. Please usefields[]
instead. - id2: If specified, this value is used instead of the second
fields[]
value. Please usefields[]
instead.
對象引用
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.
- objref - Specifies an object reference that can be used to update a page with a thumbnail of an uploaded image. Passing this parameter is expected in the following format
objref=prefix|page_title|object_id
- prefix - Interwiki or interlanguage prefix as defined per Special:Interwiki. The prefix must be defined in order to make this work.
- page_title - The title of the page the object is listed on.
- object_id - A unique identifier of the object for a bot to update
- updateList: Specifies whether a list page should be updated at all. Set to any value, this parameter enables a checkbox
测试
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
模板
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:
- the Template:Information (you could use mediawiki's export tool to import this template into your own installation of mediawiki)
- Description language identifiers like the "En" template, if none are defined, then only {{en}} is used.
- the Location template for geocoordinates
- Various licensing tags (which are configurable )
- (Optionally) a template to indicate that a file is uncategorized
參見
- How do I add custom license to Extension:UploadWizard?
- Above but for the messages only (Miraheze's Issue Tracker)
- 活動文檔
- 开发者文档
- Extension:UploadWizard/Error behavior
- Extension:EnhancedUpload – a new special page for multi-upload and improves drag-and-drop upload in VisualEditor
- 維基媒體操作說明
- Commons:Upload Wizard – the Upload Wizard info page in Wikimedia Commons
- Extension:MediaUploader – 從UploadWizard分叉的第三方用戶的靈活、多文件、分步上傳器
- Extension:MsUpload
- User:Drecodeam/GSoC 2012 Application - Ankur Anand's work on Flickr & geolocation integration
相关规格
- 自定義WikiText許可功能
- 位置 - 輸入GPS坐標/從EXIF導出它們
此扩展用于一个或多个维基媒体项目。 这可能意味着扩展足够稳定、运作足够良好,可以用在这样的高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中查找此扩展的名称以查看哪些网站安装了该扩展。 特定wiki上的已安装的扩展的完整列表位于Special:Version页面。 |
此扩展在以下wiki农场/托管网站和/或软件包中提供: 這不是一份權威名單。 即使某些wiki农场/托管网站和/或软件包未在这里列出,它们也可能提供此扩展。 请检查你的wiki农场/托管网站或软件包以确认提供情况。 |