From be40cca1317f40de05a8d7add6e9d03422234098 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 20 Jul 2010 09:23:37 +0000 Subject: [PATCH] Kill two functions in Parser that have been ununused forever, add a clarifying comment elsewhere. --- includes/parser/Parser.php | 98 +------------------------------------- 1 file changed, 1 insertion(+), 97 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 7d591b1b53..ca0087bff9 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3316,7 +3316,7 @@ class Parser { * Fetch the unparsed text of a template and register a reference to it. */ function fetchTemplateAndTitle( $title ) { - $templateCb = $this->mOptions->getTemplateCallback(); + $templateCb = $this->mOptions->getTemplateCallback(); # Defaults to Parser::statelessFetchTemplate() $stuff = call_user_func( $templateCb, $title, $this ); $text = $stuff['text']; $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title; @@ -4033,102 +4033,6 @@ class Parser { } } - /** - * Merge $tree2 into $tree1 by replacing the section with index - * $section in $tree1 and its descendants with the sections in $tree2. - * Note that in the returned section tree, only the 'index' and - * 'byteoffset' fields are guaranteed to be correct. - * - * @param $tree1 Array: section tree from ParserOutput::getSectons() - * @param $tree2 Array: section tree - * @param $section Integer: section index - * @param $title Title: Title both section trees come from - * @param $len2 Integer: length of the original wikitext for $tree2 - * @return Array: merged section tree - */ - public static function mergeSectionTrees( $tree1, $tree2, $section, $title, $len2 ) { - global $wgContLang; - $newTree = array(); - $targetLevel = false; - $merged = false; - $lastLevel = 1; - $nextIndex = 1; - $numbering = array( 0 ); - $titletext = $title->getPrefixedDBkey(); - foreach ( $tree1 as $s ) { - if ( $targetLevel !== false ) { - if ( $s['level'] <= $targetLevel ) { - # We've skipped enough - $targetLevel = false; - } else { - continue; - } - } - if ( $s['index'] != $section || - $s['fromtitle'] != $titletext ) { - self::incrementNumbering( $numbering, - $s['toclevel'], $lastLevel ); - - # Rewrite index, byteoffset and number - if ( $s['fromtitle'] == $titletext ) { - $s['index'] = $nextIndex++; - if ( $merged ) { - $s['byteoffset'] += $len2; - } - } - $s['number'] = implode( '.', array_map( - array( $wgContLang, 'formatnum' ), - $numbering ) ); - $lastLevel = $s['toclevel']; - $newTree[] = $s; - } else { - # We're at $section - # Insert sections from $tree2 here - foreach ( $tree2 as $s2 ) { - # Rewrite the fields in $s2 - # before inserting it - $s2['toclevel'] += $s['toclevel'] - 1; - $s2['level'] += $s['level'] - 1; - $s2['index'] = $nextIndex++; - $s2['byteoffset'] += $s['byteoffset']; - - self::incrementNumbering( $numbering, - $s2['toclevel'], $lastLevel ); - $s2['number'] = implode( '.', array_map( - array( $wgContLang, 'formatnum' ), - $numbering ) ); - $lastLevel = $s2['toclevel']; - $newTree[] = $s2; - } - # Skip all descendants of $section in $tree1 - $targetLevel = $s['level']; - $merged = true; - } - } - return $newTree; - } - - /** - * Increment a section number. Helper function for mergeSectionTrees() - * - * @param $number Array representing a section number - * @param $level Integer: current TOC level (depth) - * @param $lastLevel Integer: level of previous TOC entry - */ - private static function incrementNumbering( &$number, $level, $lastLevel ) { - if ( $level > $lastLevel ) { - $number[$level - 1] = 1; - } elseif ( $level < $lastLevel ) { - foreach ( $number as $key => $unused ) - if ( $key >= $level ) { - unset( $number[$key] ); - } - $number[$level - 1]++; - } else { - $number[$level - 1]++; - } - } - /** * Transform wiki markup when saving a page by doing \r\n -> \n * conversion, substitting signatures, {{subst:}} templates, etc. -- 2.20.1