Index: trunk/extensions/News/NewsRenderer.php |
— | — | @@ -444,7 +444,7 @@ |
445 | 445 | |
446 | 446 | $title = Title::makeTitle( $row->rc_namespace, $row->rc_title ); //XXX: this is redundant, we already have a title object in renderRow. But no good way to pass it :( |
447 | 447 | |
448 | | - if ($this->publication) { |
| 448 | + if ( $this->publication || $row->rc_new ) { |
449 | 449 | $name = $title->getPrefixedText(); |
450 | 450 | } |
451 | 451 | else { |
— | — | @@ -541,18 +541,38 @@ |
542 | 542 | // and extension tags from templates are stripped properly |
543 | 543 | // this doesn't work though: $t = $this->templateparser->preprocess( $t, $this->title, new ParserOptions() ); |
544 | 544 | //TODO: avoid magic categories, interwiki-links, etc |
545 | | - $params['content'] = NewsRenderer::sanitizeWikiText( $t ); |
| 545 | + $params['content'] = NewsRenderer::sanitizeWikiText( $t, $this->templateparser ); |
546 | 546 | |
547 | 547 | if ( stripos($templatetext, '{{{head}}}')!==false ) { |
548 | 548 | $params['head'] = NewsRenderer::extractHead( $params['content'], $title ); |
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | | - $text = $this->templateparser->replaceVariables( $templatetext, $params ); |
| 552 | + $text = NewsRenderer::replaceVariables( $this->templateparser, $templatetext, $params, $this->title ); |
553 | 553 | return $text; |
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
| 557 | + static function replaceVariables($parser, $text, $params = NULL, $title = NULL) { |
| 558 | + global $wgVersion; |
| 559 | + |
| 560 | + if ( $params === NULL ) $params = array(); |
| 561 | + $text = $parser->replaceVariables( $text, $params ); |
| 562 | + |
| 563 | + /* |
| 564 | + if ( version_compare( $wgVersion, "1.12", '<' ) ) { |
| 565 | + } |
| 566 | + else { |
| 567 | + $parser = $GLOBALS['wgParser']; |
| 568 | + |
| 569 | + $frame = $parser->getPreprocessor()->newCustomFrame($params); |
| 570 | + $text = $parser->replaceVariables( $text, $frame ); |
| 571 | + } |
| 572 | + */ |
| 573 | + |
| 574 | + return $text; |
| 575 | + } |
| 576 | + |
557 | 577 | /* |
558 | 578 | function renderFeedMetaLink( $format ) { |
559 | 579 | $format = strtolower(trim($format)); |
— | — | @@ -594,7 +614,7 @@ |
595 | 615 | |
596 | 616 | static function renderFeedLink( $text, $argv, &$parser ) { |
597 | 617 | $t = @$argv['feed']; |
598 | | - if ($t) $t = $parser->replaceVariables($t, array()); |
| 618 | + if ($t) $t = NewsRenderer::replaceVariables( $parser, $t ); |
599 | 619 | |
600 | 620 | $title = $t === NULL ? NULL : Title::newFromText($t); |
601 | 621 | if (!$title) $title = $GLOBALS['wgTitle']; |
— | — | @@ -628,7 +648,7 @@ |
629 | 649 | $url = NewsRenderer::getFeedURL($title, $format); |
630 | 650 | |
631 | 651 | $ttl = @$argv['title']; |
632 | | - if ($ttl) $ttl = $parser->replaceVariables($ttl, array()); |
| 652 | + if ($ttl) $ttl = NewsRenderer::replaceVariables( $parser, $ttl ); |
633 | 653 | |
634 | 654 | $s = ''; |
635 | 655 | if ($text) { |
— | — | @@ -664,14 +684,14 @@ |
665 | 685 | return $row[0]; |
666 | 686 | } |
667 | 687 | |
668 | | - static function sanitizeWikiText( $text ) { |
669 | | - global $wgParser; |
| 688 | + static function sanitizeWikiText( $text, $parser = NULL ) { |
| 689 | + if ( !$parser ) $parser = $GLOBALS['wgParser']; |
670 | 690 | |
671 | | - $elements = array_keys( $wgParser->mTagHooks ); |
| 691 | + $elements = array_keys( $parser->mTagHooks ); |
672 | 692 | $uniq_prefix = "\x07NR-UNIQ"; |
673 | 693 | |
674 | 694 | $matches = array(); |
675 | | - $text = Parser::extractTagsAndParams( $elements, $text, $matches, $uniq_prefix ); |
| 695 | + $text = $parser->extractTagsAndParams( $elements, $text, $matches, $uniq_prefix ); |
676 | 696 | |
677 | 697 | foreach( $matches as $marker => $data ) { |
678 | 698 | list( $element, $content, $params, $tag ) = $data; |