r105436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105435‎ | r105436 | r105437 >
Date:16:39, 7 December 2011
Author:jeroendedauw
Status:ok
Tags:
Comment:
bug 24702: added new config option that allows choosing the default license type rather then limiting selection to one and also changed the 3 user preferences into one as per Neils suggestion
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.config.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.i18n.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardHooks.php (modified) (history)
  • /trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.config.php
@@ -43,6 +43,10 @@
4444 // When not provided, the message mwe-upwiz-thanks-intro will be used.
4545 'thanksLabelPage' => '',
4646
 47+ // Default license type.
 48+ // Possible values: choice, ownwork, thirdparty
 49+ 'defaultLicenseType' => 'choice',
 50+
4751 // Should the own work option be shown, and if not, what option should be set?
4852 // Possible values: choice, own, notown
4953 'ownWorkOption' => 'choice',
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php
@@ -505,48 +505,26 @@
506506 if ( UploadWizardConfig::getSetting( 'enableLicensePreference' ) ) {
507507 $licenseConfig = UploadWizardConfig::getSetting( 'licenses' );
508508
509 - $defOption = array( wfMsg( 'mwe-upwiz-prefs-def-license-def' ) => 'default' );
510 -
511 - $preferences['upwiz_deflicensetype'] = array(
512 - 'type' => 'radio',
513 - 'label-message' => 'mwe-upwiz-prefs-def-licensetype',
514 - 'section' => 'uploads',
515 - 'options' => $defOption + array(
516 - wfMsg( 'mwe-upwiz-prefs-def-license-ownwork' ) => 'ownwork',
517 - wfMsg( 'mwe-upwiz-prefs-def-license-3rdparty' ) => 'thirdparty',
518 - )
519 - );
520 -
521 - $ownWork = UploadWizardConfig::getSetting( 'licensesOwnWork' );
522 -
523509 $licenses = array();
524 -
 510+
 511+ $ownWork = UploadWizardConfig::getSetting( 'licensesOwnWork' );
525512 foreach ( $ownWork['licenses'] as $license ) {
526 - $licenses[wfMsg( $licenseConfig[$license]['msg'] )] = $license;
 513+ $licenseMessage = self::getLicenseMessage( $license, $licenseConfig );
 514+ $licenses[wfMsgExt( 'mwe-upwiz-prefs-license-own', 'parsemag', $licenseMessage )] = 'ownwork-' . $license;
527515 }
528516
529 - $licenses = array_merge( $defOption, $licenses );
530 -
531 - $preferences['upwiz_deflicense'] = array(
532 - 'type' => 'radio',
533 - 'label-message' => 'mwe-upwiz-prefs-def-license',
534 - 'section' => 'uploads',
535 - 'options' => $licenses
536 - );
537 -
538 - $thirdParty = UploadWizardConfig::getSetting( 'licensesThirdParty' );
539 -
540 - $licenses = array();
541 -
542517 foreach ( UploadWizardConfig::getThirdPartyLicenses() as $license ) {
543 - $licenses[wfMsg( $licenseConfig[$license]['msg'] )] = $license;
 518+ if ( $license !== 'custom' ) {
 519+ $licenseMessage = self::getLicenseMessage( $license, $licenseConfig );
 520+ $licenses[wfMsgExt( 'mwe-upwiz-prefs-license-thirdparty', 'parsemag', $licenseMessage )] = 'thirdparty-' . $license;
 521+ }
544522 }
545523
546 - $licenses = array_merge( $defOption, $licenses );
 524+ $licenses = array_merge( array( wfMsg( 'mwe-upwiz-prefs-def-license-def' ) => 'default' ), $licenses );
547525
548 - $preferences['upwiz_def3rdparty'] = array(
 526+ $preferences['upwiz_deflicense'] = array(
549527 'type' => 'radio',
550 - 'label-message' => 'mwe-upwiz-prefs-def-3rdparty',
 528+ 'label-message' => 'mwe-upwiz-prefs-def-license',
551529 'section' => 'uploads',
552530 'options' => $licenses
553531 );
@@ -554,5 +532,24 @@
555533
556534 return true;
557535 }
 536+
 537+ /**
 538+ * Helper function to get the message for a license.
 539+ *
 540+ * @since 1.2
 541+ *
 542+ * @param string $licenseName
 543+ * @param array $licenseConfig
 544+ *
 545+ * @return string
 546+ */
 547+ protected static function getLicenseMessage( $licenseName, array &$licenseConfig ) {
 548+ if ( array_key_exists( 'url', $licenseConfig[$licenseName] ) ) {
 549+ return wfMsgExt( $licenseConfig[$licenseName]['msg'], 'parseinline', '', $licenseConfig[$licenseName]['url'] );
 550+ }
 551+ else {
 552+ return wfMsg( $licenseConfig[$licenseName]['msg'] );
 553+ }
 554+ }
558555
559556 }
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
@@ -144,22 +144,20 @@
145145
146146 $defaultLicense = $this->getUser()->getOption( 'upwiz_deflicense' );
147147
148 - if ( $defaultLicense !== 'default' && in_array( $defaultLicense, $config['licensesOwnWork']['licenses'] ) ) {
149 - $config['licensesOwnWork']['defaults'] = array( $defaultLicense );
 148+ if ( $defaultLicense !== 'default' ) {
 149+ $defaultLicense = explode( '-', $defaultLicense, 2 );
 150+ $licenseType = $defaultLicense[0];
 151+ $defaultLicense = $defaultLicense[1];
 152+
 153+ if ( in_array( $defaultLicense, $config['licensesOwnWork']['licenses'] )
 154+ || in_array( $defaultLicense, UploadWizardConfig::getThirdPartyLicenses() ) ) {
 155+
 156+ $licenseGroup = $licenseType === 'ownwork' ? 'licensesOwnWork' : 'licensesThirdParty';
 157+ $config[$licenseGroup]['defaults'] = array( $defaultLicense );
 158+ $config['defaultLicenseType'] = $licenseType;
 159+ }
150160 }
151161
152 - $thirdPartyDefault = $this->getUser()->getOption( 'upwiz_def3rdparty' );
153 -
154 - if ( $thirdPartyDefault !== 'default' && in_array( $thirdPartyDefault, UploadWizardConfig::getThirdPartyLicenses() ) ) {
155 - $config['licensesThirdParty']['defaults'] = array( $thirdPartyDefault );
156 - }
157 -
158 - $licenseTypeDefault = $this->getUser()->getOption( 'upwiz_deflicensetype' );
159 -
160 - if ( $licenseTypeDefault !== 'default' && $config['ownWorkOption'] === 'choice' ) {
161 - $config['ownWorkOption'] = $licenseTypeDefault === 'ownwork' ? 'own' : 'notown';
162 - }
163 -
164162 $this->getOutput()->addScript(
165163 Skin::makeVariablesScript(
166164 array(
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -368,12 +368,10 @@
369369
370370 // Preferences
371371 'prefs-uploads' => 'Uploads',
372 - 'mwe-upwiz-prefs-def-license' => 'Default own work license',
 372+ 'mwe-upwiz-prefs-def-license' => 'Default license',
373373 'mwe-upwiz-prefs-def-license-def' => 'Use whatever the default is',
374 - 'mwe-upwiz-prefs-def-licensetype' => 'Default license type',
375 - 'mwe-upwiz-prefs-def-3rdparty' => 'Default third party license',
376 - 'mwe-upwiz-prefs-def-license-ownwork' => 'Own work',
377 - 'mwe-upwiz-prefs-def-license-3rdparty' => 'Third party',
 374+ 'mwe-upwiz-prefs-license-own' => 'Own work - $1',
 375+ 'mwe-upwiz-prefs-license-thirdparty' => "Someone else's work - $1",
378376 );
379377
380378 /** Message documentation (Message documentation)
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js
@@ -386,14 +386,19 @@
387387
388388 deed.setFormFields( $deedInterface.find( '.mwe-upwiz-deed-form' ) );
389389
 390+ var selectDeedFunction = function() {
 391+ _this.choose( deed );
 392+ _this.selectDeedInterface( $deedInterface );
 393+ $deedInterface.find( 'span.mwe-upwiz-deed-header input' ).attr( 'checked', true );
 394+ };
 395+
390396 if ( deeds.length == 1 ) {
391 - _this.onLayoutReady = function() {
392 - _this.choose( deed );
393 - _this.selectDeedInterface( $deedInterface );
394 - $deedInterface.find( 'span.mwe-upwiz-deed-header input' ).attr( 'checked', true );
395 - };
 397+ _this.onLayoutReady = selectDeedFunction;
396398 }
397399 else {
 400+ if ( mw.UploadWizard.config.defaultLicenseType === deed.name ) {
 401+ _this.onLayoutReady = selectDeedFunction;
 402+ }
398403 $deedInterface.find( 'span.mwe-upwiz-deed-header input' ).click( function() {
399404 if ( $j( this ).is( ':checked' ) ) {
400405 _this.choose( deed );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103599implemented feature request from bug 24702jeroendedauw15:46, 18 November 2011

Status & tagging log