http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73959
Revision: 73959
Author: kaldari
Date: 2010-09-29 17:19:37 +0000 (Wed, 29 Sep 2010)
Log Message:
-----------
tentative fix for bug 25354 (abondoning custom variables), adding quotes per
r73829
Modified Paths:
--------------
trunk/extensions/CentralNotice/CentralNotice.db.php
trunk/extensions/CentralNotice/SpecialBannerLoader.php
Modified: trunk/extensions/CentralNotice/CentralNotice.db.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNotice.db.php 2010-09-29 17:09:11 UTC
(rev 73958)
+++ trunk/extensions/CentralNotice/CentralNotice.db.php 2010-09-29 17:19:37 UTC
(rev 73959)
@@ -27,9 +27,9 @@
$dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
if ( !$date ) {
- $encTimestamp = $dbr->timestamp();
+ $encTimestamp = $dbr->addQuotes( $dbr->timestamp() );
} else {
- $encTimestamp = $dbr->timestamp( $date );
+ $encTimestamp = $dbr->addQuotes( $dbr->timestamp( $date
) );
}
$tables[] = "cn_notices";
Modified: trunk/extensions/CentralNotice/SpecialBannerLoader.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialBannerLoader.php 2010-09-29
17:09:11 UTC (rev 73958)
+++ trunk/extensions/CentralNotice/SpecialBannerLoader.php 2010-09-29
17:19:37 UTC (rev 73959)
@@ -103,8 +103,12 @@
*/
function getNoticeField( $match ) {
$field = $match[1];
+ $params = array();
+ if ( $field == 'amount' ) {
+ $params = array( $this->formatNum(
$this->getDonationAmount() ) );
+ }
$message = "centralnotice-{$this->bannerName}-$field";
- $source = $this->getMessage( $message );
+ $source = $this->getMessage( $message, $params );
return $source;
}
@@ -125,25 +129,25 @@
* @param $msg The full name of the message
* @return translated messsage string
*/
- private function getMessage( $msg ) {
- global $wgLang;
-
+ private function getMessage( $msg, $params = array() ) {
+ global $wgLang, $wgSitename;
+
// A god-damned dirty hack! :D
$oldLang = $wgLang;
+ $oldSitename = $wgSitename;
+ $wgSitename = $this->siteName; // hack for {{SITENAME}}
$wgLang = Language::factory( $this->language ); // hack for
{{int:...}}
- $out = wfMsgExt( $msg, array( 'language' => $this->language,
'parsemag' ) );
- // Restore global
+ $options = array( 'language' => $this->language, 'parsemag' );
+ array_unshift( $params, $options );
+ array_unshift( $params, $msg );
+ $out = call_user_func_array( 'wfMsgExt', $params );
+
+ // Restore global variables
$wgLang = $oldLang;
-
- // Replace variables in banner with values
- $amountSub = strpos( $out, '$amount');
- if ( $amountSub !== false ) {
- $out = str_replace( '$amount', $this->formatNum(
$this->getDonationAmount() ), $out );
- }
- $out = str_replace( '$sitename', $this->siteName, $out );
-
+ $wgSitename = $oldSitename;
+
return $out;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs