Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Siblings of active and node ID fixes. #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions services/NaveeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,28 +638,11 @@ private function getSubsetOfNodes($nodes, $activeNodes)
continue;
}
}
// start with a given node id
elseif ((int) $this->config->startWithNodeId && isset($rootNode))
{
if ($node->lft <= $rootNode->lft || $node->rgt >= $rootNode->rgt)
{
unset($nodes[$k]);
continue;
}
}
// start with children of a given node id
elseif ((int) $this->config->startWithChildrenOfNodeId && isset($rootNode))
{
if ($node->lft < $rootNode->lft || $node->rgt > $rootNode->rgt)
{
unset($nodes[$k]);
continue;
}
}
// start with the active node
// start with siblings of the active node
elseif ($this->config->startWithSiblingsOfActive)
{
if (!$this->nodeInBranchOfActiveNode($rootNode, $node) && !$node->active)
if ((!$this->nodeInBranchOfActiveNode($rootNode, $node) && !$node->active)
|| ($node->level < $activeNode->level && !$node->descendantActive))
{
array_push($removedNodes, $node);
unset($nodes[$k]);
Expand Down Expand Up @@ -707,6 +690,25 @@ private function getSubsetOfNodes($nodes, $activeNodes)

}
}

// start with a given node id
if ((int) $this->config->startWithNodeId && isset($rootNode))
{
if ($node->lft <= $rootNode->lft || $node->rgt >= $rootNode->rgt)
{
unset($nodes[$k]);
continue;
}
}
// start with children of a given node id
elseif ((int) $this->config->startWithChildrenOfNodeId && isset($rootNode))
{
if ($node->lft < $rootNode->lft || $node->rgt > $rootNode->rgt)
{
unset($nodes[$k]);
continue;
}
}
}

$nodes = $this->rebuildNestedSet($nodes);
Expand Down