r96988 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96987‎ | r96988 | r96989 >
Date:18:54, 13 September 2011
Author:jeroendedauw
Status:reverted (Comments)
Tags:
Comment:
fixed bug 29249; also fixed issues caused by using the license name where it's template or it's message should have been used
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.config.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.i18n.php (modified) (history)
  • /trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php (modified) (history)
  • /trunk/extensions/UploadWizard/includes/specials/SpecialUploadCampaign.php (modified) (history)
  • /trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.config.php
@@ -68,6 +68,13 @@
6969 // The maximum length of the id field.
7070 'idFieldMaxLength' => 25,
7171
 72+ // Wikitext for a custom own-work license.
 73+ // Leave empty for no such license.
 74+ 'wikitextLicense' => '',
 75+
 76+ // Templates to add when choosing the custom in wikitext defined license.
 77+ 'wikitextLicenseTemplates' => array(),
 78+
7279 // 'licenses' is a list of licenses you could possibly use elsewhere, for instance in
7380 // licensesOwnWork or licensesThirdParty.
7481 // It just describes what licenses go with what wikitext, and how to display them in
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadCampaign.php
@@ -94,7 +94,12 @@
9595
9696 // show _ALL_ the licenses!
9797 $standardConfig = UploadWizardConfig::getConfig();
98 - foreach ( $standardConfig['licenses'] as $key => $license ) {
 98+ $licences = array_merge(
 99+ $standardConfig['licenses'],
 100+ array( 'wikitextLicense' => array( 'msg' => 'mwe-upwiz-campaign-customLicense' ) )
 101+ );
 102+
 103+ foreach ( $licences as $key => $license ) {
99104 $configFields['licensesOwnWork']['options'][ wfMsg( $license['msg'] ) ] = $key;
100105 $configFields['defaultOwnWorkLicence']['options'][ wfMsg( $license['msg'] ) ] = $key;
101106 }
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
@@ -168,6 +168,15 @@
169169
170170 $config['thanksLabel'] = $this->getPageContent( $config['thanksLabelPage'], true );
171171
 172+ if ( in_array( 'wikitextLicense', $config['licensesOwnWork']['licenses'] ) ) {
 173+ $config['wikitextLicense'] = str_replace( '$1', $this->getLang()->getCode(), $config['wikitextLicense'] );
 174+
 175+ $config['licenses']['wikitextLicense'] = array(
 176+ 'html' => $this->getOutput()->parse( $config['wikitextLicense'], false ),
 177+ 'templates' => $config['wikitextLicenseTemplates'],
 178+ );
 179+ }
 180+
172181 $this->getOutput()->addScript(
173182 Skin::makeVariablesScript(
174183 array(
Index: trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php
@@ -198,6 +198,12 @@
199199 'options' => array(),
200200 'default' => $globalConfig['licensesOwnWork']['defaults'][0]
201201 ),
 202+ 'wikitextLicense' => array(
 203+ 'type' => 'text'
 204+ ),
 205+ 'wikitextLicenseTemplates' => array(
 206+ 'type' => 'text'
 207+ ),
202208 'defaultCategories' => array(
203209 'type' => 'text'
204210 ),
@@ -213,13 +219,6 @@
214220 ),
215221 );
216222
217 - foreach ( $globalConfig['licensesOwnWork']['licenses'] as $license ) {
218 - $licenceMsg = wfMsg( $globalConfig['licenses'][$license]['msg'] );
219 - $config['licensesOwnWork']['options'][$licenceMsg] = $license;
220 - }
221 -
222 - $config['defaultOwnWorkLicence']['options'] = $config['licensesOwnWork']['options'];
223 -
224223 return $config;
225224 }
226225
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -322,6 +322,7 @@
323323 'uploadcampaign-text' => 'You are modifying an Upload Wizard campaign.',
324324 'mwe-upwiz-campaign-name' => 'Campaign name:',
325325 'mwe-upwiz-campaign-enabled' => 'Campaign enabled',
 326+ 'mwe-upwiz-campaign-customLicense' => 'Custom license',
326327 'mwe-upwiz-campaign-conf-skipTutorial' => 'Skip the licensing tutorial',
327328 'mwe-upwiz-campaign-conf-autoCategories' => 'Categories to add the files to automatically and silently (pipe separated):',
328329 'mwe-upwiz-campaign-conf-defaultCategories' => 'Default categories to list in the describe tab (pipe separated):',
@@ -341,6 +342,8 @@
342343 'mwe-upwiz-campaign-conf-headerLabelPage' => 'Page containing text to display above the UploadWizard interface. $1 is replaced with the language code:',
343344 'mwe-upwiz-campaign-conf-thanksLabelPage' => 'Page containing text to display on top of the "Use" page. $1 is replaced with the language code:',
344345 'mwe-upwiz-campaign-conf-idFieldMaxLength' => 'Maximum length of the text in the ID field',
 346+ 'mwe-upwiz-campaign-conf-wikitextLicense' => 'Wikitext for a custom own-work license. Empty for no such custom license. $1 is replaced with the language code:',
 347+ 'mwe-upwiz-campaign-conf-wikitextLicenseTemplates' => 'Templates to add when the user chooses the custom license (pipe separated):',
345348
346349 // Coolcats
347350 'mw-coolcats-confirm-new-title' => 'Confirm new category',
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js
@@ -55,16 +55,14 @@
5656 .attr( { name: "author" } )
5757 .addClass( 'mwe-upwiz-sign' );
5858
59 - var ownWork = mw.UploadWizard.config.licensesOwnWork;
60 - var licenseIsNotDefault = ( ownWork.licenses.length === 1 && ownWork.licenses[0] !== ownWork.defaults[0] );
61 - _this.showCustomDiv = ownWork.licenses.length > 1 || licenseIsNotDefault;
 59+ _this.showCustomDiv = mw.UploadWizard.config.licensesOwnWork.licenses.length > 1;
6260
6361 if ( _this.showCustomDiv ) {
6462 var licenseInputDiv = $j( '<div class="mwe-upwiz-deed-license"></div>' );
6563
6664 _this.licenseInput = new mw.UploadWizardLicenseInput(
6765 licenseInputDiv,
68 - undefined,
 66+ undefined,
6967 mw.UploadWizard.config.licensesOwnWork,
7068 _this.uploadCount
7169 );
@@ -91,8 +89,9 @@
9290 return this.licenseInput.getWikiText();
9391 }
9492 else {
 93+ var defLicensename = mw.UploadWizard.config.licensesOwnWork.defaults[0];
9594 return '{{' + mw.UploadWizard.config.licensesOwnWork.filterTemplate
96 - + '|' + mw.UploadWizard.config.licensesOwnWork.defaults[0] + '}}';
 95+ + '|' + mw.UploadWizard.config.licenses[defLicensename]['templates'].join( '' ) + '}}';
9796 }
9897 },
9998
@@ -119,15 +118,29 @@
120119 _this.$form = $j( '<form />' );
121120
122121 _this.$authorInput2 = $j( '<input type="text" />' ).attr( { name: "author2" } ).addClass( 'mwe-upwiz-sign' );
 122+
 123+ var $assertNote = $j( '<p class="mwe-small-print"></p>' );
 124+
 125+ var defLicense = mw.UploadWizard.config.licensesOwnWork.defaults[0];
 126+ defLicense = mw.UploadWizard.config.licenses[defLicense];
 127+
 128+ if ( mw.isDefined( defLicense.html ) ) {
 129+ $assertNote.text( gM( 'mwe-upwiz-source-ownwork-assert-note', '' ) )
 130+ .append( defLicense.html )
 131+ }
 132+ else {
 133+ $assertNote.msg(
 134+ 'mwe-upwiz-source-ownwork-assert-note',
 135+ gM( defLicense.msg )
 136+ )
 137+ }
 138+
123139 var $standardDiv = $j( '<div />' ).append(
124140 $j( '<label for="author2" generated="true" class="mwe-validator-error" style="display:block;" />' ),
125141 $j( '<p></p>' ).msg( 'mwe-upwiz-source-ownwork-assert',
126142 uploadCount,
127143 _this.$authorInput2 ),
128 - $j( '<p class="mwe-small-print"></p>' ).msg(
129 - 'mwe-upwiz-source-ownwork-assert-note',
130 - gM( 'mwe-upwiz-license-' + mw.UploadWizard.config.licensesOwnWork.defaults[0] )
131 - )
 144+ $assertNote
132145 );
133146
134147 var $crossfader = $j( '<div />' ).append( $standardDiv );
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js
@@ -83,16 +83,28 @@
8484 $input.data( 'licenseName', name );
8585 _this.inputs.push( $input );
8686
87 - var messageKey = mw.isDefined( license.props['msg'] ) ? license.props.msg : '[missing msg for ' + license.name + ']';
8887 var $icons = $j( '<span></span>' );
8988 if ( mw.isDefined( license.props['icons'] ) ) {
9089 $j.each( license.props.icons, function( i, icon ) {
9190 $icons.append( $j( '<span></span>' ).addClass( 'mwe-upwiz-license-icon mwe-upwiz-' + icon + '-icon' ) );
9291 } );
9392 }
 93+
 94+ var $label = $j( '<label />' ).attr( { 'for': id } ).append( $icons );
 95+
 96+ if ( mw.isDefined( license.props['html'] ) ) {
 97+ $label.html( license.props['html'] );
 98+ }
 99+ else if ( mw.isDefined( license.props['msg'] ) ) {
 100+ $label.msg( license.props['msg'], _this.count );
 101+ }
 102+ else {
 103+ $label.text( '[missing msg for ' + license.name + ']' );
 104+ }
 105+
94106 $el.append(
95107 $input,
96 - $j( '<label />' ).attr( { 'for': id } ).msg( messageKey, _this.count ).append( $icons ),
 108+ $label,
97109 $j( '<br/>' )
98110 // XXX help?
99111 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r97369reverted r96988neilk04:56, 17 September 2011

Comments

#Comment by NeilK (talk | contribs)   04:57, 17 September 2011

Unfortunately this is not what we wanted. It's my fault for not giving Jeroen a better spec.

A better spec has been created, so I'm reverting this in r97639. If there are other parts which are useful then you'll have to reintroduce them later.

#Comment by MZMcBride (talk | contribs)   00:18, 1 October 2012

You meant r97369, not r97639, of course.

Status & tagging log