Skip to content
Browse files

API CHANGE Splitting off "Behaviour" and "Access" tabs from SiteTree-…

…>getCMSFields() into SiteTree->getSettingsFields(). Adjusting functionality to split of SiteTree->getCMSFields() into getSettingsFields(), and new tab paths ("Root.Content" instead of "Root.Content.Main")
  • Loading branch information...
1 parent 53ed7c4 commit 7a50608e24aabdb376f3716248a4e1cac35267b7 @chillu chillu committed Apr 15, 2011
View
2 code/model/ErrorPage.php
@@ -131,7 +131,7 @@ function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab(
- "Root.Content.Main",
+ "Root.Content",
new DropdownField(
"ErrorCode",
$this->fieldLabel('ErrorCode'),
View
2 code/model/RedirectorPage.php
@@ -126,7 +126,7 @@ function getCMSFields() {
$fields->removeByName('MetaDescription');
$fields->removeByName('ExtraMeta');
- $fields->addFieldsToTab('Root.Content.Main',
+ $fields->addFieldsToTab('Root.Content',
array(
new HeaderField('RedirectorDescHeader',_t('RedirectorPage.HEADER', "This page will redirect users to another page")),
new OptionsetField(
View
120 code/model/SiteTree.php
@@ -1667,11 +1667,14 @@ function VirtualPages() {
}
/**
- * Returns a FieldSet with which to create the CMS editing form.
+ * Returns a FieldSet with which to create the main editing form.
*
* You can override this in your child classes to add extra fields - first
* get the parent fields using parent::getCMSFields(), then use
* addFieldToTab() on the FieldSet.
+ *
+ * See {@link getSettingsFields()} for a different set of fields
+ * concerned with configuration aspects on the record, e.g. access control
*
* @return FieldSet The fields to be displayed in the CMS.
*/
@@ -1747,35 +1750,70 @@ function getCMSFields() {
));
}
- // Lay out the fields
$fields = new FieldSet(
$rootTab = new TabSet("Root",
- $tabContent = new TabSet('Content',
- $tabMain = new Tab('Main',
- new TextField("Title", $this->fieldLabel('Title')),
- new TextField("MenuTitle", $this->fieldLabel('MenuTitle')),
- new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))
+ $tabMain = new Tab('Main',
+ new TextField("Title", $this->fieldLabel('Title')),
+ new TextField("MenuTitle", $this->fieldLabel('MenuTitle')),
+ new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))
+ ),
+ $tabMeta = new Tab('Metadata',
+ new FieldGroup(_t('SiteTree.URL', "URL"),
+ new LabelField('BaseUrlLabel',Controller::join_links (
+ Director::absoluteBaseURL(),
+ (self::nested_urls() && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)
+ )),
+ new TextField("URLSegment","URLSegment"),
+ new LabelField('TrailingSlashLabel',"/")
),
- $tabMeta = new Tab('Metadata',
- new FieldGroup(_t('SiteTree.URL', "URL"),
- new LabelField('BaseUrlLabel',Controller::join_links (
- Director::absoluteBaseURL(),
- (self::nested_urls() && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)
- )),
- new TextField("URLSegment","URLSegment"),
- new LabelField('TrailingSlashLabel',"/")
- ),
- new LiteralField('LinkChangeNote', self::nested_urls() && count($this->Children()) ?
- '<p>' . $this->fieldLabel('LinkChangeNote'). '</p>' : null
- ),
- new HeaderField('MetaTagsHeader',$this->fieldLabel('MetaTagsHeader')),
- new TextField("MetaTitle", $this->fieldLabel('MetaTitle')),
- new TextareaField("MetaKeywords", $this->fieldLabel('MetaKeywords'), 1),
- new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')),
- new TextareaField("ExtraMeta",$this->fieldLabel('ExtraMeta'))
- )
+ new LiteralField('LinkChangeNote', self::nested_urls() && count($this->Children()) ?
+ '<p>' . $this->fieldLabel('LinkChangeNote'). '</p>' : null
+ ),
+ new HeaderField('MetaTagsHeader',$this->fieldLabel('MetaTagsHeader')),
+ new TextField("MetaTitle", $this->fieldLabel('MetaTitle')),
+ new TextareaField("MetaKeywords", $this->fieldLabel('MetaKeywords'), 1),
+ new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')),
+ new TextareaField("ExtraMeta",$this->fieldLabel('ExtraMeta'))
),
- $tabBehaviour = new Tab('Behaviour',
+ $tabDependent = new Tab('Dependent',
+ $dependentNote,
+ $dependentTable
+ )
+ )
+ );
+
+ // Conditional dependent pages tab
+ if($dependentPagesCount) $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ($dependentPagesCount)");
+ else $fields->removeFieldFromTab('Root', 'Dependent');
+
+ $tabMain->setTitle(_t('SiteTree.TABCONTENT', "Content"));
+ $tabMeta->setTitle(_t('SiteTree.TABMETA', "Metadata"));
+
+ if(file_exists(BASE_PATH . '/install.php')) {
+ $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader",
+ "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING",
+ "Warning: You should remove install.php from this SilverStripe install for security reasons.")
+ . "</p>"), "Title");
+ }
+
+
+ if(self::$runCMSFieldsExtensions) {
+ $this->extend('updateCMSFields', $fields);
+ }
+
+ return $fields;
+ }
+
+ /**
+ * Returns fields related to configuration aspects on this record, e.g. access control.
+ * See {@link getCMSFields()} for content-related fields.
+ *
+ * @return FieldSet
+ */
+ function getSettingsFields() {
+ $fields = new FieldSet(
+ $rootTab = new TabSet("Root",
+ $tabBehaviour = new Tab('Settings',
new DropdownField(
"ClassName",
$this->fieldLabel('ClassName'),
@@ -1803,10 +1841,6 @@ function getCMSFields() {
_t('SiteTree.HOMEPAGEFORDOMAIN', "Domain(s)", PR_MEDIUM, 'Listing domains that should be used as homepage')
)
),
- $tabDependent = new Tab('Dependent',
- $dependentNote,
- $dependentTable
- ),
$tabAccess = new Tab('Access',
new HeaderField('WhoCanViewHeader',_t('SiteTree.ACCESSHEADER', "Who can view this page?"), 2),
$viewersOptionsField = new OptionsetField(
@@ -1823,17 +1857,15 @@ function getCMSFields() {
)
)
);
-
-
+
/*
* This filter ensures that the ParentID dropdown selection does not show this node,
* or its descendents, as this causes vanishing bugs.
*/
$parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
- // Conditional dependent pages tab
- if($dependentPagesCount) $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ($dependentPagesCount)");
- else $fields->removeFieldFromTab('Root', 'Dependent');
+ $tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
+ $tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
// Make page location fields read-only if the user doesn't have the appropriate permission
if(!Permission::check("SITETREE_REORGANISE")) {
@@ -1874,24 +1906,10 @@ function getCMSFields() {
}
}
- $tabContent->setTitle(_t('SiteTree.TABCONTENT', "Content"));
- $tabMain->setTitle(_t('SiteTree.TABMAIN', "Main"));
- $tabMeta->setTitle(_t('SiteTree.TABMETA', "Metadata"));
- $tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
- $tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
-
- if(file_exists(BASE_PATH . '/install.php')) {
- $fields->addFieldToTab("Root.Content.Main", new LiteralField("InstallWarningHeader",
- "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING",
- "Warning: You should remove install.php from this SilverStripe install for security reasons.")
- . "</p>"), "Title");
- }
-
-
if(self::$runCMSFieldsExtensions) {
- $this->extend('updateCMSFields', $fields);
+ $this->extend('updateSettingsFields', $fields);
}
-
+
return $fields;
}
View
6 code/model/VirtualPage.php
@@ -150,17 +150,17 @@ function getCMSFields($cms = null) {
}
// Add fields to the tab
- $fields->addFieldToTab("Root.Content.Main",
+ $fields->addFieldToTab("Root.Content",
new HeaderField('VirtualPageHeader',_t('VirtualPage.HEADER', "This is a virtual page")),
"Title"
);
- $fields->addFieldToTab("Root.Content.Main", $copyContentFromField, "Title");
+ $fields->addFieldToTab("Root.Content", $copyContentFromField, "Title");
// Create links back to the original object in the CMS
if($this->CopyContentFrom()->ID) {
$linkToContent = "<a class=\"cmsEditlink\" href=\"admin/show/$this->CopyContentFromID\">" .
_t('VirtualPage.EDITCONTENT', 'click here to edit the content') . "</a>";
- $fields->addFieldToTab("Root.Content.Main",
+ $fields->addFieldToTab("Root.Content",
$linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent),
"Title"
);
View
2 tests/model/SiteTreeBacklinksTest.php
@@ -252,7 +252,7 @@ function extraStatics() {
}
function updateCMSFields(&$fields) {
- $fields->addFieldToTab("Root.Content.Main", new HTMLEditorField("ExtraContent"));
+ $fields->addFieldToTab("Root.Content", new HTMLEditorField("ExtraContent"));
}
}
?>
View
4 tests/model/SiteTreePermissionsTest.php
@@ -150,7 +150,7 @@ function testAccessTabOnlyDisplaysWithGrantAccessPermissions() {
$subadminuser = $this->objFromFixture('Member', 'subadmin');
$this->session()->inst_set('loggedInAs', $subadminuser->ID);
- $fields = $page->getCMSFields();
+ $fields = $page->getSettingsFields();
$this->assertFalse(
$fields->dataFieldByName('CanViewType')->isReadonly(),
'Users with SITETREE_GRANT_ACCESS permission can change "view" permissions in cms fields'
@@ -162,7 +162,7 @@ function testAccessTabOnlyDisplaysWithGrantAccessPermissions() {
$editoruser = $this->objFromFixture('Member', 'editor');
$this->session()->inst_set('loggedInAs', $editoruser->ID);
- $fields = $page->getCMSFields();
+ $fields = $page->getSettingsFields();
$this->assertTrue(
$fields->dataFieldByName('CanViewType')->isReadonly(),
'Users without SITETREE_GRANT_ACCESS permission cannot change "view" permissions in cms fields'

0 comments on commit 7a50608

Please sign in to comment.
Something went wrong with that request. Please try again.