Index: trunk/extensions/UploadWizard/UploadWizard.config.php |
— | — | @@ -15,7 +15,10 @@ |
16 | 16 | // The default api url is for the current wiki ( can override at run time ) |
17 | 17 | 'apiUrl' => $wgServer . $wgScriptPath . '/api.php', |
18 | 18 | |
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 |
20 | 23 | 'autoCategory' => '', |
21 | 24 | |
22 | 25 | // '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 @@ |
58 | 58 | $enabled = $campaign ? $campaign->getIsEnabled() : false; |
59 | 59 | $configFields = $campaign ? $campaign->getAllConfig() : UploadWizardCampaign::getDefaultConfig(); |
60 | 60 | |
61 | | - $fields = array (); |
| 61 | + $fields = array(); |
62 | 62 | |
63 | 63 | $fields['Campaignid'] = array ( 'type' => 'hidden', 'default' => $id ); |
64 | 64 | $fields['Campaignname'] = array ( 'type' => 'text', 'default' => $this->subPage, 'label-message' => 'mwe-upwiz-campaign-name' ); |
— | — | @@ -65,7 +65,20 @@ |
66 | 66 | |
67 | 67 | foreach ( $configFields as $name => $data ) { |
68 | 68 | $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 | + } |
70 | 83 | } |
71 | 84 | |
72 | 85 | return $fields; |
Index: trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php |
— | — | @@ -69,9 +69,8 @@ |
70 | 70 | $this->id = $id; |
71 | 71 | $this->name = $name; |
72 | 72 | $this->isEnabled = $isEnabled; |
73 | | - $this->config = $config; |
74 | 73 | |
75 | | - $this->loadedConfig = count( $this->config ) > 0; |
| 74 | + $this->setConfig( $config ); |
76 | 75 | } |
77 | 76 | |
78 | 77 | /** |
— | — | @@ -152,7 +151,8 @@ |
153 | 152 | */ |
154 | 153 | public static function getConfigTypes() { |
155 | 154 | return array( |
156 | | - 'skipTutorial' => 'check' |
| 155 | + 'skipTutorial' => 'check', |
| 156 | + 'autoCategories' => 'text', |
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
— | — | @@ -225,8 +225,17 @@ |
226 | 226 | * @param array $config |
227 | 227 | */ |
228 | 228 | 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 | + |
229 | 237 | $this->config = $config; |
230 | | - $this->loadedConfig = true; |
| 238 | + |
| 239 | + $this->loadedConfig = count( $this->config ) > 0; |
231 | 240 | } |
232 | 241 | |
233 | 242 | /** |
— | — | @@ -365,7 +374,7 @@ |
366 | 375 | array( |
367 | 376 | 'cc_campaign_id' => $this->id, |
368 | 377 | 'cc_property' => $prop, |
369 | | - 'cc_value' => $value |
| 378 | + 'cc_value' => is_array( $value ) ? implode( ', ', $value ) : $value |
370 | 379 | ) |
371 | 380 | ); |
372 | 381 | } |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -296,6 +296,7 @@ |
297 | 297 | 'mwe-upwiz-campaign-name' => 'Campaign name', |
298 | 298 | 'mwe-upwiz-campaign-enabled' => 'Campaign enabled', |
299 | 299 | 'mwe-upwiz-campaign-conf-skipTutorial' => 'Skip the licensing tutorial', |
| 300 | + 'mwe-upwiz-campaign-conf-autoCategories' => 'Categories to add the images to automatically', |
300 | 301 | ); |
301 | 302 | |
302 | 303 | /** Message documentation (Message documentation) |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js |
— | — | @@ -265,10 +265,11 @@ |
266 | 266 | } ); |
267 | 267 | |
268 | 268 | // make this a category picker |
269 | | - var hiddenCats = []; |
| 269 | + var hiddenCats = mw.isDefined( mw.UploadWizard.config.autoCategories ) ? mw.UploadWizard.config.autoCategories : []; |
270 | 270 | if ( mw.isDefined( mw.UploadWizard.config.autoCategory ) && mw.UploadWizard.config.autoCategory !== '' ) { |
271 | 271 | hiddenCats.push( mw.UploadWizard.config.autoCategory ); |
272 | 272 | } |
| 273 | + |
273 | 274 | $categoriesDiv.find( '.mwe-upwiz-details-input' ) |
274 | 275 | .find( 'input' ) |
275 | 276 | .mwCoolCats( { |