BUGFIX Made ContentController work properly if it doesn't have a dataRecord

MINOR phpDoc update for ContentController->getMenu()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64771 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2008-10-25 11:30:28 +00:00
parent 03830e1baa
commit 412df22527

View File

@ -132,6 +132,7 @@ class ContentController extends Controller {
/** /**
* Returns a fixed navigation menu of the given level. * Returns a fixed navigation menu of the given level.
* @return DataObjectSet
*/ */
public function getMenu($level = 1) { public function getMenu($level = 1) {
if($level == 1) { if($level == 1) {
@ -140,11 +141,14 @@ class ContentController extends Controller {
} else { } else {
$parent = $this->data(); $parent = $this->data();
$stack = array($parent); $stack = array($parent);
while($parent = $parent->Parent)
array_unshift($stack, $parent);
if(isset($stack[$level-2])) if($parent) {
$result = $stack[$level-2]->Children(); while($parent = $parent->Parent) {
array_unshift($stack, $parent);
}
}
if(isset($stack[$level-2])) $result = $stack[$level-2]->Children();
} }
$visible = array(); $visible = array();
@ -293,7 +297,7 @@ HTML;
* Returns a page comment system * Returns a page comment system
*/ */
function PageComments() { function PageComments() {
if($this->data()->ProvideComments) { if($this->data() && $this->data()->ProvideComments) {
return new PageCommentInterface($this, 'PageComments', $this->data()); return new PageCommentInterface($this, 'PageComments', $this->data());
} else { } else {
if(isset($_REQUEST['executeForm']) && $_REQUEST['executeForm'] == 'PageComments.PostCommentForm') { if(isset($_REQUEST['executeForm']) && $_REQUEST['executeForm'] == 'PageComments.PostCommentForm') {