Index: trunk/extensions/UploadWizard/UploadWizard.config.php |
— | — | @@ -43,6 +43,10 @@ |
44 | 44 | // When not provided, the message mwe-upwiz-thanks-intro will be used. |
45 | 45 | 'thanksLabelPage' => '', |
46 | 46 | |
| 47 | + // Default license type. |
| 48 | + // Possible values: choice, ownwork, thirdparty |
| 49 | + 'defaultLicenseType' => 'choice', |
| 50 | + |
47 | 51 | // Should the own work option be shown, and if not, what option should be set? |
48 | 52 | // Possible values: choice, own, notown |
49 | 53 | 'ownWorkOption' => 'choice', |
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -505,48 +505,26 @@ |
506 | 506 | if ( UploadWizardConfig::getSetting( 'enableLicensePreference' ) ) { |
507 | 507 | $licenseConfig = UploadWizardConfig::getSetting( 'licenses' ); |
508 | 508 | |
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 | | - |
523 | 509 | $licenses = array(); |
524 | | - |
| 510 | + |
| 511 | + $ownWork = UploadWizardConfig::getSetting( 'licensesOwnWork' ); |
525 | 512 | 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; |
527 | 515 | } |
528 | 516 | |
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 | | - |
542 | 517 | 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 | + } |
544 | 522 | } |
545 | 523 | |
546 | | - $licenses = array_merge( $defOption, $licenses ); |
| 524 | + $licenses = array_merge( array( wfMsg( 'mwe-upwiz-prefs-def-license-def' ) => 'default' ), $licenses ); |
547 | 525 | |
548 | | - $preferences['upwiz_def3rdparty'] = array( |
| 526 | + $preferences['upwiz_deflicense'] = array( |
549 | 527 | 'type' => 'radio', |
550 | | - 'label-message' => 'mwe-upwiz-prefs-def-3rdparty', |
| 528 | + 'label-message' => 'mwe-upwiz-prefs-def-license', |
551 | 529 | 'section' => 'uploads', |
552 | 530 | 'options' => $licenses |
553 | 531 | ); |
— | — | @@ -554,5 +532,24 @@ |
555 | 533 | |
556 | 534 | return true; |
557 | 535 | } |
| 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 | + } |
558 | 555 | |
559 | 556 | } |
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php |
— | — | @@ -144,22 +144,20 @@ |
145 | 145 | |
146 | 146 | $defaultLicense = $this->getUser()->getOption( 'upwiz_deflicense' ); |
147 | 147 | |
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 | + } |
150 | 160 | } |
151 | 161 | |
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 | | - |
164 | 162 | $this->getOutput()->addScript( |
165 | 163 | Skin::makeVariablesScript( |
166 | 164 | array( |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -368,12 +368,10 @@ |
369 | 369 | |
370 | 370 | // Preferences |
371 | 371 | 'prefs-uploads' => 'Uploads', |
372 | | - 'mwe-upwiz-prefs-def-license' => 'Default own work license', |
| 372 | + 'mwe-upwiz-prefs-def-license' => 'Default license', |
373 | 373 | '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", |
378 | 376 | ); |
379 | 377 | |
380 | 378 | /** Message documentation (Message documentation) |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js |
— | — | @@ -386,14 +386,19 @@ |
387 | 387 | |
388 | 388 | deed.setFormFields( $deedInterface.find( '.mwe-upwiz-deed-form' ) ); |
389 | 389 | |
| 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 | + |
390 | 396 | 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; |
396 | 398 | } |
397 | 399 | else { |
| 400 | + if ( mw.UploadWizard.config.defaultLicenseType === deed.name ) { |
| 401 | + _this.onLayoutReady = selectDeedFunction; |
| 402 | + } |
398 | 403 | $deedInterface.find( 'span.mwe-upwiz-deed-header input' ).click( function() { |
399 | 404 | if ( $j( this ).is( ':checked' ) ) { |
400 | 405 | _this.choose( deed ); |