jenkins-bot has submitted this change and it was merged.
Change subject: Allow custom wikitext license in preferences
......................................................................
Allow custom wikitext license in preferences
Bug: T42647
Change-Id: I30d8a1324a061a6eebdf017da80898fb9e95fbbb
---
M UploadWizardHooks.php
M i18n/en.json
M i18n/qqq.json
M includes/specials/SpecialUploadWizard.php
M resources/mw.UploadWizardLicenseInput.js
5 files changed, 39 insertions(+), 6 deletions(-)
Approvals:
MarkTraceur: Looks good to me, approved
jenkins-bot: Verified
diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index aa8792c..1514084 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -824,11 +824,15 @@
$licenses[$licenseKey] = 'ownwork-' . $license;
}
- foreach ( UploadWizardConfig::getThirdPartyLicenses()
as $license ) {
+ $thirdParty =
UploadWizardConfig::getThirdPartyLicenses();
+ $hasCustom = false;
+ foreach ( $thirdParty as $license ) {
if ( $license !== 'custom' ) {
$licenseMessage =
self::getLicenseMessage( $license, $licenseConfig );
$licenseKey = wfMessage(
'mwe-upwiz-prefs-license-thirdparty', $licenseMessage )->text();
$licenses[$licenseKey] = 'thirdparty-'
. $license;
+ } else {
+ $hasCustom = true;
}
}
@@ -839,6 +843,14 @@
$licenses
);
+ if ( $hasCustom ) {
+ // The "custom license" option must be last,
otherwise the text referring to "following
+ // wikitext" and "last option above" makes no
sense.
+ $licenseMessage = self::getLicenseMessage(
'custom', $licenseConfig );
+ $licenseKey = wfMessage(
'mwe-upwiz-prefs-license-thirdparty', $licenseMessage )->text();
+ $licenses[$licenseKey] = 'thirdparty-custom';
+ };
+
$preferences['upwiz_deflicense'] = array(
'type' => 'radio',
'label-message' =>
'mwe-upwiz-prefs-def-license',
@@ -846,6 +858,15 @@
'options' => $licenses
);
+ if ( $hasCustom ) {
+ $preferences['upwiz_deflicense_custom'] = array(
+ 'type' => 'text',
+ 'label-message' =>
'mwe-upwiz-prefs-def-license-custom',
+ 'help-message' =>
'mwe-upwiz-prefs-def-license-custom-help',
+ 'section' => 'uploads/upwiz-licensing',
+ );
+ }
+
if ( UploadWizardConfig::getSetting( 'enableChunked' )
=== 'opt-in' ) {
$preferences['upwiz-chunked'] = array(
'type' => 'check',
diff --git a/i18n/en.json b/i18n/en.json
index 23b5d39..c44f6f4 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -322,6 +322,8 @@
"prefs-upwiz-interface": "User interface",
"mwe-upwiz-prefs-def-license": "Default license",
"mwe-upwiz-prefs-def-license-def": "Use whatever the default is",
+ "mwe-upwiz-prefs-def-license-custom": "Custom default license",
+ "mwe-upwiz-prefs-def-license-custom-help": "This field is only used if
you choose the last option above.",
"mwe-upwiz-prefs-license-own": "Own work - $1",
"mwe-upwiz-prefs-license-thirdparty": "Someone else's work - $1",
"mwe-upwiz-prefs-chunked": "Chunked uploads for files over $1 in Upload
Wizard - Increases maximum file upload size from $2 to $3",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 4d3609d..4d0689b 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -344,8 +344,10 @@
"prefs-upwiz-licensing": "{{Identical|Licensing}}",
"prefs-upwiz-experimental": "Used in [[Special:Preferences]].",
"prefs-upwiz-interface": "Preferences section heading for preferences
related to the Upload Wizard user interface",
- "mwe-upwiz-prefs-def-license": "Form input label",
+ "mwe-upwiz-prefs-def-license": "Label of preference used to choose
which license which is selected by default when uploading files.",
"mwe-upwiz-prefs-def-license-def": "Radio button option",
+ "mwe-upwiz-prefs-def-license-custom": "Label of preference used to
input wikitext for custom license, if selected.",
+ "mwe-upwiz-prefs-def-license-custom-help": "Additional label of
preference used to input wikitext for custom license, if selected. The text of
'last option above' is {{msg-mw|mwe-upwiz-license-custom}}",
"mwe-upwiz-prefs-license-own": "Parameters:\n* $1 - license message.
e.g. {{msg-mw|Mwe-upwiz-license-cc-by-sa-3.0}}\nSee also:\n*
{{msg-mw|Mwe-upwiz-prefs-license-thirdparty}}",
"mwe-upwiz-prefs-license-thirdparty": "Parameters:\n* $1 - license
message. e.g. {{msg-mw|Mwe-upwiz-license-cc-by-sa-3.0}}\nSee also:\n*
{{msg-mw|Mwe-upwiz-prefs-license-own}}",
"mwe-upwiz-prefs-chunked": "Preference that enables chunked uploading.
Parameters:\n* $1 - size of each chunk, as configured on this wiki\n* $2 -
maximum upload size without preference\n* $3 - maximum upload size with
preference enabled",
diff --git a/includes/specials/SpecialUploadWizard.php
b/includes/specials/SpecialUploadWizard.php
index 8734e9e..a9d480c 100644
--- a/includes/specials/SpecialUploadWizard.php
+++ b/includes/specials/SpecialUploadWizard.php
@@ -233,6 +233,11 @@
}
$config['licensing'][$userLicenseGroup]['defaults'] = array(
$userDefaultLicense );
$config['licensing']['defaultType'] =
$userLicenseType;
+
+ if ( $userDefaultLicense === 'custom' ) {
+
$config['licenses']['custom']['defaultText'] =
+ $this->getUser()->getOption(
'upwiz_deflicense_custom' );
+ }
}
}
diff --git a/resources/mw.UploadWizardLicenseInput.js
b/resources/mw.UploadWizardLicenseInput.js
index 6b4eec5..834512b 100644
--- a/resources/mw.UploadWizardLicenseInput.js
+++ b/resources/mw.UploadWizardLicenseInput.js
@@ -189,7 +189,7 @@
}
$.each( config.licenses, function ( i, licenseName ) {
- var $customDiv, license, templates, $input,
$label;
+ var $customDiv, license, templates, $input,
$label, customDefault;
if ( mw.UploadWizard.config.licenses[
licenseName ] !== undefined ) {
license = {
@@ -213,7 +213,8 @@
$input.data( 'groupToggler',
$groupToggler );
if ( config.special === 'custom' ) {
- $customDiv =
input.createCustomWikiTextInterface( $input );
+ customDefault =
mw.UploadWizard.config.licenses[ licenseName ].defaultText;
+ $customDiv =
input.createCustomWikiTextInterface( $input, customDefault );
$el.append( $customDiv );
$input.data( 'textarea',
$customDiv.find( 'textarea' ) );
}
@@ -316,15 +317,17 @@
* When text entered here, auto-selects the input.
*
* @param {jQuery} $input Wrapped input
- * @return {jQuery} wrapped textarea
+ * @param {string} [customDefault] Default custom license text
+ * @return {jQuery} Wrapped textarea
*/
- createCustomWikiTextInterface: function ( $input ) {
+ createCustomWikiTextInterface: function ( $input, customDefault
) {
var keydownTimeout,
input = this,
nameId = $input.attr( 'id' ) + '_custom',
textarea, button;
textarea = new OO.ui.TextInputWidget( {
+ value: customDefault,
name: nameId,
multiline: true,
autosize: true
--
To view, visit https://gerrit.wikimedia.org/r/262329
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I30d8a1324a061a6eebdf017da80898fb9e95fbbb
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits