r93318 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93317‎ | r93318 | r93319 >
Date:21:52, 27 July 2011
Author:jeroendedauw
Status:ok
Tags:
Comment:
added campaign settings for ownwork choice and ownwork licences. not implemented in the JS yet
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/UploadWizardConfig.php (modified) (history)
  • /trunk/extensions/UploadWizard/includes/specials/SpecialUploadCampaign.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.config.php
@@ -27,6 +27,10 @@
2828 // WikiText to automatically (and silently) add to all uploaded images.
2929 'autoWikiText' => '',
3030
 31+ // Should the own work option be shown, and if not, what option should be set?
 32+ // Possible values: choice, own, notown
 33+ 'ownWorkOption' => 'choice',
 34+
3135 // 'licenses' is a list of licenses you could possibly use elsewhere, for instance in
3236 // licensesOwnWork or licensesThirdParty.
3337 // It just describes what licenses go with what wikitext, and how to display them in
Index: trunk/extensions/UploadWizard/includes/UploadWizardConfig.php
@@ -103,7 +103,7 @@
104104 $capaign = UploadWizardCampaign::newFromName( $campaignName );
105105
106106 if ( $capaign !== false && $capaign->getIsEnabled() ) {
107 - return $capaign->getConfig();
 107+ return $capaign->getConfigForGlobalMerge();
108108 }
109109
110110 return array();
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadCampaign.php
@@ -24,7 +24,7 @@
2525 * @param $request is the request (usually wgRequest)
2626 * @param $par is everything in the URL after Special:UploadCampaign. Not sure what we can use it for
2727 */
28 - public function __construct($request = null, $par = null) {
 28+ public function __construct( $request = null, $par = null ) {
2929 parent::__construct ( 'UploadCampaign', 'upwizcampaigns', false );
3030 }
3131
@@ -75,10 +75,6 @@
7676 }
7777 }
7878
79 - if ( $data['type'] == 'textarea' ) {
80 - $data['rows'] = 4;
81 - }
82 -
8379 $fields[$name] = $data;
8480 }
8581
Index: trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php
@@ -150,12 +150,44 @@
151151 * @return array
152152 */
153153 public static function getConfigTypes() {
154 - return array(
155 - 'skipTutorial' => 'check',
156 - 'autoCategories' => 'text',
157 - 'defaultCategories' => 'text',
158 - 'autoWikiText' => 'textarea',
 154+ $config = array(
 155+ 'skipTutorial' => array(
 156+ 'type' => 'check'
 157+ ),
 158+ 'autoCategories' => array(
 159+ 'type' => 'text'
 160+ ),
 161+ 'defaultCategories' => array(
 162+ 'type' => 'text'
 163+ ),
 164+ 'autoWikiText' => array(
 165+ 'type' => 'textarea',
 166+ 'rows' => 4
 167+ ),
 168+ 'ownWorkOption' => array(
 169+ 'type' => 'radio',
 170+ 'options' => array(
 171+ wfMsg( 'mwe-upwiz-campaign-owner-choice' ) => 'choice',
 172+ wfMsg( 'mwe-upwiz-campaign-owner-own' ) => 'own',
 173+ wfMsg( 'mwe-upwiz-campaign-owner-notown' ) => 'notown'
 174+ )
 175+ ),
159176 );
 177+
 178+ $globalConfig = UploadWizardConfig::getConfig();
 179+
 180+ $config['licensesOwnWork'] = array(
 181+ 'type' => 'multiselect',
 182+ 'options' => array(),
 183+ 'default' => $globalConfig['licensesOwnWork']['licenses']
 184+ );
 185+
 186+ foreach ( $globalConfig['licensesOwnWork']['licenses'] as $license ) {
 187+ $licenceMsg = wfMsg( $globalConfig['licenses'][$license]['msg'] );
 188+ $config['licensesOwnWork']['options'][$licenceMsg] = $license;
 189+ }
 190+
 191+ return $config;
160192 }
161193
162194 /**
@@ -173,9 +205,9 @@
174206 $config = array();
175207 $globalConf = UploadWizardConfig::getConfig();
176208
177 - foreach ( self::getConfigTypes() as $setting => $type ) {
 209+ foreach ( self::getConfigTypes() as $setting => $data ) {
178210 if ( array_key_exists( $setting, $globalConf ) ) {
179 - $config[$setting] = array( 'type' => $type, 'default' => $globalConf[$setting] );
 211+ $config[$setting] = array_merge( array( 'default' => $globalConf[$setting] ), $data );
180212 }
181213 else {
182214 wfWarn( "Nonexiting Upload Wizard configuration setting '$setting' will be ignored." );
@@ -269,6 +301,21 @@
270302 return $this->config;
271303 }
272304
 305+ public function getConfigForGlobalMerge() {
 306+ $config = $this->getConfig();
 307+
 308+ foreach ( $config as $settingName => &$settingValue ) {
 309+ if ( $settingName == 'licensesOwnWork' ) {
 310+ $settingValue = array_merge(
 311+ UploadWizardConfig::getSetting( 'licensesOwnWork' ),
 312+ array( 'licenses' => $settingValue )
 313+ );
 314+ }
 315+ }
 316+
 317+ return $config;
 318+ }
 319+
273320 /**
274321 * Returns all config properties by merging the set ones with a list of default ones.
275322 * Property name => array( 'default' => $value, 'type' => HTMLForm input type )
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -302,6 +302,11 @@
303303 'mwe-upwiz-campaign-conf-autoCategories' => 'Categories to add the files to automatically and silently',
304304 'mwe-upwiz-campaign-conf-defaultCategories' => 'Default categories to list in the describe tab',
305305 'mwe-upwiz-campaign-conf-autoWikiText' => 'WikiText to automatically add to all uploaded images',
 306+ 'mwe-upwiz-campaign-conf-ownWorkOption' => 'How to handle own-work or not own-work',
 307+ 'mwe-upwiz-campaign-owner-choice' => 'Allow the user to choose between own work and non-own work',
 308+ 'mwe-upwiz-campaign-owner-own' => 'Only allow for own work uploads',
 309+ 'mwe-upwiz-campaign-owner-notown' => 'Only allow for non-own work uploads',
 310+ 'mwe-upwiz-campaign-conf-licensesOwnWork' => 'The licences that should be choosable for own-work',
306311
307312 // Coolcats
308313 'mw-coolcats-confirm-new-title' => 'Confirm new category',

Status & tagging log