mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Conditionally add Theme dropdown (if there are any themese available) for #261. Replace field instantiatiors in getCMSFields() with ::create() to support injection.
Add empty string / lang entry to Theme dropdown
This commit is contained in:
parent
10302932a9
commit
8705a46b98
@ -583,15 +583,15 @@ class Subsite extends DataObject
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
if ($this->ID!=0) {
|
if ($this->ID != 0) {
|
||||||
$domainTable = new GridField(
|
$domainTable = GridField::create(
|
||||||
"Domains",
|
"Domains",
|
||||||
_t('Subsite.DomainsListTitle', "Domains"),
|
_t('Subsite.DomainsListTitle', "Domains"),
|
||||||
$this->Domains(),
|
$this->Domains(),
|
||||||
GridFieldConfig_RecordEditor::create(10)
|
GridFieldConfig_RecordEditor::create(10)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$domainTable = new LiteralField(
|
$domainTable = LiteralField::create(
|
||||||
'Domains',
|
'Domains',
|
||||||
'<p>'._t('Subsite.DOMAINSAVEFIRST', 'You can only add domains after saving for the first time').'</p>'
|
'<p>'._t('Subsite.DOMAINSAVEFIRST', 'You can only add domains after saving for the first time').'</p>'
|
||||||
);
|
);
|
||||||
@ -610,45 +610,49 @@ class Subsite extends DataObject
|
|||||||
}
|
}
|
||||||
asort($pageTypeMap);
|
asort($pageTypeMap);
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = FieldList::create(
|
||||||
$subsiteTabs = new TabSet('Root',
|
$subsiteTabs = TabSet::create('Root',
|
||||||
new Tab(
|
Tab::create(
|
||||||
'Configuration',
|
'Configuration',
|
||||||
_t('Subsite.TabTitleConfig', 'Configuration'),
|
_t('Subsite.TabTitleConfig', 'Configuration'),
|
||||||
new HeaderField($this->getClassName() . ' configuration', 2),
|
HeaderField::create($this->getClassName() . ' configuration', 2),
|
||||||
new TextField('Title', $this->fieldLabel('Title'), $this->Title),
|
TextField::create('Title', $this->fieldLabel('Title'), $this->Title),
|
||||||
|
|
||||||
new HeaderField(
|
HeaderField::create(
|
||||||
_t('Subsite.DomainsHeadline', "Domains for this subsite")
|
_t('Subsite.DomainsHeadline', "Domains for this subsite")
|
||||||
),
|
),
|
||||||
$domainTable,
|
$domainTable,
|
||||||
$languageSelector,
|
$languageSelector,
|
||||||
// new TextField('RedirectURL', 'Redirect to URL', $this->RedirectURL),
|
// new TextField('RedirectURL', 'Redirect to URL', $this->RedirectURL),
|
||||||
new CheckboxField('DefaultSite', $this->fieldLabel('DefaultSite'), $this->DefaultSite),
|
CheckboxField::create('DefaultSite', $this->fieldLabel('DefaultSite'), $this->DefaultSite),
|
||||||
new CheckboxField('IsPublic', $this->fieldLabel('IsPublic'), $this->IsPublic),
|
CheckboxField::create('IsPublic', $this->fieldLabel('IsPublic'), $this->IsPublic),
|
||||||
|
|
||||||
new DropdownField('Theme', $this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme),
|
LiteralField::create(
|
||||||
|
|
||||||
|
|
||||||
new LiteralField(
|
|
||||||
'PageTypeBlacklistToggle',
|
'PageTypeBlacklistToggle',
|
||||||
sprintf(
|
sprintf(
|
||||||
'<div class="field"><a href="#" id="PageTypeBlacklistToggle">%s</a></div>',
|
'<div class="field"><a href="#" id="PageTypeBlacklistToggle">%s</a></div>',
|
||||||
_t('Subsite.PageTypeBlacklistField', 'Disallow page types?')
|
_t('Subsite.PageTypeBlacklistField', 'Disallow page types?')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
new CheckboxSetField(
|
CheckboxSetField::create(
|
||||||
'PageTypeBlacklist',
|
'PageTypeBlacklist',
|
||||||
false,
|
false,
|
||||||
$pageTypeMap
|
$pageTypeMap
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
new HiddenField('ID', '', $this->ID),
|
HiddenField::create('ID', '', $this->ID),
|
||||||
new HiddenField('IsSubsite', '', 1)
|
HiddenField::create('IsSubsite', '', 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
$subsiteTabs->addExtraClass('subsite-model');
|
// If there are any themes available, add the dropdown
|
||||||
|
$themes = $this->allowedThemes();
|
||||||
|
if (!empty($themes)) {
|
||||||
|
$fields->addFieldToTab('Root.Configuration',
|
||||||
|
DropdownField::create('Theme', $this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme)->setEmptyString(_t('Subsite.ThemeFieldEmptyString', '')), 'PageTypeBlacklistToggle');
|
||||||
|
}
|
||||||
|
|
||||||
|
$subsiteTabs->addExtraClass('subsite-model');
|
||||||
|
|
||||||
$this->extend('updateCMSFields', $fields);
|
$this->extend('updateCMSFields', $fields);
|
||||||
return $fields;
|
return $fields;
|
||||||
|
@ -72,6 +72,7 @@ en:
|
|||||||
PrimaryDomainFieldLabel: 'Primary Domain'
|
PrimaryDomainFieldLabel: 'Primary Domain'
|
||||||
RedirectURLFieldLabel: 'Redirect URL'
|
RedirectURLFieldLabel: 'Redirect URL'
|
||||||
ThemeFieldLabel: Theme
|
ThemeFieldLabel: Theme
|
||||||
|
ThemeFieldEmptyString: ''
|
||||||
TitleFieldLabel: 'Subsite Name'
|
TitleFieldLabel: 'Subsite Name'
|
||||||
SubsitesVirtualPage:
|
SubsitesVirtualPage:
|
||||||
DESCRIPTION: 'Displays the content of a page on another subsite'
|
DESCRIPTION: 'Displays the content of a page on another subsite'
|
||||||
|
Loading…
Reference in New Issue
Block a user