From a26099f6f5686c40cca2d9f1dae4b9d0d31d83e4 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 19 Nov 2007 01:25:21 +0000 Subject: [PATCH] parents-merge 34566 - Moved Level() from ContentController to SiteTree so that it can be accessed from anywhere git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@45047 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/control/ContentController.php | 14 -------------- core/model/SiteTree.php | 13 +++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/control/ContentController.php b/core/control/ContentController.php index 6013b4700..2038b987d 100644 --- a/core/control/ContentController.php +++ b/core/control/ContentController.php @@ -154,20 +154,6 @@ class ContentController extends Controller { return new DataObjectSet($visible); } - /** - * Returns the page in the current page stack of the given level. - * Level(1) will return the main menu item that we're currently inside, etc. - */ - - public function Level($level) { - $parent = $this->data(); - $stack = array($parent); - while($parent = $parent->Parent) { - array_unshift($stack, $parent); - } - - return isset($stack[$level-1]) ? $stack[$level-1] : null; - } public function Menu($level) { return $this->getMenu($level); diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 642b72575..bc9c5b3a3 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1347,7 +1347,20 @@ class SiteTree extends DataObject { } } + /** + * Returns the page in the current page stack of the given level. + * Level(1) will return the main menu item that we're currently inside, etc. + */ + public function Level($level) { + $parent = $this; + $stack = array($parent); + while($parent = $parent->Parent) { + array_unshift($stack, $parent); + } + return isset($stack[$level-1]) ? $stack[$level-1] : null; + } + /** * Return the CSS classes to apply to this node in the CMS tree *