Jump to content

Extension talk:Hierarchy/Hierarchy1.2.0.php

Add topic
From mediawiki.org
Latest comment: 13 years ago by Hypergrove in topic $root_text not processed

Any chance this version of the extension works with the followings versions:

MediaWiki 1.16.0 PHP 5.3.3 (apache2handler) MySQL 5.1.51-log

I attempted to use the older version, but got the following error:

Detected bug in an extension! Hook fnHierarchySaveHook failed to return a value; should return true to continue hook processing or false to abort.

Any clue what may be causing this and/or do you think your newer version would correct it?

Thanks for any help you can give me.

$root_text not processed

[edit]

Strange but 1.2 does not process the $root_text variable, so the root= parameter does not work as advertised. I added the following code to the Render() method which is called in two places.

	function Render($input, $title, $options, $root_text, $deslash) {
		// preprocess text 
		if( $root_text && strlen($root_text)>0 ) {
			// change TOC title
			$pattern = '@\[\[( *)(.*?)\|(.*?)\]\]@s';
			$replacement = '[[$1' . $root_text . '$2|$3]]';
			$input = preg_replace ($pattern, $replacement, $input, 1);
			// change TOC links
			$pattern = '@(\=+ *)([^\'"\=\n]+)(\=+)@';
			$replacement = '$1' . $root_text . '$2$3';
			$input = preg_replace ($pattern, $replacement, $input);
		}
		// parse text
		$localParser = new Parser();

--Hypergrove 01:31, 30 August 2011 (UTC)Reply