r103612 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103611‎ | r103612 | r103613 >
Date:20:59, 18 November 2011
Author:jeroendedauw
Status:ok (Comments)
Tags:neilk 
Comment:
Follow up to r103599; implemented prefs for third party license and license type as well
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.i18n.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardHooks.php (modified) (history)
  • /trunk/extensions/UploadWizard/includes/UploadWizardConfig.php (modified) (history)
  • /trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.php
@@ -86,6 +86,8 @@
8787 $wgRemoveGroups['sysop'][] = 'upwizcampeditors';
8888
8989 $wgDefaultUserOptions['upwiz_deflicense'] = 'default';
 90+$wgDefaultUserOptions['upwiz_def3rdparty'] = 'default';
 91+$wgDefaultUserOptions['upwiz_deflicensetype'] = 'default';
9092
9193 // Init the upload wizard config array
9294 // UploadWizard.config.php includes default configuration
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php
@@ -500,16 +500,29 @@
501501 */
502502 public static function onGetPreferences( User $user, array &$preferences ) {
503503 if ( UploadWizardConfig::getSetting( 'enableLicensePreference' ) ) {
504 - $ownWork = UploadWizardConfig::getSetting( 'licensesOwnWork' );
505504 $licenseConfig = UploadWizardConfig::getSetting( 'licenses' );
506505
 506+ $defOption = array( wfMsg( 'mwe-upwiz-prefs-def-license-def' ) => 'default' );
 507+
 508+ $preferences['upwiz_deflicensetype'] = array(
 509+ 'type' => 'radio',
 510+ 'label-message' => 'mwe-upwiz-prefs-def-licensetype',
 511+ 'section' => 'uploads',
 512+ 'options' => array(
 513+ $defOption,
 514+ wfMsg( 'mwe-upwiz-prefs-def-license-ownwork' ) => 'ownwork',
 515+ wfMsg( 'mwe-upwiz-prefs-def-license-3rdparty' ) => 'thirdparty',
 516+ )
 517+ );
 518+
 519+ $ownWork = UploadWizardConfig::getSetting( 'licensesOwnWork' );
 520+
507521 $licenses = array();
508522
509523 foreach ( $ownWork['licenses'] as $license ) {
510524 $licenses[wfMsg( $licenseConfig[$license]['msg'] )] = $license;
511525 }
512526
513 - $defOption = array( wfMsg( 'mwe-upwiz-prefs-def-license-def' ) => 'default' );
514527 $licenses = array_merge( $defOption, $licenses );
515528
516529 $preferences['upwiz_deflicense'] = array(
@@ -518,6 +531,23 @@
519532 'section' => 'uploads',
520533 'options' => $licenses
521534 );
 535+
 536+ $thirdParty = UploadWizardConfig::getSetting( 'licensesThirdParty' );
 537+
 538+ $licenses = array();
 539+
 540+ foreach ( UploadWizardConfig::getThirdPartyLicenses() as $license ) {
 541+ $licenses[wfMsg( $licenseConfig[$license]['msg'] )] = $license;
 542+ }
 543+
 544+ $licenses = array_merge( $defOption, $licenses );
 545+
 546+ $preferences['upwiz_def3rdparty'] = array(
 547+ 'type' => 'radio',
 548+ 'label-message' => 'mwe-upwiz-prefs-def-3rdparty',
 549+ 'section' => 'uploads',
 550+ 'options' => $licenses
 551+ );
522552 }
523553
524554 return true;
Index: trunk/extensions/UploadWizard/includes/UploadWizardConfig.php
@@ -111,4 +111,22 @@
112112 return array();
113113 }
114114
 115+ /**
 116+ * Get a list of available third party licenses from the config.
 117+ *
 118+ * @since 1.2
 119+ *
 120+ * @return array
 121+ */
 122+ public static function getThirdPartyLicenses() {
 123+ $thirdParty = self::getSetting( 'licensesThirdParty' );
 124+ $licenses = array();
 125+
 126+ foreach ( $thirdParty['licenseGroups'] as $group ) {
 127+ $licenses = array_merge( $licenses, $group['licenses'] );
 128+ }
 129+
 130+ return $licenses;
 131+ }
 132+
115133 }
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
@@ -148,6 +148,18 @@
149149 $config['licensesOwnWork']['defaults'] = array( $defaultLicense );
150150 }
151151
 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+
152164 $this->getOutput()->addScript(
153165 Skin::makeVariablesScript(
154166 array(
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -366,6 +366,10 @@
367367 'prefs-uploads' => 'Uploads',
368368 'mwe-upwiz-prefs-def-license' => 'Default own work license',
369369 'mwe-upwiz-prefs-def-license-def' => 'Use whatever the default is',
 370+ 'mwe-upwiz-prefs-def-licensetype' => 'Default license type',
 371+ 'mwe-upwiz-prefs-def-3rdparty' => 'Default third party license',
 372+ 'mwe-upwiz-prefs-def-license-ownwork' => 'Own work',
 373+ 'mwe-upwiz-prefs-def-license-3rdparty' => 'Third party',
370374 );
371375
372376 /** Message documentation (Message documentation)

Follow-up revisions

RevisionCommit summaryAuthorDate
r103670follow up to r103612jeroendedauw13:37, 19 November 2011

Past revisions this follows-up on

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

Comments

#Comment by Siebrand (talk | contribs)   04:12, 19 November 2011

Please add message documentation for the newly added messages. Thanks.

#Comment by NeilK (talk | contribs)   18:47, 6 December 2011

adding fixme only for r104495 compatibility -- and I'm not sure I really like how that was implemented either ;)

Status & tagging log