New magic word __TOC__ that inserts the toc at the place it is found
authorGabriel Wicke <gwicke@users.mediawiki.org>
Tue, 29 Jun 2004 23:59:30 +0000 (23:59 +0000)
committerGabriel Wicke <gwicke@users.mediawiki.org>
Tue, 29 Jun 2004 23:59:30 +0000 (23:59 +0000)
Implies __FORCETOC__

includes/MagicWord.php
includes/Parser.php
languages/Language.php

index bb7b7c1..33b8f09 100644 (file)
@@ -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,
index 54b7c27..8a24bf1 100644 (file)
@@ -120,6 +120,7 @@ class Parser
                                '/ (\\?|:|!|\\302\\273)/i' => '&nbsp;\\1', 
                                # french spaces, Guillemet-right
                                '/(\\302\\253) /i' => '\\1&nbsp;', 
+                               '/([^> ]+(&#x30(1|3|9);)[^< ]*)/i' => '<span class="diacrit">\\1</span>', 
                                '/<center *>/i' => '<div class="center">',
                                '/<\\/center *>/i' => '</div>'
                        );
@@ -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
index afae893..e360e8f 100644 (file)
@@ -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',