From 1258dc326897c52a4512aabc5bb35352af52f1c5 Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Thu, 10 Jun 2010 15:02:25 +0000 Subject: [PATCH] added newPartNodeArray for creating a node with a list of parts form a php array; useful for programatically constructing template parameters --- includes/parser/Preprocessor_DOM.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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; -- 2.20.1