From: Gabriel Wicke Date: Tue, 29 Jun 2004 23:59:30 +0000 (+0000) Subject: New magic word __TOC__ that inserts the toc at the place it is found X-Git-Tag: 1.5.0alpha1~2739 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=944b87264659593ec83a3b4acf7b3cf8aa3a61e0;p=lhc%2Fweb%2Fwiklou.git New magic word __TOC__ that inserts the toc at the place it is found Implies __FORCETOC__ --- diff --git a/includes/MagicWord.php b/includes/MagicWord.php index bb7b7c1640..33b8f09332 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -45,6 +45,7 @@ define("MAG_SERVER", 28); define("MAG_IMG_FRAMED", 29); define("MAG_PAGENAME", 30); define("MAG_NAMESPACE", 31); +define("MAG_TOC", 32); $wgVariableIDs = array( MAG_CURRENTMONTH, diff --git a/includes/Parser.php b/includes/Parser.php index 54b7c27226..8a24bf178a 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -120,6 +120,7 @@ class Parser '/ (\\?|:|!|\\302\\273)/i' => ' \\1', # french spaces, Guillemet-right '/(\\302\\253) /i' => '\\1 ', + '/([^> ]+(0(1|3|9);)[^< ]*)/i' => '\\1', '/
/i' => '
', '/<\\/center *>/i' => '
' ); @@ -1823,6 +1824,7 @@ cl_sortkey" ; $doNumberHeadings = $this->mOptions->getNumberHeadings(); $doShowToc = $this->mOptions->getShowToc(); + $forceTocHere = false; if( !$this->mTitle->userCanEdit() ) { $showEditLink = 0; $rightClickHack = 0; @@ -1858,12 +1860,21 @@ cl_sortkey" ; $doShowToc = 0; } - # if the string __FORCETOC__ (not case-sensitive) occurs in the HTML, - # override above conditions and always show TOC - $mw =& MagicWord::get( MAG_FORCETOC ); - if ($mw->matchAndRemove( $text ) ) { + # if the string __TOC__ (not case-sensitive) occurs in the HTML, + # override above conditions and always show TOC at that place + $mw =& MagicWord::get( MAG_TOC ); + if ($mw->match( $text ) ) { $doShowToc = 1; + $forceTocHere = true; + } else { + # if the string __FORCETOC__ (not case-sensitive) occurs in the HTML, + # override above conditions and always show TOC above first header + $mw =& MagicWord::get( MAG_FORCETOC ); + if ($mw->matchAndRemove( $text ) ) { + $doShowToc = 1; + } } + # We need this to perform operations on the HTML @@ -1993,7 +2004,7 @@ cl_sortkey" ; # $full .= $sk->editSectionLink(0); } $full .= $block; - if( $doShowToc && !$i && $isMain) { + if( $doShowToc && !$i && $isMain && !$forceTocHere) { # Top anchor now in skin $full = $full.$toc; } @@ -2003,8 +2014,12 @@ cl_sortkey" ; } $i++; } - - return $full; + if($forceTocHere) { + $mw =& MagicWord::get( MAG_TOC ); + return $mw->replace( $toc, $full ); + } else { + return $full; + } } # Return an HTML link for the "ISBN 123456" text diff --git a/languages/Language.php b/languages/Language.php index afae893a8d..e360e8f12d 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -154,6 +154,7 @@ $wgLanguageNamesEn =& $wgLanguageNames; MAG_REDIRECT => array( 0, '#redirect' ), MAG_NOTOC => array( 0, '__NOTOC__' ), MAG_FORCETOC => array( 0, '__FORCETOC__' ), + MAG_TOC => array( 0, '__TOC__' ), MAG_NOEDITSECTION => array( 0, '__NOEDITSECTION__' ), MAG_START => array( 0, '__START__' ), MAG_CURRENTMONTH => array( 1, 'CURRENTMONTH' ), @@ -696,7 +697,7 @@ See [[{{ns:4}}:User preferences help]] for help deciphering the options.", 'oldpassword' => 'Old password', 'newpassword' => 'New password', 'retypenew' => 'Retype new password', -'textboxsize' => 'Textbox dimensions', +'textboxsize' => 'Editing', 'rows' => 'Rows', 'columns' => 'Columns', 'searchresultshead' => 'Search result settings',