Last modified: 2014-02-12 23:38:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T46682, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 44682 - Add Custom license in the pre-defined license list
Add Custom license in the pre-defined license list
Status: REOPENED
Product: MediaWiki extensions
Classification: Unclassified
UploadWizard (Other open bugs)
REL1_20-branch
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-05 16:02 UTC by Kelson [Emmanuel Engelhart]
Modified: 2014-02-12 23:38 UTC (History)
8 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Kelson [Emmanuel Engelhart] 2013-02-05 16:02:30 UTC
I wanted to allow users to upload copyrighted content on a private wiki. Unfortunately there is no license for "copyrighted" content, so I tried to create my own entry in the available license list. This seems to be not feasible.

The first problem is that you can not really edit the default configuration of the WikiEditor. You can only create your own configuration hash table which will be merged with the default configuration hash (PHP array_merge function). If this approache works for scalar hash values, this does not work at all for complex ones (and the configuration hash has plenty of them). I think there, that the default configuration should be global and already declared as $wgUploadWizardConfig. It would be easy afterward to customise it.

The second problem seems to be with the string translation. You can't create easily your own license description (in the "licenses" hash) without having to declare somewhere translated strings.

One solution for my own use case would be to patch the default WikiEditor configuration file and add an entry for the copyrighted content... But, I guess there are other people who want to introduce their own custom license.
Comment 1 Kelson [Emmanuel Engelhart] 2013-02-05 16:04:00 UTC
Sorry, this bug report is about the UploadWizard, not about WikiEditor.
Comment 2 Nischay Nahata 2013-02-18 19:10:18 UTC
You can add new licenses by accessing the global config variable as follows

$wgUploadWizardConfig[ 'licenses' ]['your-own-license-name'] => array(
			'msg' => 'xyz',
			'icons' => array(),
			'url' => '//example.org/'
		);


The only problem I see is adding a msg, it should be a feature to add a translation in LocalSettings.php but I don't think that is possible right now (should ask the in #mediawiki-i18n). However a workaround is to create a simple extension and add those messages using that.

Closing this as fixed.
Comment 3 Nemo 2013-02-18 19:30:32 UTC
> The only problem I see is adding a msg, it should be a feature to add a
> translation in LocalSettings.php but I don't think that is possible right now
> (should ask the in #mediawiki-i18n). However a workaround is to create a
> simple
> extension and add those messages using that.

For proper copyright tags, Wikimedia projects use WikimediaMessages extension. https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/WikimediaMessages.git;a=blob;f=WikimediaCCLicenseTexts.i18n.php

If it's just a single (fake?) license, can't one just set $wgUploadWizardConfig and hen add a custom system message on wiki? That would be weird and should be filed as a bug.
Comment 4 Kelson [Emmanuel Engelhart] 2013-02-19 11:41:48 UTC
@Nischay Nahata

I have added your code to my LocalSetting.php
$wgUploadWizardConfig[ 'licenses' ]['your-own-license-name'] => array(
            'msg' => 'xyz',
            'icons' => array(),
            'url' => '//example.org/'
        );

Unfortunately, this breaks Mediawiki:
PHP message: PHP Parse error:  syntax error, unexpected T_DOUBLE_ARROW

So, I reopen the ticket.
Comment 5 Alex Monk 2013-02-19 14:15:37 UTC
Just get rid of the arrow and use an equals sign:

$wgUploadWizardConfig[ 'licenses' ]['your-own-license-name'] = array(
    'msg' => 'xyz',
    'icons' => array(),
    'url' => '//example.org/'
);
Comment 6 Kelson [Emmanuel Engelhart] 2013-02-19 14:52:21 UTC
This does not work either (at least for me). I'm stuck in the "upload" stage and nothing happens if I click on the "continue" button. In addition I do not see how $wgUploadWizardConfig could alone fix the problem as the available licenses seem to be configured in 'licensesThirdParty' and 'licensesOwnWork'.

So, I reopen the ticket.
Comment 7 Nischay Nahata 2013-02-19 19:02:16 UTC
Actually the $wgUploadWizardConfig is not like other config vars where we can just add new values... because its using array_merge() afterwards.

So we need to use

$wgUploadWizardConfig = array( 
	'licenses' = array( 
		'custom' => array(
				'msg' => 'mwe-upwiz-license-cc-by-sa-3.0',
				'icons' => array( 'cc-by', 'cc-sa' ),
				'url' => '//creativecommons.org/licenses/by-sa/3.0/'
		)
	)
);


But this again won't work because we aren't using array_merge_recursive()..
I will try a fix in some time.

However, even then this won't show on UW as it needs to be grouped in either own work or third party :(
Comment 8 Nischay Nahata 2013-02-19 19:47:36 UTC
Sorry the above code is erroneous, you can use

$wgUploadWizardConfig = array( 
    'licenses' => array( 
        'custom' => array(
                'msg' => 'mwe-upwiz-license-cc-by-sa-3.0',
                'icons' => array( 'cc-by', 'cc-sa' ),
                'url' => '//creativecommons.org/licenses/by-sa/3.0/'
        )
    ),
	'licensesOwnWork' => array(
		'type' => 'or',
		'filterTemplate' => 'self',
		'licenses' => array(
			'custom'
		),
	),
);

in LocalSettings.php

after applying https://gerrit.wikimedia.org/r/#/c/49849/

This shows me the license under own work, similarly you can do for third party licenses.
Comment 9 Alex Monk 2013-02-27 01:06:13 UTC
Fixes it for me, merged.
Comment 10 Kelson [Emmanuel Engelhart] 2013-02-27 15:15:53 UTC
It seems to me that the recursive array merge for the config is a good start, but this does not fix the whole problem:
* You still can't specify your license message
* You still can't use it as the default license
* Unable to easily use the configured template

Recursive array merge does not make sense for all values. For example, the 'licensesOwnWork' keys 'defaults' and 'licenses' should not be merged but overwritten. I still thing the best way is not to merge two config arrays, but to make the default config array directly modifiable.

The other problem, is that it seems impossible to have your own license message ('msg') also if you have specified it in the "Mediawiki" namespace. I guess that UW does not care if the msg key ('mwe-upwiz-license-copyrighted' in my case) is not translated somewhere else in the extension. This should be able to bypass that. I also think this should be possible to somehow harcode the message in the configuration itself by using a new value like for example "msghard".

The config. specified "template" is not directly used but the description page is based on a complex system relying on other templates like "self". This templates are not installed per default, so I see only two solutions: the templates is created by UW or we find a solution to use directly the template specified in the configuration.
Comment 11 Nischay Nahata 2013-02-27 19:15:56 UTC
Well this will be a lot of work, unfortunately UploadWizard isn't made so generic that it can be used outside of WMF wikis.
Comment 12 Nemo 2013-03-11 07:35:47 UTC
(In reply to comment #9)
> Fixes it for me, merged.

Revert committed, Gerrit change #53137
Comment 13 Erik Moeller 2013-03-11 07:40:54 UTC
Unfortunately this attempted fix messed up the Commons local configuration by incorrectly merging the config array with the default settings.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links