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
This commit is contained in:
Sam Minnee 2007-11-19 01:25:21 +00:00
parent afbca3a88f
commit a26099f6f5
2 changed files with 13 additions and 14 deletions

View File

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

View File

@ -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
*