Index: trunk/phase3/includes/Parser.php |
— | — | @@ -1710,6 +1710,13 @@ |
1711 | 1711 | if ( !$found ) { |
1712 | 1712 | return $matches[0]; |
1713 | 1713 | } else { |
| 1714 | + # replace ==section headers== |
| 1715 | + # XXX this needs to go away once we have a better parser. |
| 1716 | + for ( $i = 1; $i <= 6; ++$i ) { |
| 1717 | + $h = substr( '======', 0, $i ); |
| 1718 | + $text = preg_replace( "/^{$h}([^=].*){$h}\\s?$/m", |
| 1719 | + "${h}\\1 __MWTEMPLATESECTION__${h}\\2", $text ); |
| 1720 | + } |
1714 | 1721 | return $text; |
1715 | 1722 | } |
1716 | 1723 | } |
— | — | @@ -1973,6 +1980,7 @@ |
1974 | 1981 | |
1975 | 1982 | # headline counter |
1976 | 1983 | $headlineCount = 0; |
| 1984 | + $sectionCount = 0; # headlineCount excluding template sections |
1977 | 1985 | |
1978 | 1986 | # Ugh .. the TOC should have neat indentation levels which can be |
1979 | 1987 | # passed to the skin functions. These are determined here |
— | — | @@ -1984,6 +1992,11 @@ |
1985 | 1993 | $level = 0; |
1986 | 1994 | $prevlevel = 0; |
1987 | 1995 | foreach( $matches[3] as $headline ) { |
| 1996 | + $istemplate = 0; |
| 1997 | + if (strstr($headline, "__MWTEMPLATESECTION__")) { |
| 1998 | + $istemplate = 1; |
| 1999 | + $headline = str_replace("__MWTEMPLATESECTION__", "", $headline); |
| 2000 | + } |
1988 | 2001 | $numbering = ''; |
1989 | 2002 | if( $level ) { |
1990 | 2003 | $prevlevel = $level; |
— | — | @@ -2064,22 +2077,24 @@ |
2065 | 2078 | if( $doShowToc && ( !isset($wgMaxTocLevel) || $toclevel<$wgMaxTocLevel ) ) { |
2066 | 2079 | $toc .= $sk->tocLine($anchor,$tocline,$toclevel); |
2067 | 2080 | } |
2068 | | - if( $showEditLink ) { |
| 2081 | + if( $showEditLink && !$istemplate ) { |
2069 | 2082 | if ( empty( $head[$headlineCount] ) ) { |
2070 | 2083 | $head[$headlineCount] = ''; |
2071 | 2084 | } |
2072 | | - $head[$headlineCount] .= $sk->editSectionLink($headlineCount+1); |
| 2085 | + $head[$headlineCount] .= $sk->editSectionLink($sectionCount+1); |
2073 | 2086 | } |
2074 | 2087 | |
2075 | 2088 | # Add the edit section span |
2076 | 2089 | if( $rightClickHack ) { |
2077 | | - $headline = $sk->editSectionScript($headlineCount+1,$headline); |
| 2090 | + $headline = $sk->editSectionScript($sectionCount+1,$headline); |
2078 | 2091 | } |
2079 | 2092 | |
2080 | 2093 | # give headline the correct <h#> tag |
2081 | 2094 | @$head[$headlineCount] .= "<a name=\"$anchor\"></a><h".$level.$matches[2][$headlineCount] .$headline.'</h'.$level.'>'; |
2082 | 2095 | |
2083 | 2096 | $headlineCount++; |
| 2097 | + if( !$istemplate ) |
| 2098 | + $sectionCount++; |
2084 | 2099 | } |
2085 | 2100 | |
2086 | 2101 | if( $doShowToc ) { |