Index: trunk/phase3/includes/parser/Preprocessor_DOM.php |
— | — | @@ -29,6 +29,30 @@ |
30 | 30 | return new PPCustomFrame_DOM( $this, $args ); |
31 | 31 | } |
32 | 32 | |
| 33 | + function newPartNodeArray( $values ) { |
| 34 | + //NOTE: DOM manipulation is slower than building & parsing XML! (or so Tim sais) |
| 35 | + $xml = ""; |
| 36 | + $xml .= "<list>"; |
| 37 | + |
| 38 | + foreach ( $values as $k => $val ) { |
| 39 | + |
| 40 | + if ( is_int( $k ) ) { |
| 41 | + $xml .= "<part><name index=\"$k\"/><value>" . htmlspecialchars( $val ) ."</value></part>"; |
| 42 | + } else { |
| 43 | + $xml .= "<part><name>" . htmlspecialchars( $k ) . "</name>=<value>" . htmlspecialchars( $val ) . "</value></part>"; |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + $xml .= "</list>"; |
| 48 | + |
| 49 | + $dom = new DOMDocument(); |
| 50 | + $dom->loadXML( $xml ); |
| 51 | + $root = $dom->documentElement; |
| 52 | + |
| 53 | + $node = new PPNode_DOM( $root->childNodes ); |
| 54 | + return $node; |
| 55 | + } |
| 56 | + |
33 | 57 | function memCheck() { |
34 | 58 | if ( $this->memoryLimit === false ) { |
35 | 59 | return; |