Index: trunk/phase3/includes/Parser.php |
— | — | @@ -1524,6 +1524,31 @@ |
1525 | 1525 | return $text; |
1526 | 1526 | } |
1527 | 1527 | |
| 1528 | + # Split template arguments |
| 1529 | + function getTemplateArgs( $argsString ) { |
| 1530 | + if ( $argsString === '' ) { |
| 1531 | + return array(); |
| 1532 | + } |
| 1533 | + |
| 1534 | + $args = explode( '|', substr( $argsString, 1 ) ); |
| 1535 | + |
| 1536 | + # If any of the arguments contains a '[[' but no ']]', it needs to be |
| 1537 | + # merged with the next arg because the '|' character between belongs |
| 1538 | + # to the link syntax and not the template parameter syntax. |
| 1539 | + $argc = count($args); |
| 1540 | + $i = 0; |
| 1541 | + for ( $i = 0; $i < $argc-1; $i++ ) { |
| 1542 | + if ( substr_count ( $args[$i], "[[" ) != substr_count ( $args[$i], "]]" ) ) { |
| 1543 | + $args[$i] .= "|".$args[$i+1]; |
| 1544 | + array_splice($args, $i+1, 1); |
| 1545 | + $i--; |
| 1546 | + $argc--; |
| 1547 | + } |
| 1548 | + } |
| 1549 | + |
| 1550 | + return $args; |
| 1551 | + } |
| 1552 | + |
1528 | 1553 | function braceSubstitution( $matches ) { |
1529 | 1554 | global $wgLinkCache, $wgLang; |
1530 | 1555 | $fname = 'Parser::braceSubstitution'; |
— | — | @@ -1540,11 +1565,8 @@ |
1541 | 1566 | $newline = $matches[1]; |
1542 | 1567 | $part1 = $matches[2]; |
1543 | 1568 | # If the third subpattern matched anything, it will start with | |
1544 | | - if ( $matches[3] !== '' ) { |
1545 | | - $args = explode( '|', substr( $matches[3], 1 ) ); |
1546 | | - } else { |
1547 | | - $args = array(); |
1548 | | - } |
| 1569 | + |
| 1570 | + $args = $this->getTemplateArgs($matches[3]); |
1549 | 1571 | $argc = count( $args ); |
1550 | 1572 | |
1551 | 1573 | # {{{}}} |