7 September 2007

From Organic Design wiki
Warning.svg This is a blog item that needs to be converted to the new Bliki format


Testing TreeView4

The Tree view extension has been upgraded today from version 3.6.1 to 4.0.1. The core code has been re-written in the new version to include special voodoo techniques to overcome a long standing bug preventing articles containing trees from able to be transcluded unless they're transcluded into another tree. The new version appears to execute a little faster too, but I'll test it for a while before making the new version official on the MediaWiki site. Let me know if you notice any problems with any of the trees here on OrganicDesign as we're now using the new version.

The main voodoo is the following bit of code which allows the recursive tree stuff to work even though there's no way to determine the transclusion depth from MediaWiki's parser environment. I understood the voodoo enough to get it working by combining it with some minor hacks, some trial-and-error, some perserverence and some luck ;-) <php> $text = $this->uniq[$id] = preg_replace( '/^\\*(\\**)\\s*(.UNIQ.+?-treeview4(.+?)-.+?-QINU)/me', '$this->uniq["$3"] ? preg_replace("/^(\\*+)/m","$1\$1",$this->uniq["$3"]) : "$1$2"', $text ); </php>