Fz-29 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/367808 )

Change subject: Make static function of CargoHierarchy suitable for extending 
the class
......................................................................

Make static function of CargoHierarchy suitable for extending the class

Change-Id: Ie38c8ce4f6cdc87edb3fa86476504fbf0cf77113
---
M CargoHierarchy.php
1 file changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/08/367808/1

diff --git a/CargoHierarchy.php b/CargoHierarchy.php
index 983008c..18caaf8 100644
--- a/CargoHierarchy.php
+++ b/CargoHierarchy.php
@@ -30,7 +30,7 @@
        public static function newFromWikiText( $wikitext ) {
                // A dummy node (__pseudo_root__ is added so that
                // multiple nodes can be added in the first level
-               $fullTree = new CargoHierarchy();
+               $fullTree = new static();
                $lines = explode( "\n", $wikitext );
                foreach ( $lines as $line ) {
                        $numBullets = 0;
@@ -40,8 +40,9 @@
                        if ( $numBullets == 0 ) continue;
                        $lineText = trim( substr( $line, $numBullets ) );
                        $curParentNode = $fullTree->getLastNodeForLevel( 
$numBullets );
-                       $curParentNode->addChild( new CargoHierarchy( $lineText 
) );
+                       $curParentNode->addChild( new static( $lineText ) );
                }
+               $fullTree->computeLeftRight();
                return $fullTree;
        }
 
@@ -55,18 +56,17 @@
 
        function generateHierarchyStructureTableData() {
                $tableData = array();
-               $this->computeLeftRight();
                //  Preorder traversal using Stack data structure
                $stack = new SplStack();
                $stack->push( $this );
-               while( !$stack->isEmpty() ) {
+               while ( !$stack->isEmpty() ) {
                        $node = $stack->pop();
                        $row = array();
                        $row['_value'] = $node->mTitle;
                        $row['_left'] = $node->mLeft;
                        $row['_right'] = $node->mRight;
                        $tableData[] = $row;
-                       foreach( array_reverse( $node->mChildren ) as $child ) {
+                       foreach ( array_reverse( $node->mChildren ) as $child ) 
{
                                $stack->push( $child );
                        }
                }
@@ -77,7 +77,7 @@
                $this->mLeft = $counter;
                $counter += 1;
                //  Visit mChildren of the current node
-               foreach( $this->mChildren as $child ) {
+               foreach ( $this->mChildren as $child ) {
                        $child->computeLeftRight( $counter );
                }
                $this->mRight = $counter;

-- 
To view, visit https://gerrit.wikimedia.org/r/367808
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie38c8ce4f6cdc87edb3fa86476504fbf0cf77113
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Fz-29 <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to