r93022 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93021‎ | r93022 | r93023 >
Date:21:59, 24 July 2011
Author:jeroendedauw
Status:ok (Comments)
Tags:config 
Comment:
added basic support for multiple value settings. added autoCategories to replace autoCategory and added it to the capmaign config list
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/resources/mw.UploadWizardDetails.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.config.php
@@ -15,7 +15,10 @@
1616 // The default api url is for the current wiki ( can override at run time )
1717 'apiUrl' => $wgServer . $wgScriptPath . '/api.php',
1818
19 - // Category to automatically add all uploaded images into. Leave empty for none.
 19+ // Categories to automatically add all uploaded images into.
 20+ 'autoCategories' => array( 'Locations', 'Examples' ),
 21+
 22+ // Deprecated: use autoCategories
2023 'autoCategory' => '',
2124
2225 // 'licenses' is a list of licenses you could possibly use elsewhere, for instance in
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadCampaign.php
@@ -57,7 +57,7 @@
5858 $enabled = $campaign ? $campaign->getIsEnabled() : false;
5959 $configFields = $campaign ? $campaign->getAllConfig() : UploadWizardCampaign::getDefaultConfig();
6060
61 - $fields = array ();
 61+ $fields = array();
6262
6363 $fields['Campaignid'] = array ( 'type' => 'hidden', 'default' => $id );
6464 $fields['Campaignname'] = array ( 'type' => 'text', 'default' => $this->subPage, 'label-message' => 'mwe-upwiz-campaign-name' );
@@ -65,7 +65,20 @@
6666
6767 foreach ( $configFields as $name => $data ) {
6868 $data['label-message'] = 'mwe-upwiz-campaign-conf-' . $name;
69 - $fields[$name] = $data;
 69+
 70+ // Special handling for lists of values per input type.
 71+ if ( is_array( $data['default'] ) ) {
 72+ switch ( $data['type'] ) {
 73+ case 'text':
 74+ $data['default'] = implode( ', ', $data['default'] );
 75+ break;
 76+ }
 77+
 78+ $fields[$name] = $data;
 79+ }
 80+ else {
 81+ $fields[$name] = $data;
 82+ }
7083 }
7184
7285 return $fields;
Index: trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php
@@ -69,9 +69,8 @@
7070 $this->id = $id;
7171 $this->name = $name;
7272 $this->isEnabled = $isEnabled;
73 - $this->config = $config;
7473
75 - $this->loadedConfig = count( $this->config ) > 0;
 74+ $this->setConfig( $config );
7675 }
7776
7877 /**
@@ -152,7 +151,8 @@
153152 */
154153 public static function getConfigTypes() {
155154 return array(
156 - 'skipTutorial' => 'check'
 155+ 'skipTutorial' => 'check',
 156+ 'autoCategories' => 'text',
157157 );
158158 }
159159
@@ -225,8 +225,17 @@
226226 * @param array $config
227227 */
228228 public function setConfig( array $config ) {
 229+ $defaultConfig = self::getDefaultConfig();
 230+
 231+ foreach ( $config as $settingName => &$settingValue ) {
 232+ if ( is_array( $defaultConfig[$settingName]['default'] ) && !is_array( $settingValue ) ) {
 233+ $settingValue = explode( ', ', $settingValue );
 234+ }
 235+ }
 236+
229237 $this->config = $config;
230 - $this->loadedConfig = true;
 238+
 239+ $this->loadedConfig = count( $this->config ) > 0;
231240 }
232241
233242 /**
@@ -365,7 +374,7 @@
366375 array(
367376 'cc_campaign_id' => $this->id,
368377 'cc_property' => $prop,
369 - 'cc_value' => $value
 378+ 'cc_value' => is_array( $value ) ? implode( ', ', $value ) : $value
370379 )
371380 );
372381 }
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -296,6 +296,7 @@
297297 'mwe-upwiz-campaign-name' => 'Campaign name',
298298 'mwe-upwiz-campaign-enabled' => 'Campaign enabled',
299299 'mwe-upwiz-campaign-conf-skipTutorial' => 'Skip the licensing tutorial',
 300+ 'mwe-upwiz-campaign-conf-autoCategories' => 'Categories to add the images to automatically',
300301 );
301302
302303 /** Message documentation (Message documentation)
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
@@ -265,10 +265,11 @@
266266 } );
267267
268268 // make this a category picker
269 - var hiddenCats = [];
 269+ var hiddenCats = mw.isDefined( mw.UploadWizard.config.autoCategories ) ? mw.UploadWizard.config.autoCategories : [];
270270 if ( mw.isDefined( mw.UploadWizard.config.autoCategory ) && mw.UploadWizard.config.autoCategory !== '' ) {
271271 hiddenCats.push( mw.UploadWizard.config.autoCategory );
272272 }
 273+
273274 $categoriesDiv.find( '.mwe-upwiz-details-input' )
274275 .find( 'input' )
275276 .mwCoolCats( {

Follow-up revisions

RevisionCommit summaryAuthorDate
r93029fu r93022 - rem demo datajeroendedauw23:25, 24 July 2011

Comments

#Comment by NeilK (talk | contribs)   13:10, 22 August 2011

We should get rid of autoCategory, just use autoCategories. But not harmful for now so okaying.

Status & tagging log