mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
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")
This commit is contained in:
parent
53ed7c496e
commit
7a50608e24
@ -131,7 +131,7 @@ class ErrorPage extends Page {
|
|||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
"Root.Content.Main",
|
"Root.Content",
|
||||||
new DropdownField(
|
new DropdownField(
|
||||||
"ErrorCode",
|
"ErrorCode",
|
||||||
$this->fieldLabel('ErrorCode'),
|
$this->fieldLabel('ErrorCode'),
|
||||||
|
@ -126,7 +126,7 @@ class RedirectorPage extends Page {
|
|||||||
$fields->removeByName('MetaDescription');
|
$fields->removeByName('MetaDescription');
|
||||||
$fields->removeByName('ExtraMeta');
|
$fields->removeByName('ExtraMeta');
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Content.Main',
|
$fields->addFieldsToTab('Root.Content',
|
||||||
array(
|
array(
|
||||||
new HeaderField('RedirectorDescHeader',_t('RedirectorPage.HEADER', "This page will redirect users to another page")),
|
new HeaderField('RedirectorDescHeader',_t('RedirectorPage.HEADER', "This page will redirect users to another page")),
|
||||||
new OptionsetField(
|
new OptionsetField(
|
||||||
|
@ -1667,12 +1667,15 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* You can override this in your child classes to add extra fields - first
|
||||||
* get the parent fields using parent::getCMSFields(), then use
|
* get the parent fields using parent::getCMSFields(), then use
|
||||||
* addFieldToTab() on the FieldSet.
|
* 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.
|
* @return FieldSet The fields to be displayed in the CMS.
|
||||||
*/
|
*/
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
@ -1747,35 +1750,70 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lay out the fields
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldSet(
|
||||||
$rootTab = new TabSet("Root",
|
$rootTab = new TabSet("Root",
|
||||||
$tabContent = new TabSet('Content',
|
$tabMain = new Tab('Main',
|
||||||
$tabMain = new Tab('Main',
|
new TextField("Title", $this->fieldLabel('Title')),
|
||||||
new TextField("Title", $this->fieldLabel('Title')),
|
new TextField("MenuTitle", $this->fieldLabel('MenuTitle')),
|
||||||
new TextField("MenuTitle", $this->fieldLabel('MenuTitle')),
|
new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))
|
||||||
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',"/")
|
|
||||||
),
|
|
||||||
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',
|
$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'))
|
||||||
|
),
|
||||||
|
$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(
|
new DropdownField(
|
||||||
"ClassName",
|
"ClassName",
|
||||||
$this->fieldLabel('ClassName'),
|
$this->fieldLabel('ClassName'),
|
||||||
@ -1803,10 +1841,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
_t('SiteTree.HOMEPAGEFORDOMAIN', "Domain(s)", PR_MEDIUM, 'Listing domains that should be used as homepage')
|
_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',
|
$tabAccess = new Tab('Access',
|
||||||
new HeaderField('WhoCanViewHeader',_t('SiteTree.ACCESSHEADER', "Who can view this page?"), 2),
|
new HeaderField('WhoCanViewHeader',_t('SiteTree.ACCESSHEADER', "Who can view this page?"), 2),
|
||||||
$viewersOptionsField = new OptionsetField(
|
$viewersOptionsField = new OptionsetField(
|
||||||
@ -1824,16 +1858,14 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This filter ensures that the ParentID dropdown selection does not show this node,
|
* This filter ensures that the ParentID dropdown selection does not show this node,
|
||||||
* or its descendents, as this causes vanishing bugs.
|
* or its descendents, as this causes vanishing bugs.
|
||||||
*/
|
*/
|
||||||
$parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
|
$parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
|
||||||
|
|
||||||
// Conditional dependent pages tab
|
$tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
|
||||||
if($dependentPagesCount) $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ($dependentPagesCount)");
|
$tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
|
||||||
else $fields->removeFieldFromTab('Root', 'Dependent');
|
|
||||||
|
|
||||||
// Make page location fields read-only if the user doesn't have the appropriate permission
|
// Make page location fields read-only if the user doesn't have the appropriate permission
|
||||||
if(!Permission::check("SITETREE_REORGANISE")) {
|
if(!Permission::check("SITETREE_REORGANISE")) {
|
||||||
@ -1874,22 +1906,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$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) {
|
if(self::$runCMSFieldsExtensions) {
|
||||||
$this->extend('updateCMSFields', $fields);
|
$this->extend('updateSettingsFields', $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
@ -150,17 +150,17 @@ class VirtualPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add fields to the tab
|
// 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")),
|
new HeaderField('VirtualPageHeader',_t('VirtualPage.HEADER', "This is a virtual page")),
|
||||||
"Title"
|
"Title"
|
||||||
);
|
);
|
||||||
$fields->addFieldToTab("Root.Content.Main", $copyContentFromField, "Title");
|
$fields->addFieldToTab("Root.Content", $copyContentFromField, "Title");
|
||||||
|
|
||||||
// Create links back to the original object in the CMS
|
// Create links back to the original object in the CMS
|
||||||
if($this->CopyContentFrom()->ID) {
|
if($this->CopyContentFrom()->ID) {
|
||||||
$linkToContent = "<a class=\"cmsEditlink\" href=\"admin/show/$this->CopyContentFromID\">" .
|
$linkToContent = "<a class=\"cmsEditlink\" href=\"admin/show/$this->CopyContentFromID\">" .
|
||||||
_t('VirtualPage.EDITCONTENT', 'click here to edit the content') . "</a>";
|
_t('VirtualPage.EDITCONTENT', 'click here to edit the content') . "</a>";
|
||||||
$fields->addFieldToTab("Root.Content.Main",
|
$fields->addFieldToTab("Root.Content",
|
||||||
$linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent),
|
$linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent),
|
||||||
"Title"
|
"Title"
|
||||||
);
|
);
|
||||||
|
@ -252,7 +252,7 @@ class SiteTreeBacklinksTest_DOD extends DataExtension implements TestOnly {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateCMSFields(&$fields) {
|
function updateCMSFields(&$fields) {
|
||||||
$fields->addFieldToTab("Root.Content.Main", new HTMLEditorField("ExtraContent"));
|
$fields->addFieldToTab("Root.Content", new HTMLEditorField("ExtraContent"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -150,7 +150,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
|
|
||||||
$subadminuser = $this->objFromFixture('Member', 'subadmin');
|
$subadminuser = $this->objFromFixture('Member', 'subadmin');
|
||||||
$this->session()->inst_set('loggedInAs', $subadminuser->ID);
|
$this->session()->inst_set('loggedInAs', $subadminuser->ID);
|
||||||
$fields = $page->getCMSFields();
|
$fields = $page->getSettingsFields();
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$fields->dataFieldByName('CanViewType')->isReadonly(),
|
$fields->dataFieldByName('CanViewType')->isReadonly(),
|
||||||
'Users with SITETREE_GRANT_ACCESS permission can change "view" permissions in cms fields'
|
'Users with SITETREE_GRANT_ACCESS permission can change "view" permissions in cms fields'
|
||||||
@ -162,7 +162,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
|
|
||||||
$editoruser = $this->objFromFixture('Member', 'editor');
|
$editoruser = $this->objFromFixture('Member', 'editor');
|
||||||
$this->session()->inst_set('loggedInAs', $editoruser->ID);
|
$this->session()->inst_set('loggedInAs', $editoruser->ID);
|
||||||
$fields = $page->getCMSFields();
|
$fields = $page->getSettingsFields();
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$fields->dataFieldByName('CanViewType')->isReadonly(),
|
$fields->dataFieldByName('CanViewType')->isReadonly(),
|
||||||
'Users without SITETREE_GRANT_ACCESS permission cannot change "view" permissions in cms fields'
|
'Users without SITETREE_GRANT_ACCESS permission cannot change "view" permissions in cms fields'
|
||||||
|
Loading…
Reference in New Issue
Block a user