r76157 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76156‎ | r76157 | r76158 >
Date:22:44, 5 November 2010
Author:tomasz
Status:ok
Tags:
Comment:
Missed 73959 on the last check in
Modified paths:
  • /branches/wmf/1.16wmf4/extensions/CentralNotice (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/CentralNotice/CentralNotice.db.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerLoader.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/extensions/CentralNotice/CentralNotice.db.php
@@ -27,9 +27,9 @@
2828 $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
2929
3030 if ( !$date ) {
31 - $encTimestamp = $dbr->timestamp();
 31+ $encTimestamp = $dbr->addQuotes( $dbr->timestamp() );
3232 } else {
33 - $encTimestamp = $dbr->timestamp( $date );
 33+ $encTimestamp = $dbr->addQuotes( $dbr->timestamp( $date ) );
3434 }
3535
3636 $tables = array( 'cn_notices' );
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerLoader.php
@@ -104,8 +104,12 @@
105105 */
106106 function getNoticeField( $match ) {
107107 $field = $match[1];
 108+ $params = array();
 109+ if ( $field == 'amount' ) {
 110+ $params = array( $this->formatNum( $this->getDonationAmount() ) );
 111+ }
108112 $message = "centralnotice-{$this->bannerName}-$field";
109 - $source = $this->getMessage( $message );
 113+ $source = $this->getMessage( $message, $params );
110114 return $source;
111115 }
112116
@@ -126,25 +130,25 @@
127131 * @param $msg The full name of the message
128132 * @return translated messsage string
129133 */
130 - private function getMessage( $msg ) {
131 - global $wgLang;
132 -
 134+ private function getMessage( $msg, $params = array() ) {
 135+ global $wgLang, $wgSitename;
 136+
133137 // A god-damned dirty hack! :D
134138 $oldLang = $wgLang;
 139+ $oldSitename = $wgSitename;
135140
 141+ $wgSitename = $this->siteName; // hack for {{SITENAME}}
136142 $wgLang = Language::factory( $this->language ); // hack for {{int:...}}
137 - $out = wfMsgExt( $msg, array( 'language' => $this->language, 'parsemag' ) );
138143
139 - // Restore global
 144+ $options = array( 'language' => $this->language, 'parsemag' );
 145+ array_unshift( $params, $options );
 146+ array_unshift( $params, $msg );
 147+ $out = call_user_func_array( 'wfMsgExt', $params );
 148+
 149+ // Restore global variables
140150 $wgLang = $oldLang;
141 -
142 - // Replace variables in banner with values
143 - $amountSub = strpos( $out, '$amount');
144 - if ( $amountSub !== false ) {
145 - $out = str_replace( '$amount', $this->formatNum( $this->getDonationAmount() ), $out );
146 - }
147 - $out = str_replace( '$sitename', $this->siteName, $out );
148 -
 151+ $wgSitename = $oldSitename;
 152+
149153 return $out;
150154 }
151155
Property changes on: branches/wmf/1.16wmf4/extensions/CentralNotice
___________________________________________________________________
Modified: svn:mergeinfo
152156 Merged /trunk/extensions/CentralNotice:r73959

Status & tagging log