r94405 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94404‎ | r94405 | r94406 >
Date:12:41, 13 August 2011
Author:jeroendedauw
Status:ok
Tags:
Comment:
added setting that allows internationalization of id field label message by use of wiki pages
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/resources/mw.UploadWizardDetails.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.config.php
@@ -48,6 +48,10 @@
4949 // Label text to display with the id field.
5050 'idFieldLabel' => '',
5151
 52+ // Page on which the text to display with the id field is stored.
 53+ // Overrides idFieldLabel when set. $1 is replaced by the language code.
 54+ 'idFieldLabelPage' => false,
 55+
5256 // 'licenses' is a list of licenses you could possibly use elsewhere, for instance in
5357 // licensesOwnWork or licensesThirdParty.
5458 // It just describes what licenses go with what wikitext, and how to display them in
Index: trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php
@@ -171,6 +171,9 @@
172172 'idFieldLabel' => array(
173173 'type' => 'text',
174174 ),
 175+ 'idFieldLabelPage' => array(
 176+ 'type' => 'text',
 177+ ),
175178 'ownWorkOption' => array(
176179 'type' => 'radio',
177180 'options' => array(
@@ -327,6 +330,14 @@
328331 return $this->config;
329332 }
330333
 334+ /**
 335+ * Returns the configuration, ready for merging with the
 336+ * global configuration.
 337+ *
 338+ * @since 1.2
 339+ *
 340+ * @return arrayu
 341+ */
331342 public function getConfigForGlobalMerge() {
332343 $config = $this->getConfig();
333344
@@ -341,9 +352,28 @@
342353 }
343354 }
344355
 356+ foreach ( self::getDefaultConfig() as $name => $data ) {
 357+ if ( !array_key_exists( $name, $config ) ) {
 358+ $config[$name] = $data['default'];
 359+ }
 360+ }
 361+
345362 $config['licensesOwnWork']['defaults'] = array( $config['defaultOwnWorkLicence'] );
346363 unset( $config['defaultOwnWorkLicence'] );
347364
 365+ $labelPage = $config['idFieldLabelPage'];
 366+ $config['idFieldLabelPage'] = false;
 367+
 368+ if ( trim( $labelPage ) != '' ) {
 369+ global $wgLang;
 370+ $labelPage = Title::newFromText( str_replace( '$1', $wgLang->getCode(), $labelPage ) );
 371+
 372+ if ( !is_null( $labelPage ) && $labelPage->exists() ) {
 373+ $article = new Article( $labelPage );
 374+ $config['idFieldLabelPage'] = $article->getContent();
 375+ }
 376+ }
 377+
348378 return $config;
349379 }
350380
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -322,6 +322,7 @@
323323 'mwe-upwiz-campaign-conf-defaultOwnWorkLicence' => 'The default own work license',
324324 'mwe-upwiz-campaign-conf-idField' => 'Id field wikitext. Example: <nowiki>{{Rijksmonument|$1}}</nowiki>. Blank to not display field',
325325 'mwe-upwiz-campaign-conf-idFieldLabel' => 'Id field label text',
 326+ 'mwe-upwiz-campaign-conf-idFieldLabelPage' => 'Page name with text for the id field label ($1 for lang code)',
326327
327328 // Coolcats
328329 'mw-coolcats-confirm-new-title' => 'Confirm new category',
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
@@ -180,8 +180,15 @@
181181 var idFieldId = "idField" + ( _this.upload.index ).toString();
182182 _this.idFieldInput = $j( '<input type="text" id="' + idFieldId + '" name="' + idFieldId + '" class="mwe-idfield" maxlength="15"/>' );
183183
 184+ if ( mw.UploadWizard.config.idFieldLabelPage !== false ) {
 185+ var label = mw.UploadWizard.config.idFieldLabelPage;
 186+ }
 187+ else {
 188+ var label = mw.UploadWizard.config.idFieldLabel;
 189+ }
 190+
184191 _this.$form.append(
185 - $j( '<div class="mwe-upwiz-details-fieldname"></div>' ).text( mw.UploadWizard.config.idFieldLabel ),
 192+ $j( '<div class="mwe-upwiz-details-fieldname"></div>' ).text( label ),
186193 $j( '<div class="mwe-id-field"></div>' ).append( _this.idFieldInput )
187194 );
188195 }

Status & tagging log