Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321219

Change subject: Depth limits
......................................................................

Depth limits

Change-Id: If3971637e909923eb9b6be6a50c282e0529f0fab
---
M src/Tree.php
M src/Util.php
2 files changed, 33 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/19/321219/1

diff --git a/src/Tree.php b/src/Tree.php
index 9222ec9..3aaa034 100644
--- a/src/Tree.php
+++ b/src/Tree.php
@@ -21,23 +21,44 @@
        /** @var integer */
        protected $descendant_depth;
 
+       /**
+        * Set the number of levels the tree will go up to from the ancestors' 
starting points.
+        * @param integer $ancestor_depth
+        */
        public function setAncestorDepth( $ancestor_depth ) {
                $this->ancestor_depth = $ancestor_depth;
        }
 
+       /**
+        * Set the number of levels the tree will go down to from the 
descendants' starting points.
+        * @param integer $descendant_depth
+        */
        public function setDescendantDepth( $descendant_depth ) {
                $this->descendant_depth = $descendant_depth;
        }
 
+       /**
+        * Add ancestor starting points to this tree, from which to traverse 
upwards.
+        * @param string[] $ancestors Array of page titles.
+        */
        public function addAncestors( $ancestors ) {
                $this->addAncestorsOrDescendants( 'ancestors', $ancestors );
        }
 
+       /**
+        * Add descendant starting points to this tree, from which to traverse 
downwards.
+        * @param string[] $descendants Array of page titles.
+        */
        public function addDescendants( $descendants ) {
                $this->addAncestorsOrDescendants( 'descendants', $descendants );
        }
 
-       private function addAncestorsOrDescendants( $type, $list ) {
+       /**
+        * Add ancestor or descendant starting points to this tree.
+        * @param string $type
+        * @param string[] $list
+        */
+       protected function addAncestorsOrDescendants( $type, $list ) {
                foreach ( $list as $a ) {
                        $title = Title::newFromText( $a );
                        if ( $title ) {
@@ -47,6 +68,10 @@
                }
        }
 
+       /**
+        * Get the Dot source code for the graph of this tree.
+        * @return string
+        */
        public function getGraphviz() {
                $this->out( 'top', 'start', 'digraph GenealogyTree {' );
                $this->out( 'top', 'graph-attrs', 'graph [rankdir=LR]' );
diff --git a/src/Util.php b/src/Util.php
index f5e453b..b87b737 100644
--- a/src/Util.php
+++ b/src/Util.php
@@ -129,14 +129,18 @@
                                if ( isset( $params['ancestors'] ) ) {
                                        $tree->addAncestors( explode( "\n", 
$params['ancestors'] ) );
                                }
-                               // $tree->setAncestorDepth($params['ancestor 
depth']);
+                               if ( isset( $params['ancestor depth'] ) ) {
+                                       $tree->setAncestorDepth( 
$params['ancestor depth'] );
+                               }
                                if ( isset( $params['descendants'] ) ) {
                                        $tree->addDescendants( explode( "\n", 
$params['descendants'] ) );
                                }
-                               // 
$tree->setDescendantDepth($params['descendant depth']);
+                               if ( isset( $params['descendant depth'] ) ) {
+                                       $tree->setDescendantDepth( 
$params['descendant depth'] );
+                               }
                                $graphviz = $tree->getGraphviz();
                                $out .= $parser->recursiveTagParse( 
"<graphviz>\n$graphviz\n</graphviz>" );
-                               $out .= $parser->recursiveTagParse( 
"<pre>$graphviz</pre>" );
+                               // $out .= $parser->recursiveTagParse( 
"<pre>$graphviz</pre>" );
                                break;
                        default:
                                $msg = wfMessage( 
'genealogy-parser-function-not-found', [ $type ] );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If3971637e909923eb9b6be6a50c282e0529f0fab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson <s...@samwilson.id.au>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to