Extension:Hierarchy/Hierarchy1.2.0.php

@s'; if (!preg_match($pattern, $html_text, $matches, PREG_OFFSET_CAPTURE, $offset)) { return $html_text; }		$toc = $matches[0][0]; $offset = $matches[0][1];

// change TOC title $pattern = '@(.*?)@'; $replacement = '$1'. $root_page_link. '$3';		$toc = preg_replace ($pattern, $replacement, $toc, 1);

// change TOC links $pattern = '@ (.*?) (.*?) @'; do { $topic_found = preg_match($pattern, $toc, $matches, PREG_OFFSET_CAPTURE); if ($topic_found) { $item_text = $matches[4][0]; $title = Title::newFromText($item_text); $page_url = $title->escapeLocalURL; $url_position = $matches[2][1]; $url_length = strlen($matches[2][0]); $toc = substr_replace($toc, $page_url, $url_position, $url_length); }		} while ($topic_found);

// return HTML output return $toc; }	function Save($text, $article, $user, $root_text, $deslash) { $article_id = $article->getID; if ($article_id) { // Verify that the page has been saved at least once $this->EraseInformation($article_id); $parsed_text = $this->Render($text, $article->mTitle, new ParserOptions($user), $root_text, $deslash); $this->SaveIndex($parsed_text, $article_id, $root_text, $deslash); }	}

// Erases information about this hierarchy in the database. function EraseInformation($index_article_id) { $fname = 'Hierarchy::EraseInformation'; $dbw =& wfGetDB( DB_MASTER ); $dbw->delete('hierarchy',			array( 'IndexArticleId' => $index_article_id, ), $fname		); }

function SaveIndex($text, $index_article_id, $root_text, $deslash) { // get hierarchy root $offset = 0; $pattern = '@