Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/292284
Change subject: Mark UploadWizard uploads with a change tag (and Flickr uploads
separately)
......................................................................
Mark UploadWizard uploads with a change tag (and Flickr uploads separately)
Unfortunately, we can't just use the API action=upload&tags=...,
because that only allows user-defined tags and it would be terribly
inconvenient to have our users define them on every wiki.
This adds a semi-secret 'uploadwizardtags' parameter to action=upload
and uses it to tag all UploadWizard uploads with the tag 'uploadwizard'.
Flickr uploads are additionally tagged with 'uploadwizard-flickr'.
Bug: T121872
Bug: T121880
Change-Id: I9f91b00db2f9f76dc9fce076489ff5ff54177b37
---
M UploadWizard.php
M UploadWizardHooks.php
M i18n/en.json
M i18n/qqq.json
M resources/mw.FlickrChecker.js
M resources/mw.UploadWizardDetails.js
M resources/mw.UploadWizardUpload.js
7 files changed, 69 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/84/292284/1
diff --git a/UploadWizard.php b/UploadWizard.php
index b3d047a..4160a0d 100644
--- a/UploadWizard.php
+++ b/UploadWizard.php
@@ -89,6 +89,10 @@
$wgHooks['IsUploadAllowedFromUrl'][] =
'UploadWizardHooks::onIsUploadAllowedFromUrl';
$wgHooks['ResourceLoaderTestModules'][] =
'UploadWizardHooks::onResourceLoaderTestModules';
$wgHooks['UnitTestsList'][] = 'UploadWizardHooks::onUnitTestsList';
+$wgHooks['APIGetAllowedParams'][] = 'UploadWizardHooks::onAPIGetAllowedParams';
+$wgHooks['RecentChange_save'][] = 'UploadWizardHooks::onRecentChangeSave';
+$wgHooks['ListDefinedTags'][] = 'UploadWizardHooks::onListDefinedTags';
+$wgHooks['ChangeTagsListActive'][] =
'UploadWizardHooks::onChangeTagsListActive';
$uploadWizardModuleInfo = [
'localBasePath' => __DIR__ . '/resources',
diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index d4f6382..653008e 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -1,6 +1,8 @@
<?php
class UploadWizardHooks {
+ const VALID_TAGS = [ 'uploadwizard', 'uploadwizard-flickr' ];
+
/**
* Schema update to set up the needed database tables.
*
@@ -216,4 +218,50 @@
return wfMessage( $licenseConfig[$licenseName]['msg']
)->text();
}
}
+
+ public static function onAPIGetAllowedParams( &$module, &$params,
$flags ) {
+ if ( $module instanceof ApiUpload ) {
+ $params['uploadwizardtags'] = [
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_HELP_MSG =>
'mwe-upwiz-apihelp-param-uploadwizardtags',
+ ];
+ }
+ return true;
+ }
+
+ public static function onRecentChangeSave( RecentChange $recentChange )
{
+ if ( !(
+ $recentChange->getAttribute( 'rc_log_type' ) ===
'upload' &&
+ $recentChange->getAttribute( 'rc_log_action' ) ===
'upload'
+ ) ) {
+ return true;
+ }
+
+ $request = RequestContext::getMain()->getRequest();
+ $paramTags = explode( '|', $request->getVal(
'uploadwizardtags', '' ) );
+ $validTags = self::VALID_TAGS;
+ $tags = array_values( array_intersect( $paramTags, $validTags )
);
+
+ if ( $tags ) {
+ ChangeTags::addTags(
+ $tags,
+ $recentChange->getAttribute( 'rc_id' ),
+ $recentChange->getAttribute( 'rc_this_oldid' ),
+ $recentChange->getAttribute( 'rc_logid' )
+ );
+ }
+
+ return true;
+ }
+
+ public static function onListDefinedTags( &$tags ) {
+ $tags = array_merge( $tags, self::VALID_TAGS );
+ return true;
+ }
+
+ public static function onChangeTagsListActive( &$tags ) {
+ $tags = array_merge( $tags, self::VALID_TAGS );
+ return true;
+ }
}
diff --git a/i18n/en.json b/i18n/en.json
index 31da3c1..d5f96b6 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -319,6 +319,8 @@
"mwe-upwiz-custom-date": "Use custom date format",
"uploadcampaign-legend": "Upload campaign configuration",
"uploadcampaign-text": "You are modifying an Upload Wizard campaign.",
+ "tag-uploadwizard": "{{int:uploadwizard}}",
+ "tag-uploadwizard-flickr": "{{int:uploadwizard}}: Flickr",
"prefs-uploads": "Uploading",
"prefs-upwiz-licensing": "Licensing",
"prefs-upwiz-experimental": "Experimental features",
@@ -335,6 +337,7 @@
"campaigns": "Upload Wizard campaigns",
"mwe-upload-campaigns-pagination-next": "Next page",
"mwe-upload-campaigns-list-title": "List of upload campaigns",
+ "mwe-upwiz-apihelp-param-uploadwizardtags": "Additional
UploadWizard-related change tags to apply. Internal, do not use.",
"apihelp-flickrblacklist-description": "Validate a Flickr URL by using
the user ID (NSID) for blacklisting.\n\nWhen used with the list option, returns
all blacklisted IDs.",
"apihelp-flickrblacklist-param-url": "The Flickr URL to be tested.",
"apihelp-flickrblacklist-param-list": "When set, the complete blacklist
is returned. Cannot be used together with $1url.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index a0c09b3..b4257c8 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -343,6 +343,8 @@
"mwe-upwiz-custom-date": "Shown as a tooltip of a button next to a date
input field, to enable inputting arbitrary text rather than only choosing dates
from a calendar. (For example, if the date you want to input is 'circa 1900'.)",
"uploadcampaign-legend": "Diambiguation: this message is about the
configuration of an upload campaign.",
"uploadcampaign-text": "Text shown on the edit page for an upload
campaign.",
+ "tag-uploadwizard": "Tag on uploads performed using UploadWizard.",
+ "tag-uploadwizard-flickr": "Tag on uploads from Flickr performed using
UploadWizard.",
"prefs-uploads": "Preferences tab label for UploadWizard preferences
related to uploads.\n\nNote that this is about '''the process of uploading
files''', and not files that were uploaded.\n\nSee
https://commons.wikimedia.org/w/index.php?uselang=en&title=Special:Preferences#mw-prefsection-uploads.\n{{Identical|Uploading}}",
"prefs-upwiz-licensing": "{{Identical|Licensing}}",
"prefs-upwiz-experimental": "Used in [[Special:Preferences]].",
@@ -359,6 +361,7 @@
"campaigns": "{{doc-special|Campaigns}}\nThe UploadWizard campaign page
provides a list of Upload Wizard campaigns.\nFor more information, see
[[:mw:Extension:UploadWizard/Campaigns]].",
"mwe-upload-campaigns-pagination-next": "Link to next page of upload
campaigns.\n{{Identical|Next page}}",
"mwe-upload-campaigns-list-title": "Title of page that has list of
upload campaigns",
+ "mwe-upwiz-apihelp-param-uploadwizardtags":
"{{doc-apihelp-param|upload|uploadwizardtags}}",
"apihelp-flickrblacklist-description":
"{{doc-apihelp-description|flickrblacklist}}",
"apihelp-flickrblacklist-param-url":
"{{doc-apihelp-param|flickrblacklist|url}}",
"apihelp-flickrblacklist-param-list":
"{{doc-apihelp-param|flickrblacklist|list}}",
diff --git a/resources/mw.FlickrChecker.js b/resources/mw.FlickrChecker.js
index ce5c5fb..2d94b92 100644
--- a/resources/mw.FlickrChecker.js
+++ b/resources/mw.FlickrChecker.js
@@ -409,6 +409,7 @@
url: '',
type: 'JPEG',
fromURL: true,
+ fromFlickr: true,
licenseValue: licenseValue,
licenseMessage:
license.licenseMessage,
license: license.licenseName
!== 'Public Domain Mark',
@@ -539,6 +540,7 @@
url: '',
type: 'JPEG',
fromURL: true,
+ fromFlickr: true,
licenseValue: license.licenseValue,
licenseMessage: license.licenseMessage,
license: license.licenseName !==
'Public Domain Mark',
diff --git a/resources/mw.UploadWizardDetails.js
b/resources/mw.UploadWizardDetails.js
index 143c468..8c4d6ac 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -727,7 +727,12 @@
*/
submit: function () {
var params, wikiText, apiPromise,
+ tags = [ 'uploadwizard' ],
details = this;
+
+ if ( this.upload.fromFlickr ) {
+ tags.push( 'uploadwizard-flickr' );
+ }
$( 'form', this.containerDiv ).submit();
@@ -740,6 +745,7 @@
params = {
action: 'upload',
+ uploadwizardtags: tags,
filekey: this.upload.fileKey,
filename: this.getTitle().getMain(),
comment: 'User created page with ' +
mw.UploadWizard.userAgent
diff --git a/resources/mw.UploadWizardUpload.js
b/resources/mw.UploadWizardUpload.js
index 892c63f..5db87ae 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -84,6 +84,9 @@
if ( providedFile.fromURL ) {
this.fromURL = true;
}
+ if ( providedFile.fromFlickr ) {
+ this.fromFlickr = true;
+ }
this.ui.fill( providedFile );
};
--
To view, visit https://gerrit.wikimedia.org/r/292284
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f91b00db2f9f76dc9fce076489ff5ff54177b37
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits