Index: branches/CentralNotice-SpecialPage-Integration/SpecialNoticeText.php |
— | — | @@ -40,21 +40,6 @@ |
41 | 41 | |
42 | 42 | function getHtmlNotice( $noticeName ) { |
43 | 43 | $this->noticeName = $noticeName; |
44 | | - /* |
45 | | - return strtr( |
46 | | - $this->getHtmlNotice(), |
47 | | - array( |
48 | | - #'$heading' => $this->getHeadlines(), // Wikipedia: Making Life Easier. |
49 | | - #'$subheading' => $this->getSubheading(), |
50 | | - #'$meter' => $this->getMeter(), // dynamic selection |
51 | | - '$amount' => $this->getMessage( 'amount' ), |
52 | | - array ( $this->formatNum( $this->getDonationAmount() )), // lookup |
53 | | - #'$target' => $this->getMessage( 'target' ), // "Our Goal 6 million |
54 | | - #'$show' => $this->getMessage( 'show' ), // show |
55 | | - #'$hide' => $this->getMessage( 'hide' ), // hide |
56 | | - ) |
57 | | - ); |
58 | | - */ |
59 | 44 | return preg_replace_callback( |
60 | 45 | '/{{{(.*?)}}}/', |
61 | 46 | array( $this, 'getNoticeField' ), |
— | — | @@ -241,11 +226,7 @@ |
242 | 227 | } |
243 | 228 | $message = "centralnotice-{$this->noticeName}-$field"; |
244 | 229 | $source = $this->getMessage( $message, $params ); |
245 | | - if( $source == '' ) { |
246 | | - return '{{{' . htmlspecialchars( $field ) . '}}}'; |
247 | | - } else { |
248 | | - return $this->parse( $source ); |
249 | | - } |
| 230 | + return $source; |
250 | 231 | } |
251 | 232 | |
252 | 233 | /* |
— | — | @@ -274,88 +255,23 @@ |
275 | 256 | */ |
276 | 257 | |
277 | 258 | private function getMessage( $msg, $params=array() ) { |
278 | | - /* |
279 | | - $guard = array(); |
280 | | - for( $lang = $this->language; $lang; $lang = $this->safeLangFallback( $lang ) ) { |
281 | | - if( isset( $guard[$lang] ) ) |
282 | | - break; // avoid loops... |
283 | | - $guard[$lang] = true; |
284 | | - if( $text = $this->getRawMessage( "$msg/$lang", $params ) ) { |
285 | | - return $text; |
286 | | - } |
287 | | - } |
288 | | - return $this->getRawMessage( $msg, $params ); |
289 | | - */ |
290 | | - array_unshift( $params, array( 'language' => $this->language ) ); |
291 | | - array_unshift( $params, $msg ); |
292 | | - return call_user_func_array( 'wfMsgExt', $params ); |
293 | | - } |
294 | | - |
295 | | - private function safeLangFallback( $lang ) { |
296 | | - $fallback = Language::getFallbackFor( $lang ); |
297 | | - if( $fallback == 'en' ) { |
298 | | - // We want to be able to special-case English |
299 | | - // This lets us put _regular_ English in 'blah' and special-case in 'blah/en' |
300 | | - return false; |
301 | | - } else { |
302 | | - return $fallback; |
303 | | - } |
304 | | - } |
305 | | - |
306 | | - private function getRawMessage( $msg, $params ) { |
307 | | - $searchPath = array( |
308 | | - "$msg/{$this->project}", |
309 | | - "$msg" ); |
310 | | - foreach( $searchPath as $rawMsg ) { |
311 | | - wfDebug( __METHOD__ . ": $rawMsg\n" ); |
312 | | - $xparams = array_merge( array( $rawMsg ), $params ); |
313 | | - wfDebug( __METHOD__ . ': ' . str_replace( "\n", " ", var_export( $xparams, true ) ) . "\n" ); |
314 | | - $text = call_user_func_array( 'wfMsgForContentNoTrans', |
315 | | - $xparams ); |
316 | | - if( !wfEmptyMsg( $rawMsg, $text ) ) { |
317 | | - return $text; |
318 | | - } |
319 | | - } |
320 | | - return false; |
321 | | - } |
322 | | - |
323 | | - /* |
324 | | - private function splitList( $text, $callback=false ) { |
325 | | - $list = array_filter( |
326 | | - array_map( |
327 | | - array( $this, 'filterListLine' ), |
328 | | - explode( "\n", $text ) ) ); |
329 | | - if( is_callable( $callback ) ) { |
330 | | - return array_map( $callback, $list ); |
331 | | - } else { |
332 | | - return $list; |
333 | | - } |
334 | | - } |
335 | | - |
336 | | - private function filterListLine( $line ) { |
337 | | - if( substr( $line, 0, 1 ) == '#' ) { |
338 | | - return ''; |
339 | | - } else { |
340 | | - return $this->parse( trim( ltrim( $line, '*' ) ) ); |
341 | | - } |
342 | | - } |
343 | | - */ |
344 | | - |
345 | | - private function parse( $text ) { |
346 | | - global $wgOut, $wgSitename; |
347 | | - |
348 | | - // A god-damned dirty hack! |
| 259 | + // A god-damned dirty hack! :D |
| 260 | + global $wgSitename; |
349 | 261 | $old = array(); |
350 | 262 | $old['wgSitename'] = $wgSitename; |
351 | 263 | $wgSitename = $this->projectName(); |
352 | 264 | |
353 | | - $out = preg_replace( |
354 | | - '/^<p>(.*)\n?<\/p>\n?$/sU', |
355 | | - '$1', |
356 | | - $wgOut->parse( $text ) ); |
| 265 | + $options = array( |
| 266 | + 'language' => $this->language, |
| 267 | + 'parsemag', |
| 268 | + ); |
| 269 | + array_unshift( $params, $options ); |
| 270 | + array_unshift( $params, $msg ); |
| 271 | + $out = call_user_func_array( 'wfMsgExt', $params ); |
357 | 272 | |
358 | 273 | // Restore globals |
359 | 274 | $wgSitename = $old['wgSitename']; |
| 275 | + |
360 | 276 | return $out; |
361 | 277 | } |
362 | 278 | |
— | — | @@ -440,19 +356,7 @@ |
441 | 357 | return ''; |
442 | 358 | } |
443 | 359 | } |
444 | | - |
445 | | - private function getSubheading() { |
446 | | - // Sigh... hack in another one real quick |
447 | | - return $this->parse( |
448 | | - $this->getMessage( 'centralnotice-subheading' ) ); |
449 | | - } |
450 | | - |
451 | | - private function getThanks() { |
452 | | - // Sigh... hack in another one real quick |
453 | | - return $this->parse( |
454 | | - $this->getMessage( 'centralnotice-thanks' ) ); |
455 | | - } |
456 | | - |
| 360 | + |
457 | 361 | private function getCachedRssEntry( $url ) { |
458 | 362 | global $wgMemc; |
459 | 363 | $key = 'centralnotice:rss:' . md5( $url ); |