From: Daniel Kinzler Date: Thu, 10 Jun 2010 15:02:25 +0000 (+0000) Subject: added newPartNodeArray for creating a node with a list of parts form a php array... X-Git-Tag: 1.31.0-rc.0~36551 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=1258dc326897c52a4512aabc5bb35352af52f1c5;p=lhc%2Fweb%2Fwiklou.git added newPartNodeArray for creating a node with a list of parts form a php array; useful for programatically constructing template parameters --- diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 625dc8a801..1dc1a173f7 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -29,6 +29,30 @@ class Preprocessor_DOM implements Preprocessor { return new PPCustomFrame_DOM( $this, $args ); } + function newPartNodeArray( $values ) { + //NOTE: DOM manipulation is slower than building & parsing XML! (or so Tim sais) + $xml = ""; + $xml .= ""; + + foreach ( $values as $k => $val ) { + + if ( is_int( $k ) ) { + $xml .= "" . htmlspecialchars( $val ) .""; + } else { + $xml .= "" . htmlspecialchars( $k ) . "=" . htmlspecialchars( $val ) . ""; + } + } + + $xml .= ""; + + $dom = new DOMDocument(); + $dom->loadXML( $xml ); + $root = $dom->documentElement; + + $node = new PPNode_DOM( $root->childNodes ); + return $node; + } + function memCheck() { if ( $this->memoryLimit === false ) { return;