From e17b4a185a997b288324395e0bda45f4bc59da69 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Sat, 17 Dec 2011 16:45:09 +1300 Subject: [PATCH] MINOR: update PageTypes to use updated tab path for CMS fields. Fixes #6811 --- code/controllers/CMSMain.php | 23 ++++++++++++++++------- code/model/ErrorPage.php | 2 +- code/model/RedirectorPage.php | 2 +- code/model/VirtualPage.php | 6 +++--- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index fd4cb94a..4ab91696 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -225,24 +225,33 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr foreach($classes as $class) { $obj = singleton($class); + if($obj instanceof HiddenClass) continue; $allowedChildren = $obj->allowedChildren(); - //SiteTree::allowedChildren() returns null rather than an empty array if SiteTree::allowed_chldren == 'none' - if ($allowedChildren == null) $allowedChildren = array(); + + // SiteTree::allowedChildren() returns null rather than an empty array if SiteTree::allowed_chldren == 'none' + if($allowedChildren == null) $allowedChildren = array(); + $def[$class]['disallowedChildren'] = array_keys(array_diff($classes, $allowedChildren)); $defaultChild = $obj->defaultChild(); - if ($defaultChild != 'Page' && $defaultChild != null) $def[$class]['defaultChild'] = $defaultChild; - $defaultParent = isset(SiteTree::get_by_link($obj->defaultParent())->ID) ? SiteTree::get_by_link($obj->defaultParent())->ID : null; + if($defaultChild != 'Page' && $defaultChild != null) + $def[$class]['defaultChild'] = $defaultChild; + + $id = SiteTree::get_by_link($obj->defaultParent())->ID; + $defaultParent = $id ? SiteTree::get_by_link($obj->defaultParent())->ID : null; + if ($defaultParent != 1 && $defaultParent != null) $def[$class]['defaultParent'] = $defaultParent; - if(is_array($def[$class]['disallowedChildren'])) foreach($def[$class]['disallowedChildren'] as $disallowedChild) { - $def[$disallowedChild]['disallowedParents'][] = $class; + if(is_array($def[$class]['disallowedChildren'])) { + foreach($def[$class]['disallowedChildren'] as $disallowedChild) { + $def[$disallowedChild]['disallowedParents'][] = $class; + } } - //Are any classes allowed to be parents of root? + // Are any classes allowed to be parents of root? $def['Root']['disallowedParents'][] = $class; } diff --git a/code/model/ErrorPage.php b/code/model/ErrorPage.php index 130157f8..f2f180c5 100644 --- a/code/model/ErrorPage.php +++ b/code/model/ErrorPage.php @@ -133,7 +133,7 @@ class ErrorPage extends Page { $fields = parent::getCMSFields(); $fields->addFieldToTab( - "Root.Content", + "Root.Main", new DropdownField( "ErrorCode", $this->fieldLabel('ErrorCode'), diff --git a/code/model/RedirectorPage.php b/code/model/RedirectorPage.php index c479087c..0cdfb3b3 100644 --- a/code/model/RedirectorPage.php +++ b/code/model/RedirectorPage.php @@ -128,7 +128,7 @@ class RedirectorPage extends Page { $fields->removeByName('MetaDescription'); $fields->removeByName('ExtraMeta'); - $fields->addFieldsToTab('Root.Content', + $fields->addFieldsToTab('Root.Main', array( new HeaderField('RedirectorDescHeader',_t('RedirectorPage.HEADER', "This page will redirect users to another page")), new OptionsetField( diff --git a/code/model/VirtualPage.php b/code/model/VirtualPage.php index eb690f14..32bf0d71 100644 --- a/code/model/VirtualPage.php +++ b/code/model/VirtualPage.php @@ -172,17 +172,17 @@ class VirtualPage extends Page { } // Add fields to the tab - $fields->addFieldToTab("Root.Content", + $fields->addFieldToTab("Root.Main", new HeaderField('VirtualPageHeader',_t('VirtualPage.HEADER', "This is a virtual page")), "Title" ); - $fields->addFieldToTab("Root.Content", $copyContentFromField, "Title"); + $fields->addFieldToTab("Root.Main", $copyContentFromField, "Title"); // Create links back to the original object in the CMS if($this->CopyContentFrom()->ID) { $linkToContent = "CopyContentFromID\">" . _t('VirtualPage.EDITCONTENT', 'click here to edit the content') . ""; - $fields->addFieldToTab("Root.Content", + $fields->addFieldToTab("Root.Main", $linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent), "Title" );