API CHANGE: Added numChildrenMethod argument to LeftAndMain::getSiteTreeFor()

BUGFIX: Use the correct numChildrenMethod when showing the 'all children, including deleted' tree (from r91166) (from r96809)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102474 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-12 09:22:43 +00:00
parent cbe7f13e89
commit 480d5068d1
3 changed files with 12 additions and 11 deletions

View File

@ -253,9 +253,9 @@ HTML;
return $this->getSiteTreeFor($this->stat('tree_class'), null, 'ChildFolders'); return $this->getSiteTreeFor($this->stat('tree_class'), null, 'ChildFolders');
} }
function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $filterFunction = null, $minNodeCount = 30) { function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
if (!$childrenMethod) $childrenMethod = 'ChildFolders'; if (!$childrenMethod) $childrenMethod = 'ChildFolders';
return parent::getSiteTreeFor($className, $rootID, $childrenMethod, $filterFunction, $minNodeCount); return parent::getSiteTreeFor($className, $rootID, $childrenMethod, $numChildrenMethod, $filterFunction, $minNodeCount);
} }
public function getCMSTreeTitle() { public function getCMSTreeTitle() {

View File

@ -475,9 +475,10 @@ class LeftAndMain extends Controller {
* Children, AllChildrenIncludingDeleted, or AllHistoricalChildren * Children, AllChildrenIncludingDeleted, or AllHistoricalChildren
* @return String Nested <ul> list with links to each page * @return String Nested <ul> list with links to each page
*/ */
function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $filterFunction = null, $minNodeCount = 30) { function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
// Default childrenMethod // Default childrenMethod and numChildrenMethod
if (!$childrenMethod) $childrenMethod = 'AllChildrenIncludingDeleted'; if (!$childrenMethod) $childrenMethod = 'AllChildrenIncludingDeleted';
if (!$numChildrenMethod) $numChildrenMethod = 'numChildren';
// Get the tree root // Get the tree root
$obj = $rootID ? $this->getRecord($rootID) : singleton($className); $obj = $rootID ? $this->getRecord($rootID) : singleton($className);
@ -485,7 +486,7 @@ class LeftAndMain extends Controller {
// Mark the nodes of the tree to return // Mark the nodes of the tree to return
if ($filterFunction) $obj->setMarkingFilterFunction($filterFunction); if ($filterFunction) $obj->setMarkingFilterFunction($filterFunction);
$obj->markPartialTree($minNodeCount, $this, $childrenMethod); $obj->markPartialTree($minNodeCount, $this, $childrenMethod, $numChildrenMethod);
// Ensure current page is exposed // Ensure current page is exposed
if($p = $this->currentPage()) $obj->markToExpose($p); if($p = $this->currentPage()) $obj->markToExpose($p);
@ -509,6 +510,7 @@ class LeftAndMain extends Controller {
$this, $this,
true, true,
$childrenMethod, $childrenMethod,
$numChildrenMethod,
$minNodeCount $minNodeCount
); );
@ -542,14 +544,13 @@ class LeftAndMain extends Controller {
$filter = null; $filter = null;
} }
$html = $this->getSiteTreeFor( $html = $this->getSiteTreeFor(
$this->stat('tree_class'), $this->stat('tree_class'),
$request->getVar('ID'), $request->getVar('ID'),
null, ($filter) ? $filter->getChildrenMethod() : null,
null,
($filter) ? array($filter, 'isPageIncluded') : null, ($filter) ? array($filter, 'isPageIncluded') : null,
$request->getVar('minNodeCount'), $request->getVar('minNodeCount')
($filter) ? $filter->getChildrenMethod() : null
); );
// Trim off the outer tag // Trim off the outer tag

View File

@ -330,9 +330,9 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
return FormResponse::respond(); return FormResponse::respond();
} }
function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $filterFunction = null, $minNodeCount = 30) { function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
if (!$childrenMethod) $childrenMethod = 'stageChildren'; if (!$childrenMethod) $childrenMethod = 'stageChildren';
return parent::getSiteTreeFor($className, $rootID, $childrenMethod, $filterFunction, $minNodeCount); return parent::getSiteTreeFor($className, $rootID, $childrenMethod, $numChildrenMethod, $filterFunction, $minNodeCount);
} }
function getCMSTreeTitle() { function getCMSTreeTitle() {