r103599 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103598‎ | r103599 | r103600 >
Date:15:46, 18 November 2011
Author:jeroendedauw
Status:ok (Comments)
Tags:neilk 
Comment:
implemented feature request from bug 24702
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.config.php (modified) (history)
  • /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/specials/SpecialUploadWizard.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.php
@@ -70,6 +70,7 @@
7171 $wgHooks['ResourceLoaderRegisterModules'][] = 'UploadWizardHooks::resourceLoaderRegisterModules';
7272 $wgHooks['CanonicalNamespaces'][] = 'UploadWizardHooks::canonicalNamespaces';
7373 $wgHooks['LoadExtensionSchemaUpdates'][] = 'UploadWizardHooks::onSchemaUpdate';
 74+$wgHooks['GetPreferences'][] = 'UploadWizardHooks::onGetPreferences';
7475
7576 $wgAvailableRights[] = 'upwizcampaigns';
7677
@@ -84,6 +85,8 @@
8586 $wgAddGroups['sysop'][] = 'upwizcampeditors';
8687 $wgRemoveGroups['sysop'][] = 'upwizcampeditors';
8788
 89+$wgDefaultUserOptions['upwiz_deflicense'] = 'default';
 90+
8891 // Init the upload wizard config array
8992 // UploadWizard.config.php includes default configuration
9093 // any value can be modified in localSettings.php by setting $wgUploadWizardConfig['name'] = 'value;
Index: trunk/extensions/UploadWizard/UploadWizard.config.php
@@ -9,6 +9,9 @@
1010 // Upload wizard has an internal debug flag
1111 'debug' => false,
1212
 13+ // Enable or disable the default upload license user preference
 14+ 'enableLicensePreference' => true,
 15+
1316 // File extensions acceptable in this wiki
1417 'fileExtensions' => $wgFileExtensions,
1518
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php
@@ -486,5 +486,41 @@
487487
488488 return true;
489489 }
 490+
 491+ /**
 492+ * Adds the preferences of UploadWizard to the list of available ones.
 493+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
 494+ *
 495+ * @since 1.2
 496+ *
 497+ * @param User $user
 498+ * @param array $preferences
 499+ *
 500+ * @return true
 501+ */
 502+ public static function onGetPreferences( User $user, array &$preferences ) {
 503+ if ( UploadWizardConfig::getSetting( 'enableLicensePreference' ) ) {
 504+ $ownWork = UploadWizardConfig::getSetting( 'licensesOwnWork' );
 505+ $licenseConfig = UploadWizardConfig::getSetting( 'licenses' );
 506+
 507+ $licenses = array();
 508+
 509+ foreach ( $ownWork['licenses'] as $license ) {
 510+ $licenses[wfMsg( $licenseConfig[$license]['msg'] )] = $license;
 511+ }
 512+
 513+ $defOption = array( wfMsg( 'mwe-upwiz-prefs-def-license-def' ) => 'default' );
 514+ $licenses = array_merge( $defOption, $licenses );
 515+
 516+ $preferences['upwiz_deflicense'] = array(
 517+ 'type' => 'radio',
 518+ 'label-message' => 'mwe-upwiz-prefs-def-license',
 519+ 'section' => 'uploads',
 520+ 'options' => $licenses
 521+ );
 522+ }
490523
 524+ return true;
 525+ }
 526+
491527 }
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
@@ -142,6 +142,12 @@
143143
144144 $config['thanksLabel'] = $this->getPageContent( $config['thanksLabelPage'], true );
145145
 146+ $defaultLicense = $this->getUser()->getOption( 'upwiz_deflicense' );
 147+
 148+ if ( $defaultLicense !== 'default' ) {
 149+ $config['licensesOwnWork']['defaults'] = array( $defaultLicense );
 150+ }
 151+
146152 $this->getOutput()->addScript(
147153 Skin::makeVariablesScript(
148154 array(
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -360,8 +360,12 @@
361361 'mw-coolcats-confirm-new-title' => 'Confirm new category',
362362 'mw-coolcats-confirm-new' => 'It looks like you are trying to add a new category, "$1". Be aware:<ul><li>Categories should usually be in English.</li><li>Most new categories should be a subcategory of an existing category.</li></ul>Generally, only experts should create a category.',
363363 'mw-coolcats-confirm-new-ok' => 'Add this category anyway',
364 - 'mw-coolcats-confirm-new-cancel' => 'Never mind'
 364+ 'mw-coolcats-confirm-new-cancel' => 'Never mind',
365365
 366+ // Preferences
 367+ 'prefs-uploads' => 'Uploads',
 368+ 'mwe-upwiz-prefs-def-license' => 'Default own work license',
 369+ 'mwe-upwiz-prefs-def-license-def' => 'Use whatever the default is',
366370 );
367371
368372 /** Message documentation (Message documentation)

Follow-up revisions

RevisionCommit summaryAuthorDate
r103604Follow up to r103599;jeroendedauw19:13, 18 November 2011
r103612Follow up to r103599; implemented prefs for third party license and license t...jeroendedauw20:59, 18 November 2011
r105436bug 24702: added new config option that allows choosing the default license t...jeroendedauw16:39, 7 December 2011

Comments

#Comment by Jeroen De Dauw (talk | contribs)   15:49, 18 November 2011

Just realized this won't play nice when you select a license and then use an upload campaign that does not have it - will fix later today.

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

needs to be made compatible with r104495, otherwise looks good

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

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

#Comment by NeilK (talk | contribs)   03:41, 9 December 2011

Looks ok. By the way I don't think you're supposed to de-fixme your own code. I know other people have complained when I did it.

#Comment by Bawolff (talk | contribs)   03:46, 9 December 2011

My understanding is that fixme -> new is ok if you've fixed the issue. fixme-> resolved (or ok) is not.

Status & tagging log