r67820 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67819‎ | r67820 | r67821 >
Date:15:16, 10 June 2010
Author:daniel
Status:ok (Comments)
Tags:
Comment:
added newPartNodeArray for creating a node with a list of parts form a php array; useful for programatically constructing template parameters
Modified paths:
  • /trunk/phase3/includes/parser/Preprocessor_Hash.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Preprocessor_Hash.php
@@ -23,6 +23,33 @@
2424 return new PPCustomFrame_Hash( $this, $args );
2525 }
2626
 27+ function newPartNodeArray( $values ) {
 28+ $list = array();
 29+
 30+ foreach ( $values as $k => $val ) {
 31+ $partNode = new PPNode_Hash_Tree( 'part' );
 32+ $nameNode = new PPNode_Hash_Tree( 'name' );
 33+
 34+ if ( is_int( $k ) ) {
 35+ $nameNode->addChild( new PPNode_Hash_Attr( 'index', $k ) );
 36+ $partNode->addChild( $nameNode );
 37+ } else {
 38+ $nameNode->addChild( new PPNode_Hash_Text( $k ) );
 39+ $partNode->addChild( $nameNode );
 40+ $partNode->addChild( new PPNode_Hash_Text( '=' ) );
 41+ }
 42+
 43+ $valueNode = new PPNode_Hash_Tree( 'value' );
 44+ $valueNode->addChild( new PPNode_Hash_Text( $val ) );
 45+ $partNode->addChild( $valueNode );
 46+
 47+ $list[] = $partNode;
 48+ }
 49+
 50+ $node = new PPNode_Hash_Array( $list );
 51+ return $node;
 52+ }
 53+
2754 /**
2855 * Preprocess some wikitext and return the document tree.
2956 * This is the ghost of Parser::replace_variables().

Follow-up revisions

RevisionCommit summaryAuthorDate
r67821follow-up to r67820 and r67819: interface function newPartNodeArray for creat...daniel15:18, 10 June 2010

Comments

#Comment by Duesentrieb (talk | contribs)   13:32, 15 July 2010

needed by DataTransclusion extension

Status & tagging log