Merge pull request #62 from silverstripe-scienceninjas/master

BUGFIX: SiteTree#getCMSFields would only calculate local variable $linkedPages if ID was valid, but would then refer to that variable regardless
This commit is contained in:
Sam Minnée 2012-03-05 13:08:22 -08:00
commit 703ac7b47e

View File

@ -1760,36 +1760,36 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
// Create a status message for multiple parents
if($this->ID && is_numeric($this->ID)) {
$linkedPages = $this->VirtualPages();
}
$parentPageLinks = array();
if($linkedPages->Count() > 0) {
foreach($linkedPages as $linkedPage) {
$parentPage = $linkedPage->Parent;
if($parentPage) {
if($parentPage->ID) {
$parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/$linkedPage->ID\">{$parentPage->Title}</a>";
} else {
$parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/$linkedPage->ID\">" .
_t('SiteTree.TOPLEVEL', 'Site Content (Top Level)') .
"</a>";
$parentPageLinks = array();
if($linkedPages->Count() > 0) {
foreach($linkedPages as $linkedPage) {
$parentPage = $linkedPage->Parent;
if($parentPage) {
if($parentPage->ID) {
$parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/$linkedPage->ID\">{$parentPage->Title}</a>";
} else {
$parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/$linkedPage->ID\">" .
_t('SiteTree.TOPLEVEL', 'Site Content (Top Level)') .
"</a>";
}
}
}
$lastParent = array_pop($parentPageLinks);
$parentList = "'$lastParent'";
if(count($parentPageLinks) > 0) {
$parentList = "'" . implode("', '", $parentPageLinks) . "' and "
. $parentList;
}
$statusMessage[] = sprintf(
_t('SiteTree.APPEARSVIRTUALPAGES', "This content also appears on the virtual pages in the %s sections."),
$parentList
);
}
$lastParent = array_pop($parentPageLinks);
$parentList = "'$lastParent'";
if(count($parentPageLinks) > 0) {
$parentList = "'" . implode("', '", $parentPageLinks) . "' and "
. $parentList;
}
$statusMessage[] = sprintf(
_t('SiteTree.APPEARSVIRTUALPAGES', "This content also appears on the virtual pages in the %s sections."),
$parentList
);
}
if($this->HasBrokenLink || $this->HasBrokenFile) {