From 0cdd75dfb1feed7b8142fe50c21aec00a070ce88 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 13 Jan 2010 00:06:28 +0000 Subject: [PATCH] API CHANGE: Added numChildrenMethod argument to LeftAndMain::getSiteTreeFor() BUGFIX: Use the correct numChildrenMethod when showing the 'all children, including deleted' tree (from r91166) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@96809 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSSiteTreeFilter.php | 4 ++-- code/LeftAndMain.php | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/code/CMSSiteTreeFilter.php b/code/CMSSiteTreeFilter.php index ce5c3b99..d77bcc7b 100644 --- a/code/CMSSiteTreeFilter.php +++ b/code/CMSSiteTreeFilter.php @@ -28,7 +28,7 @@ abstract class CMSSiteTreeFilter extends Object { } $leftAndMain = new LeftAndMain(); - $tree = $leftAndMain->getSiteTreeFor('SiteTree', isset($_REQUEST['ID']) ? $_REQUEST['ID'] : 0, null, array($this, 'includeInTree')); + $tree = $leftAndMain->getSiteTreeFor('SiteTree', isset($_REQUEST['ID']) ? $_REQUEST['ID'] : 0, null, null, array($this, 'includeInTree')); // Trim off the outer tag $tree = ereg_replace('^[ \t\r\n]*]*>','', $tree); @@ -80,7 +80,7 @@ class CMSSiteTreeFilter_DeletedPages extends CMSSiteTreeFilter { function getTree() { $leftAndMain = new CMSMain(); - $tree = $leftAndMain->getSiteTreeFor('SiteTree', isset($_REQUEST['ID']) ? $_REQUEST['ID'] : 0, "AllHistoricalChildren"); + $tree = $leftAndMain->getSiteTreeFor('SiteTree', isset($_REQUEST['ID']) ? $_REQUEST['ID'] : 0, "AllHistoricalChildren", "numHistoricalChildren"); // Trim off the outer tag $tree = ereg_replace('^[ \t\r\n]*]*>','', $tree); diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index c4ee1816..3aebdc3c 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -469,9 +469,10 @@ class LeftAndMain extends Controller { * @param $childrenMethod The method to call to get the children of the tree. For example, * Children, AllChildrenIncludingDeleted, or AllHistoricalChildren */ - function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $filterFunction = null, $minNodeCount = 30) { - // Default childrenMethod + function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) { + // Default childrenMethod and numChildrenMethod if (!$childrenMethod) $childrenMethod = 'AllChildrenIncludingDeleted'; + if (!$numChildrenMethod) $numChildrenMethod = 'numChildren'; // Get the tree root $obj = $rootID ? $this->getRecord($rootID) : singleton($className); @@ -479,7 +480,7 @@ class LeftAndMain extends Controller { // Mark the nodes of the tree to return if ($filterFunction) $obj->setMarkingFilterFunction($filterFunction); - $obj->markPartialTree($minNodeCount, $this, $childrenMethod); + $obj->markPartialTree($minNodeCount, $this, $childrenMethod, $numChildrenMethod); // Ensure current page is exposed if($p = $this->currentPage()) $obj->markToExpose($p); @@ -501,6 +502,7 @@ class LeftAndMain extends Controller { $this, true, $childrenMethod, + $numChildrenMethod, $minNodeCount ); @@ -532,6 +534,7 @@ class LeftAndMain extends Controller { $request->getVar('ID'), null, null, + null, $minNodeCount );