This is a minimal change to add a new magic token that prevents
numbering of the TOC and to do the same when the user option "Auto-number
headings" under "Misc" in "Preferences" is set. This option is
already
retrieved through $this->mOptions->getNumberHeadings(); but currently not
used effectively.
The token directive is useful because some sections in a wiki may already
include numbering as part of the heading and suppressing auto-numbering is
useful in those cases.
Index: includes/Parser.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/Parser.php,v
retrieving revision 1.509
diff -u -r1.509 Parser.php
--- includes/Parser.php 23 Sep 2005 12:10:39 -0000 1.509
+++ includes/Parser.php 24 Sep 2005 12:57:48 -0000
@@ -2461,8 +2461,15 @@
*/
function formatHeadings( $text, $isMain=true ) {
global $wgMaxTocLevel, $wgContLang, $wgLinkHolders, $wgInterwikiLinkHolders;
-
- $doNumberHeadings = $this->mOptions->getNumberHeadings();
+
+ # if the string __NOTOCNUM__ (not case-sensitive) occurs in the HTML,
+ # or if the user prefers not to, do not add TOC Numbering
+ $mw =& MagicWord::get( MAG_NOTOCNUM );
+ if( $mw->matchAndRemove( $text ) ) {
+ $doNumberHeadings = false;
+ } else {
+ $doNumberHeadings = $this->mOptions->getNumberHeadings();
+ }
$doShowToc = true;
$forceTocHere = false;
if( !$this->mTitle->userCanEdit() ) {
@@ -2647,7 +2654,7 @@
$anchor .= '_' . $refcount[$headlineCount];
}
if( $doShowToc && ( !isset($wgMaxTocLevel) || $toclevel<$wgMaxTocLevel ) )
{
- $toc .= $sk->tocLine($anchor, $tocline, $numbering, $toclevel);
+ $toc .= $sk->tocLine($anchor, $tocline, $doNumberHeadings?$numbering:'',
$toclevel);
}
if( $showEditLink && ( !$istemplate || $templatetitle !== "" ) ) {
if ( empty( $head[$headlineCount] ) ) {
Index: languages/Language.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/languages/Language.php,v
retrieving revision 1.684
diff -u -r1.684 Language.php
--- languages/Language.php 23 Sep 2005 12:10:39 -0000 1.684
+++ languages/Language.php 24 Sep 2005 12:58:06 -0000
@@ -190,6 +190,7 @@
# ID CASE SYNONYMS
MAG_REDIRECT => array( 0, '#redirect' ),
MAG_NOTOC => array( 0, '__NOTOC__' ),
+ MAG_NOTOCNUM => array( 0, '__NOTOCNUM__' ),
MAG_FORCETOC => array( 0, '__FORCETOC__' ),
MAG_TOC => array( 0, '__TOC__' ),
MAG_NOEDITSECTION => array( 0, '__NOEDITSECTION__' ),
--
http://members.dodo.com.au/~netocrat