http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95037
Revision: 95037
Author: jeroendedauw
Date: 2011-08-19 20:03:02 +0000 (Fri, 19 Aug 2011)
Log Message:
-----------
fix issue with obtaining messages from config pages
Modified Paths:
--------------
trunk/extensions/UploadWizard/UploadWizard.config.php
trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php
trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
Modified: trunk/extensions/UploadWizard/UploadWizard.config.php
===================================================================
--- trunk/extensions/UploadWizard/UploadWizard.config.php 2011-08-19
20:01:08 UTC (rev 95036)
+++ trunk/extensions/UploadWizard/UploadWizard.config.php 2011-08-19
20:03:02 UTC (rev 95037)
@@ -54,7 +54,7 @@
// Page on which the text to display with the id field is stored.
// Overrides idFieldLabel when set. $1 is replaced by the language code.
- 'idFieldLabelPage' => false,
+ 'idFieldLabelPage' => '',
// 'licenses' is a list of licenses you could possibly use elsewhere,
for instance in
// licensesOwnWork or licensesThirdParty.
Modified: trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php
===================================================================
--- trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php
2011-08-19 20:01:08 UTC (rev 95036)
+++ trunk/extensions/UploadWizard/includes/UploadWizardCampaign.php
2011-08-19 20:03:02 UTC (rev 95037)
@@ -364,39 +364,10 @@
$config['licensesOwnWork']['defaults'] = array(
$config['defaultOwnWorkLicence'] );
unset( $config['defaultOwnWorkLicence'] );
- $config['idFieldLabelPage'] = $this->getPageContent(
$config['idFieldLabelPage'] );
- $config['headerLabelPage'] = $this->getPageContent(
$config['headerLabelPage'] );
-
return $config;
}
/**
- * Gets content of the specified page, or false if there is no such
page.
- * '$1' in $pageName is replaced by the code of the current language.
- *
- * @since 1.2
- *
- * @param string $pageName
- *
- * @return string|false
- */
- protected function getPageContent( $pageName ) {
- $content = false;
-
- if ( trim( $pageName ) != '' ) {
- global $wgLang;
- $page = Title::newFromText( str_replace( '$1',
$wgLang->getCode(), $pageName ) );
-
- if ( !is_null( $page ) && $page->exists() ) {
- $article = new Article( $page );
- $content = $article->getContent();
- }
- }
-
- return $content;
- }
-
- /**
* Returns all config properties by merging the set ones with a list of
default ones.
* Property name => array( 'default' => $value, 'type' => HTMLForm
input type )
*
Modified:
trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
===================================================================
--- trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
2011-08-19 20:01:08 UTC (rev 95036)
+++ trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php
2011-08-19 20:03:02 UTC (rev 95037)
@@ -132,10 +132,17 @@
public function addJsVars( $subPage ) {
global $wgOut, $wgSitename;
+ $config = UploadWizardConfig::getConfig( $this->campaign );
+
+ $labelPageContent = $this->getPageContent(
$config['idFieldLabelPage'] );
+ if ( $labelPageContent !== false ) {
+ $config['idFieldLabel'] = $labelPageContent;
+ }
+
$wgOut->addScript(
Skin::makeVariablesScript(
array(
- 'UploadWizardConfig' =>
UploadWizardConfig::getConfig( $this->campaign )
+ 'UploadWizardConfig' => $config
) +
// Site name is a true global not specific to
Upload Wizard
array(
@@ -143,8 +150,33 @@
)
)
);
-
}
+
+ /**
+ * Gets content of the specified page, or false if there is no such
page.
+ * '$1' in $pageName is replaced by the code of the current language.
+ *
+ * @since 1.2
+ *
+ * @param string $pageName
+ *
+ * @return string|false
+ */
+ protected function getPageContent( $pageName ) {
+ $content = false;
+
+ if ( trim( $pageName ) != '' ) {
+ global $wgLang;
+ $page = Title::newFromText( str_replace( '$1',
$wgLang->getCode(), $pageName ) );
+
+ if ( !is_null( $page ) && $page->exists() ) {
+ $article = new Article( $page );
+ $content = $article->getContent();
+ }
+ }
+
+ return $content;
+ }
/**
* Check if anyone can upload (or if other sitewide config prevents
this)
@@ -212,9 +244,10 @@
$globalConf = UploadWizardConfig::getConfig( $this->campaign );
- if ( $globalConf['headerLabelPage'] !== false ) {
+ $headerContent = $this->getPageContent(
$globalConf['headerLabelPage'] );
+ if ( $headerContent !== false ) {
global $wgOut;
- $wgOut->addWikiText( $globalConf['headerLabelPage'] );
+ $wgOut->addWikiText( $headerContent );
}
if ( array_key_exists( 'fallbackToAltUploadForm', $globalConf )
Modified: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
2011-08-19 20:01:08 UTC (rev 95036)
+++ trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
2011-08-19 20:03:02 UTC (rev 95037)
@@ -180,15 +180,8 @@
var idFieldId = "idField" + ( _this.upload.index ).toString();
_this.idFieldInput = $j( '<input type="text" id="' + idFieldId
+ '" name="' + idFieldId + '" class="mwe-idfield" maxlength="15"/>' );
- if ( mw.UploadWizard.config.idFieldLabelPage !== false ) {
- var label = mw.UploadWizard.config.idFieldLabelPage;
- }
- else {
- var label = mw.UploadWizard.config.idFieldLabel;
- }
-
_this.$form.append(
- $j( '<div class="mwe-upwiz-details-fieldname"></div>'
).text( label ),
+ $j( '<div class="mwe-upwiz-details-fieldname"></div>'
).text( mw.UploadWizard.config.idFieldLabel ),
$j( '<div class="mwe-id-field"></div>' ).append(
_this.idFieldInput )
);
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs