Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -2799,18 +2799,14 @@ |
2800 | 2800 | wfProfileIn( __METHOD__.'-modifiers' ); |
2801 | 2801 | if ( !$found ) { |
2802 | 2802 | |
2803 | | - $substMatch = $this->mSubsts->matchVariableStartToEnd( $part1 ); |
| 2803 | + $substMatch = $this->mSubsts->matchStartAndRemove( $part1 ); |
2804 | 2804 | |
2805 | | - # Possibilities for substMatch[0]: "subst", "safesubst" or FALSE |
| 2805 | + # Possibilities for substMatch: "subst", "safesubst" or FALSE |
2806 | 2806 | # Whether to include depends also on whether we are in the pre-save-transform |
2807 | 2807 | # |
2808 | | - # safesubst || (subst && PST) => transclude (handled by if) |
2809 | | - # (false && PST) || (subst && !PST) => return input (handled by else if) |
2810 | | - # false && !PST => transclude (no handling needed here) |
2811 | | - if ( $substMatch[0] && ( $this->ot['wiki'] || $substMatch[0] == 'safesubst' ) ) { |
2812 | | - $part1 = $substMatch[1]; |
2813 | | - |
2814 | | - } else if ( $substMatch[0] xor $this->ot['wiki'] ) { |
| 2808 | + # safesubst || (subst && PST) || (false && !PST) => transclude (skip the if) |
| 2809 | + # (false && PST) || (subst && !PST) => return input (handled by if) |
| 2810 | + if ( $substMatch != 'safesubst' && ($substMatch == 'subst' xor $this->ot['wiki']) ) { |
2815 | 2811 | $text = $frame->virtualBracketedImplode( '{{', '|', '}}', $titleWithSpaces, $args ); |
2816 | 2812 | $isLocalObj = true; |
2817 | 2813 | $found = true; |
Index: trunk/phase3/includes/MagicWord.php |
— | — | @@ -594,6 +594,21 @@ |
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
| 598 | + * Get a regex for matching a prefix. Does not match parameters. |
| 599 | + */ |
| 600 | + function getRegexStart() { |
| 601 | + $base = $this->getBaseRegex(); |
| 602 | + $newRegex = array( '', '' ); |
| 603 | + if ( $base[0] !== '' ) { |
| 604 | + $newRegex[0] = str_replace( "\\$1", "", "/^(?:{$base[0]})/iuS" ); |
| 605 | + } |
| 606 | + if ( $base[1] !== '' ) { |
| 607 | + $newRegex[1] = str_replace( "\\$1", "", "/^(?:{$base[1]})/S" ); |
| 608 | + } |
| 609 | + return $newRegex; |
| 610 | + } |
| 611 | + |
| 612 | + /** |
598 | 613 | * Get an anchored regex for matching variables |
599 | 614 | */ |
600 | 615 | function getVariableStartToEndRegex() { |
— | — | @@ -691,4 +706,24 @@ |
692 | 707 | } |
693 | 708 | return $found; |
694 | 709 | } |
| 710 | + |
| 711 | + /** |
| 712 | + * Returns the magic word id removed from the start, or false |
| 713 | + * does not match parameters. |
| 714 | + */ |
| 715 | + public function matchStartAndRemove( &$text ) { |
| 716 | + $found = FALSE; |
| 717 | + $regexes = $this->getRegexStart(); |
| 718 | + foreach ( $regexes as $regex ) { |
| 719 | + if ( $regex === '' ) { |
| 720 | + continue; |
| 721 | + } |
| 722 | + preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ); |
| 723 | + foreach ( $matches as $m ) { |
| 724 | + list( $found, $param ) = $this->parseMatch( $m ); |
| 725 | + } |
| 726 | + $text = preg_replace( $regex, '', $text ); |
| 727 | + } |
| 728 | + return $found; |
| 729 | + } |
695 | 730 | } |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -264,8 +264,8 @@ |
265 | 265 | 'subjectpagename' => array( 1, 'SUBJECTPAGENAME', 'ARTICLEPAGENAME' ), |
266 | 266 | 'subjectpagenamee' => array( 1, 'SUBJECTPAGENAMEE', 'ARTICLEPAGENAMEE' ), |
267 | 267 | 'msg' => array( 0, 'MSG:' ), |
268 | | - 'subst' => array( 0, 'SUBST:$1' ), |
269 | | - 'safesubst' => array( 0, 'SAFESUBST:$1' ), |
| 268 | + 'subst' => array( 0, 'SUBST:' ), |
| 269 | + 'safesubst' => array( 0, 'SAFESUBST:' ), |
270 | 270 | 'msgnw' => array( 0, 'MSGNW:' ), |
271 | 271 | 'img_thumbnail' => array( 1, 'thumbnail', 'thumb' ), |
272 | 272 | 'img_manualthumb' => array( 1, 'thumbnail=$1', 'thumb=$1'), |