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
This commit is contained in:
Sam Minnee 2010-01-13 00:06:28 +00:00
parent 80756cc498
commit 0cdd75dfb1
2 changed files with 8 additions and 5 deletions

View File

@ -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]*<ul[^>]*>','', $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]*<ul[^>]*>','', $tree);

View File

@ -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
);