From ceb0afeb789f5caeb8dc2a04796aac6f0a7c277f Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 9 Jul 2009 05:53:40 +0000 Subject: [PATCH] ENHANCEMENT Passing $minNodeCount through Hierarchy->getChildrenAsUL() and Hierarchy->markPartialTree() (from r78305) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@81465 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/Hierarchy.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/model/Hierarchy.php b/core/model/Hierarchy.php index 20ff69f21..6ad96f943 100644 --- a/core/model/Hierarchy.php +++ b/core/model/Hierarchy.php @@ -27,9 +27,10 @@ class Hierarchy extends DataObjectDecorator { * @param boolean $limitToMarked Display only marked children. * @param string $childrenMethod The name of the method used to get children from each object * @param boolean $rootCall Set to true for this first call, and then to false for calls inside the recursion. You should not change this. + * @param int $minNodeCount * @return string */ - public function getChildrenAsUL($attributes = "", $titleEval = '"
  • " . $child->Title', $extraArg = null, $limitToMarked = false, $childrenMethod = "AllChildrenIncludingDeleted", $rootCall = true) { + public function getChildrenAsUL($attributes = "", $titleEval = '"
  • " . $child->Title', $extraArg = null, $limitToMarked = false, $childrenMethod = "AllChildrenIncludingDeleted", $rootCall = true, $minNodeCount = 30) { if($limitToMarked && $rootCall) { $this->markingFinished(); } @@ -52,7 +53,7 @@ class Hierarchy extends DataObjectDecorator { if(!$limitToMarked || $child->isMarked()) { $foundAChild = true; $output .= eval("return $titleEval;") . "\n" . - $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked, $childrenMethod, false) . "
  • \n"; + $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked, $childrenMethod, false, $minNodeCount) . "\n"; } } @@ -72,18 +73,19 @@ class Hierarchy extends DataObjectDecorator { * This method returns the number of nodes marked. After this method is called other methods * can check isExpanded() and isMarked() on individual nodes. * - * @param int $minCount The minimum amount of nodes to mark. + * @param int $minNodeCount The minimum amount of nodes to mark. * @return int The actual number of nodes marked. */ - public function markPartialTree($minCount = 30, $context = null, $childrenMethod = "AllChildrenIncludingDeleted") { + public function markPartialTree($minNodeCount = 30, $context = null, $childrenMethod = "AllChildrenIncludingDeleted") { + if(!is_numeric($minNodeCount)) $minNodeCount = 30; + $this->markedNodes = array($this->owner->ID => $this->owner); $this->owner->markUnexpanded(); // foreach can't handle an ever-growing $nodes list while(list($id, $node) = each($this->markedNodes)) { $this->markChildren($node, $context, $childrenMethod); - - if($minCount && sizeof($this->markedNodes) >= $minCount) { + if($minNodeCount && sizeof($this->markedNodes) >= $minNodeCount) { break; } }