Index: trunk/extensions/CentralNotice/SpecialBannerLoader.php |
— | — | @@ -103,8 +103,12 @@ |
104 | 104 | */ |
105 | 105 | function getNoticeField( $match ) { |
106 | 106 | $field = $match[1]; |
| 107 | + $params = array(); |
| 108 | + if ( $field == 'amount' ) { |
| 109 | + $params = array( $this->formatNum( $this->getDonationAmount() ) ); |
| 110 | + } |
107 | 111 | $message = "centralnotice-{$this->bannerName}-$field"; |
108 | | - $source = $this->getMessage( $message ); |
| 112 | + $source = $this->getMessage( $message, $params ); |
109 | 113 | return $source; |
110 | 114 | } |
111 | 115 | |
— | — | @@ -125,25 +129,25 @@ |
126 | 130 | * @param $msg The full name of the message |
127 | 131 | * @return translated messsage string |
128 | 132 | */ |
129 | | - private function getMessage( $msg ) { |
130 | | - global $wgLang; |
131 | | - |
| 133 | + private function getMessage( $msg, $params = array() ) { |
| 134 | + global $wgLang, $wgSitename; |
| 135 | + |
132 | 136 | // A god-damned dirty hack! :D |
133 | 137 | $oldLang = $wgLang; |
| 138 | + $oldSitename = $wgSitename; |
134 | 139 | |
| 140 | + $wgSitename = $this->siteName; // hack for {{SITENAME}} |
135 | 141 | $wgLang = Language::factory( $this->language ); // hack for {{int:...}} |
136 | | - $out = wfMsgExt( $msg, array( 'language' => $this->language, 'parsemag' ) ); |
137 | 142 | |
138 | | - // Restore global |
| 143 | + $options = array( 'language' => $this->language, 'parsemag' ); |
| 144 | + array_unshift( $params, $options ); |
| 145 | + array_unshift( $params, $msg ); |
| 146 | + $out = call_user_func_array( 'wfMsgExt', $params ); |
| 147 | + |
| 148 | + // Restore global variables |
139 | 149 | $wgLang = $oldLang; |
140 | | - |
141 | | - // Replace variables in banner with values |
142 | | - $amountSub = strpos( $out, '$amount'); |
143 | | - if ( $amountSub !== false ) { |
144 | | - $out = str_replace( '$amount', $this->formatNum( $this->getDonationAmount() ), $out ); |
145 | | - } |
146 | | - $out = str_replace( '$sitename', $this->siteName, $out ); |
147 | | - |
| 150 | + $wgSitename = $oldSitename; |
| 151 | + |
148 | 152 | return $out; |
149 | 153 | } |
150 | 154 | |
Index: trunk/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -27,9 +27,9 @@ |
28 | 28 | $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
29 | 29 | |
30 | 30 | if ( !$date ) { |
31 | | - $encTimestamp = $dbr->timestamp(); |
| 31 | + $encTimestamp = $dbr->addQuotes( $dbr->timestamp() ); |
32 | 32 | } else { |
33 | | - $encTimestamp = $dbr->timestamp( $date ); |
| 33 | + $encTimestamp = $dbr->addQuotes( $dbr->timestamp( $date ) ); |
34 | 34 | } |
35 | 35 | |
36 | 36 | $tables[] = "cn_notices"; |