@@ -27,147 +27,147 @@ |
||
27 | 27 | |
28 | 28 | class BasePage extends SiteTree |
29 | 29 | { |
30 | - private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png'; |
|
31 | - |
|
32 | - /** |
|
33 | - * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide" |
|
34 | - * |
|
35 | - * {@inheritDoc} |
|
36 | - */ |
|
37 | - private static $hide_ancestor = BasePage::class; |
|
38 | - |
|
39 | - private static $api_access = [ |
|
40 | - 'view' => [ |
|
41 | - 'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription', |
|
42 | - 'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID' |
|
43 | - ], |
|
44 | - 'edit' => [ |
|
45 | - 'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription', |
|
46 | - 'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID' |
|
47 | - ], |
|
48 | - ]; |
|
49 | - |
|
50 | - private static $table_name = 'BasePage'; |
|
51 | - |
|
52 | - /** |
|
53 | - * @config |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - private static $related_pages_title = 'Related pages'; |
|
57 | - |
|
58 | - private static $many_many = [ |
|
59 | - 'Terms' => TaxonomyTerm::class, |
|
60 | - 'RelatedPages' => BasePage::class, |
|
61 | - ]; |
|
62 | - |
|
63 | - /** |
|
64 | - * @var array |
|
65 | - * @config |
|
66 | - */ |
|
67 | - private static $many_many_extraFields = [ |
|
68 | - 'RelatedPages' => [ |
|
69 | - 'SortOrder' => DBInt::class, |
|
70 | - ], |
|
71 | - ]; |
|
72 | - |
|
73 | - private static $plural_name = 'Base Pages'; |
|
74 | - |
|
75 | - /** |
|
76 | - * Get the footer holder. |
|
77 | - */ |
|
78 | - public function getFooter() |
|
79 | - { |
|
80 | - return FooterHolder::get_one(FooterHolder::class); |
|
81 | - } |
|
82 | - |
|
83 | - public function RelatedPages() |
|
84 | - { |
|
85 | - return $this->getManyManyComponents('RelatedPages')->sort('SortOrder'); |
|
86 | - } |
|
87 | - |
|
88 | - public function RelatedPagesTitle() |
|
89 | - { |
|
90 | - return $this->config()->get('related_pages_title'); |
|
91 | - } |
|
92 | - |
|
93 | - public function getCMSFields() |
|
94 | - { |
|
95 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
96 | - // Related Pages |
|
97 | - $components = GridFieldConfig_RelationEditor::create(); |
|
98 | - $components->removeComponentsByType(GridFieldAddNewButton::class); |
|
99 | - $components->removeComponentsByType(GridFieldEditButton::class); |
|
100 | - $components->removeComponentsByType(GridFieldFilterHeader::class); |
|
101 | - $components->addComponent(new GridFieldOrderableRows('SortOrder')); |
|
102 | - |
|
103 | - /** @var GridFieldDataColumns $dataColumns */ |
|
104 | - $dataColumns = $components->getComponentByType(GridFieldDataColumns::class); |
|
105 | - $dataColumns->setDisplayFields([ |
|
106 | - 'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'), |
|
107 | - 'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type') |
|
108 | - ]); |
|
109 | - |
|
110 | - $fields->findOrMakeTab( |
|
111 | - 'Root.RelatedPages', |
|
112 | - _t(__CLASS__ . '.RelatedPages', 'Related pages') |
|
113 | - ); |
|
114 | - $fields->addFieldToTab( |
|
115 | - 'Root.RelatedPages', |
|
116 | - GridField::create( |
|
117 | - 'RelatedPages', |
|
118 | - _t(__CLASS__ . '.RelatedPages', 'Related pages'), |
|
119 | - $this->RelatedPages(), |
|
120 | - $components |
|
121 | - ) |
|
122 | - ); |
|
123 | - |
|
124 | - // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc) |
|
125 | - $hasMany = $this->hasMany(); |
|
126 | - $manyMany = $this->manyMany(); |
|
127 | - if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) { |
|
128 | - $components = GridFieldConfig_RelationEditor::create(); |
|
129 | - $components->removeComponentsByType(GridFieldAddNewButton::class); |
|
130 | - $components->removeComponentsByType(GridFieldEditButton::class); |
|
131 | - |
|
132 | - /** @var GridFieldAddExistingAutocompleter $autoCompleter */ |
|
133 | - $autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class); |
|
134 | - $autoCompleter->setResultsFormat('$Name ($TaxonomyName)'); |
|
135 | - |
|
136 | - /** @var GridFieldDataColumns $dataColumns */ |
|
137 | - $dataColumns = $components->getComponentByType(GridFieldDataColumns::class); |
|
138 | - $dataColumns->setDisplayFields([ |
|
139 | - 'Name' => _t(__CLASS__ . '.Term', 'Term'), |
|
140 | - 'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy') |
|
141 | - ]); |
|
142 | - |
|
143 | - $fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags')); |
|
144 | - $fields->addFieldToTab( |
|
145 | - 'Root.Tags', |
|
146 | - TreeMultiselectField::create( |
|
147 | - 'Terms', |
|
148 | - _t(__CLASS__ . '.Terms', 'Terms'), |
|
149 | - TaxonomyTerm::class |
|
150 | - )->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms')) |
|
151 | - ); |
|
152 | - } |
|
153 | - }); |
|
154 | - return parent::getCMSFields(); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Returns the native language name for the selected locale/language, empty string if Fluent is not available |
|
159 | - * |
|
160 | - * @return string |
|
161 | - */ |
|
162 | - public function getSelectedLanguage() |
|
163 | - { |
|
164 | - if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) { |
|
165 | - return ''; |
|
166 | - } |
|
167 | - |
|
168 | - /** @var ArrayData $information */ |
|
169 | - $information = $this->LocaleInformation(FluentState::singleton()->getLocale()); |
|
170 | - |
|
171 | - return $information->LanguageNative; |
|
172 | - } |
|
30 | + private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png'; |
|
31 | + |
|
32 | + /** |
|
33 | + * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide" |
|
34 | + * |
|
35 | + * {@inheritDoc} |
|
36 | + */ |
|
37 | + private static $hide_ancestor = BasePage::class; |
|
38 | + |
|
39 | + private static $api_access = [ |
|
40 | + 'view' => [ |
|
41 | + 'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription', |
|
42 | + 'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID' |
|
43 | + ], |
|
44 | + 'edit' => [ |
|
45 | + 'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription', |
|
46 | + 'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID' |
|
47 | + ], |
|
48 | + ]; |
|
49 | + |
|
50 | + private static $table_name = 'BasePage'; |
|
51 | + |
|
52 | + /** |
|
53 | + * @config |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + private static $related_pages_title = 'Related pages'; |
|
57 | + |
|
58 | + private static $many_many = [ |
|
59 | + 'Terms' => TaxonomyTerm::class, |
|
60 | + 'RelatedPages' => BasePage::class, |
|
61 | + ]; |
|
62 | + |
|
63 | + /** |
|
64 | + * @var array |
|
65 | + * @config |
|
66 | + */ |
|
67 | + private static $many_many_extraFields = [ |
|
68 | + 'RelatedPages' => [ |
|
69 | + 'SortOrder' => DBInt::class, |
|
70 | + ], |
|
71 | + ]; |
|
72 | + |
|
73 | + private static $plural_name = 'Base Pages'; |
|
74 | + |
|
75 | + /** |
|
76 | + * Get the footer holder. |
|
77 | + */ |
|
78 | + public function getFooter() |
|
79 | + { |
|
80 | + return FooterHolder::get_one(FooterHolder::class); |
|
81 | + } |
|
82 | + |
|
83 | + public function RelatedPages() |
|
84 | + { |
|
85 | + return $this->getManyManyComponents('RelatedPages')->sort('SortOrder'); |
|
86 | + } |
|
87 | + |
|
88 | + public function RelatedPagesTitle() |
|
89 | + { |
|
90 | + return $this->config()->get('related_pages_title'); |
|
91 | + } |
|
92 | + |
|
93 | + public function getCMSFields() |
|
94 | + { |
|
95 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
96 | + // Related Pages |
|
97 | + $components = GridFieldConfig_RelationEditor::create(); |
|
98 | + $components->removeComponentsByType(GridFieldAddNewButton::class); |
|
99 | + $components->removeComponentsByType(GridFieldEditButton::class); |
|
100 | + $components->removeComponentsByType(GridFieldFilterHeader::class); |
|
101 | + $components->addComponent(new GridFieldOrderableRows('SortOrder')); |
|
102 | + |
|
103 | + /** @var GridFieldDataColumns $dataColumns */ |
|
104 | + $dataColumns = $components->getComponentByType(GridFieldDataColumns::class); |
|
105 | + $dataColumns->setDisplayFields([ |
|
106 | + 'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'), |
|
107 | + 'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type') |
|
108 | + ]); |
|
109 | + |
|
110 | + $fields->findOrMakeTab( |
|
111 | + 'Root.RelatedPages', |
|
112 | + _t(__CLASS__ . '.RelatedPages', 'Related pages') |
|
113 | + ); |
|
114 | + $fields->addFieldToTab( |
|
115 | + 'Root.RelatedPages', |
|
116 | + GridField::create( |
|
117 | + 'RelatedPages', |
|
118 | + _t(__CLASS__ . '.RelatedPages', 'Related pages'), |
|
119 | + $this->RelatedPages(), |
|
120 | + $components |
|
121 | + ) |
|
122 | + ); |
|
123 | + |
|
124 | + // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc) |
|
125 | + $hasMany = $this->hasMany(); |
|
126 | + $manyMany = $this->manyMany(); |
|
127 | + if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) { |
|
128 | + $components = GridFieldConfig_RelationEditor::create(); |
|
129 | + $components->removeComponentsByType(GridFieldAddNewButton::class); |
|
130 | + $components->removeComponentsByType(GridFieldEditButton::class); |
|
131 | + |
|
132 | + /** @var GridFieldAddExistingAutocompleter $autoCompleter */ |
|
133 | + $autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class); |
|
134 | + $autoCompleter->setResultsFormat('$Name ($TaxonomyName)'); |
|
135 | + |
|
136 | + /** @var GridFieldDataColumns $dataColumns */ |
|
137 | + $dataColumns = $components->getComponentByType(GridFieldDataColumns::class); |
|
138 | + $dataColumns->setDisplayFields([ |
|
139 | + 'Name' => _t(__CLASS__ . '.Term', 'Term'), |
|
140 | + 'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy') |
|
141 | + ]); |
|
142 | + |
|
143 | + $fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags')); |
|
144 | + $fields->addFieldToTab( |
|
145 | + 'Root.Tags', |
|
146 | + TreeMultiselectField::create( |
|
147 | + 'Terms', |
|
148 | + _t(__CLASS__ . '.Terms', 'Terms'), |
|
149 | + TaxonomyTerm::class |
|
150 | + )->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms')) |
|
151 | + ); |
|
152 | + } |
|
153 | + }); |
|
154 | + return parent::getCMSFields(); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Returns the native language name for the selected locale/language, empty string if Fluent is not available |
|
159 | + * |
|
160 | + * @return string |
|
161 | + */ |
|
162 | + public function getSelectedLanguage() |
|
163 | + { |
|
164 | + if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) { |
|
165 | + return ''; |
|
166 | + } |
|
167 | + |
|
168 | + /** @var ArrayData $information */ |
|
169 | + $information = $this->LocaleInformation(FluentState::singleton()->getLocale()); |
|
170 | + |
|
171 | + return $information->LanguageNative; |
|
172 | + } |
|
173 | 173 | } |
@@ -26,137 +26,137 @@ |
||
26 | 26 | */ |
27 | 27 | class BaseHomePage extends Page |
28 | 28 | { |
29 | - private static $icon = 'cwp/cwp:images/icons/sitetree_images/home.png'; |
|
30 | - |
|
31 | - private static $hide_ancestor = BaseHomePage::class; |
|
32 | - |
|
33 | - private static $singular_name = 'Home Page'; |
|
34 | - |
|
35 | - private static $plural_name = 'Home Pages'; |
|
36 | - |
|
37 | - private static $table_name = 'BaseHomePage'; |
|
38 | - |
|
39 | - private static $db = [ |
|
40 | - 'FeatureOneTitle' => 'Varchar(255)', |
|
41 | - 'FeatureOneCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')", |
|
42 | - 'FeatureOneContent' => 'HTMLText', |
|
43 | - 'FeatureOneButtonText' => 'Varchar(255)', |
|
44 | - 'FeatureTwoTitle' => 'Varchar(255)', |
|
45 | - 'FeatureTwoCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')", |
|
46 | - 'FeatureTwoContent' => 'HTMLText', |
|
47 | - 'FeatureTwoButtonText' => 'Varchar(255)' |
|
48 | - ]; |
|
49 | - |
|
50 | - private static $has_one = [ |
|
51 | - 'LearnMorePage' => SiteTree::class, |
|
52 | - 'FeatureOneLink' => SiteTree::class, |
|
53 | - 'FeatureTwoLink' => SiteTree::class, |
|
54 | - ]; |
|
55 | - |
|
56 | - private static $has_many = [ |
|
57 | - 'Quicklinks' => Quicklink::class . '.Parent', |
|
58 | - ]; |
|
59 | - |
|
60 | - public function Quicklinks() |
|
61 | - { |
|
62 | - return $this->getComponents('Quicklinks')->sort('SortOrder'); |
|
63 | - } |
|
64 | - |
|
65 | - public function getCMSFields() |
|
66 | - { |
|
67 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
68 | - // Main Content tab |
|
69 | - $fields->addFieldToTab( |
|
70 | - 'Root.Main', |
|
71 | - TreeDropdownField::create( |
|
72 | - 'LearnMorePageID', |
|
73 | - _t(__CLASS__ . '.LearnMoreLink', 'Page to link the "Learn More" button to:'), |
|
74 | - SiteTree::class |
|
75 | - ), |
|
76 | - 'Metadata' |
|
77 | - ); |
|
78 | - |
|
79 | - $gridField = GridField::create( |
|
80 | - 'Quicklinks', |
|
81 | - 'Quicklinks', |
|
82 | - $this->Quicklinks(), |
|
83 | - GridFieldConfig_RelationEditor::create() |
|
84 | - ); |
|
85 | - $gridConfig = $gridField->getConfig(); |
|
86 | - $gridConfig->getComponentByType(GridFieldAddNewButton::class)->setButtonName( |
|
87 | - _t(__CLASS__ . '.AddNewButton', 'Add new') |
|
88 | - ); |
|
89 | - |
|
90 | - $injector = Injector::inst(); |
|
91 | - |
|
92 | - $gridConfig->removeComponentsByType(GridFieldAddExistingAutocompleter::class); |
|
93 | - $gridConfig->removeComponentsByType(GridFieldDeleteAction::class); |
|
94 | - $gridConfig->addComponent($injector->create(GridFieldDeleteAction::class)); |
|
95 | - $gridConfig->addComponent($injector->create(GridFieldOrderableRows::class, 'SortOrder')); |
|
96 | - $gridField->setModelClass(Quicklink::class); |
|
97 | - |
|
98 | - $fields->addFieldToTab('Root.Quicklinks', $gridField); |
|
99 | - |
|
100 | - $fields->removeByName('Import'); |
|
101 | - |
|
102 | - $fields->addFieldToTab( |
|
103 | - 'Root.Features', |
|
104 | - ToggleCompositeField::create( |
|
105 | - 'FeatureOne', |
|
106 | - _t(__CLASS__ . '.FeatureOne', 'Feature One'), |
|
107 | - array( |
|
108 | - TextField::create('FeatureOneTitle', _t(__CLASS__ . '.Title', 'Title')), |
|
109 | - $dropdownField = DropdownField::create( |
|
110 | - 'FeatureOneCategory', |
|
111 | - _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'), |
|
112 | - singleton(BaseHomePage::class)->dbObject('FeatureOneCategory')->enumValues() |
|
113 | - ), |
|
114 | - HTMLEditorField::create( |
|
115 | - 'FeatureOneContent', |
|
116 | - _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content') |
|
117 | - ), |
|
118 | - TextField::create( |
|
119 | - 'FeatureOneButtonText', |
|
120 | - _t(__CLASS__ . '.FeatureButtonText', 'Button text') |
|
121 | - ), |
|
122 | - TreeDropdownField::create( |
|
123 | - 'FeatureOneLinkID', |
|
124 | - _t(__CLASS__ . '.FeatureLink', 'Page to link to'), |
|
125 | - SiteTree::class |
|
126 | - )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in')) |
|
127 | - ) |
|
128 | - )->setHeadingLevel(3) |
|
129 | - ); |
|
130 | - $dropdownField->setEmptyString('none'); |
|
131 | - |
|
132 | - $fields->addFieldToTab('Root.Features', ToggleCompositeField::create( |
|
133 | - 'FeatureTwo', |
|
134 | - _t(__CLASS__ . '.FeatureTwo', 'Feature Two'), |
|
135 | - array( |
|
136 | - TextField::create('FeatureTwoTitle', _t(__CLASS__ . '.Title', 'Title')), |
|
137 | - $dropdownField = DropdownField::create( |
|
138 | - 'FeatureTwoCategory', |
|
139 | - _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'), |
|
140 | - singleton(BaseHomePage::class)->dbObject('FeatureTwoCategory')->enumValues() |
|
141 | - ), |
|
142 | - HTMLEditorField::create( |
|
143 | - 'FeatureTwoContent', |
|
144 | - _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content') |
|
145 | - ), |
|
146 | - TextField::create( |
|
147 | - 'FeatureTwoButtonText', |
|
148 | - _t(__CLASS__ . '.FeatureButtonText', 'Button text') |
|
149 | - ), |
|
150 | - TreeDropdownField::create( |
|
151 | - 'FeatureTwoLinkID', |
|
152 | - _t(__CLASS__ . '.FeatureLink', 'Page to link to'), |
|
153 | - SiteTree::class |
|
154 | - )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in')) |
|
155 | - ) |
|
156 | - )->setHeadingLevel(3)); |
|
157 | - $dropdownField->setEmptyString('none'); |
|
158 | - }); |
|
159 | - |
|
160 | - return parent::getCMSFields(); |
|
161 | - } |
|
29 | + private static $icon = 'cwp/cwp:images/icons/sitetree_images/home.png'; |
|
30 | + |
|
31 | + private static $hide_ancestor = BaseHomePage::class; |
|
32 | + |
|
33 | + private static $singular_name = 'Home Page'; |
|
34 | + |
|
35 | + private static $plural_name = 'Home Pages'; |
|
36 | + |
|
37 | + private static $table_name = 'BaseHomePage'; |
|
38 | + |
|
39 | + private static $db = [ |
|
40 | + 'FeatureOneTitle' => 'Varchar(255)', |
|
41 | + 'FeatureOneCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')", |
|
42 | + 'FeatureOneContent' => 'HTMLText', |
|
43 | + 'FeatureOneButtonText' => 'Varchar(255)', |
|
44 | + 'FeatureTwoTitle' => 'Varchar(255)', |
|
45 | + 'FeatureTwoCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')", |
|
46 | + 'FeatureTwoContent' => 'HTMLText', |
|
47 | + 'FeatureTwoButtonText' => 'Varchar(255)' |
|
48 | + ]; |
|
49 | + |
|
50 | + private static $has_one = [ |
|
51 | + 'LearnMorePage' => SiteTree::class, |
|
52 | + 'FeatureOneLink' => SiteTree::class, |
|
53 | + 'FeatureTwoLink' => SiteTree::class, |
|
54 | + ]; |
|
55 | + |
|
56 | + private static $has_many = [ |
|
57 | + 'Quicklinks' => Quicklink::class . '.Parent', |
|
58 | + ]; |
|
59 | + |
|
60 | + public function Quicklinks() |
|
61 | + { |
|
62 | + return $this->getComponents('Quicklinks')->sort('SortOrder'); |
|
63 | + } |
|
64 | + |
|
65 | + public function getCMSFields() |
|
66 | + { |
|
67 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
68 | + // Main Content tab |
|
69 | + $fields->addFieldToTab( |
|
70 | + 'Root.Main', |
|
71 | + TreeDropdownField::create( |
|
72 | + 'LearnMorePageID', |
|
73 | + _t(__CLASS__ . '.LearnMoreLink', 'Page to link the "Learn More" button to:'), |
|
74 | + SiteTree::class |
|
75 | + ), |
|
76 | + 'Metadata' |
|
77 | + ); |
|
78 | + |
|
79 | + $gridField = GridField::create( |
|
80 | + 'Quicklinks', |
|
81 | + 'Quicklinks', |
|
82 | + $this->Quicklinks(), |
|
83 | + GridFieldConfig_RelationEditor::create() |
|
84 | + ); |
|
85 | + $gridConfig = $gridField->getConfig(); |
|
86 | + $gridConfig->getComponentByType(GridFieldAddNewButton::class)->setButtonName( |
|
87 | + _t(__CLASS__ . '.AddNewButton', 'Add new') |
|
88 | + ); |
|
89 | + |
|
90 | + $injector = Injector::inst(); |
|
91 | + |
|
92 | + $gridConfig->removeComponentsByType(GridFieldAddExistingAutocompleter::class); |
|
93 | + $gridConfig->removeComponentsByType(GridFieldDeleteAction::class); |
|
94 | + $gridConfig->addComponent($injector->create(GridFieldDeleteAction::class)); |
|
95 | + $gridConfig->addComponent($injector->create(GridFieldOrderableRows::class, 'SortOrder')); |
|
96 | + $gridField->setModelClass(Quicklink::class); |
|
97 | + |
|
98 | + $fields->addFieldToTab('Root.Quicklinks', $gridField); |
|
99 | + |
|
100 | + $fields->removeByName('Import'); |
|
101 | + |
|
102 | + $fields->addFieldToTab( |
|
103 | + 'Root.Features', |
|
104 | + ToggleCompositeField::create( |
|
105 | + 'FeatureOne', |
|
106 | + _t(__CLASS__ . '.FeatureOne', 'Feature One'), |
|
107 | + array( |
|
108 | + TextField::create('FeatureOneTitle', _t(__CLASS__ . '.Title', 'Title')), |
|
109 | + $dropdownField = DropdownField::create( |
|
110 | + 'FeatureOneCategory', |
|
111 | + _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'), |
|
112 | + singleton(BaseHomePage::class)->dbObject('FeatureOneCategory')->enumValues() |
|
113 | + ), |
|
114 | + HTMLEditorField::create( |
|
115 | + 'FeatureOneContent', |
|
116 | + _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content') |
|
117 | + ), |
|
118 | + TextField::create( |
|
119 | + 'FeatureOneButtonText', |
|
120 | + _t(__CLASS__ . '.FeatureButtonText', 'Button text') |
|
121 | + ), |
|
122 | + TreeDropdownField::create( |
|
123 | + 'FeatureOneLinkID', |
|
124 | + _t(__CLASS__ . '.FeatureLink', 'Page to link to'), |
|
125 | + SiteTree::class |
|
126 | + )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in')) |
|
127 | + ) |
|
128 | + )->setHeadingLevel(3) |
|
129 | + ); |
|
130 | + $dropdownField->setEmptyString('none'); |
|
131 | + |
|
132 | + $fields->addFieldToTab('Root.Features', ToggleCompositeField::create( |
|
133 | + 'FeatureTwo', |
|
134 | + _t(__CLASS__ . '.FeatureTwo', 'Feature Two'), |
|
135 | + array( |
|
136 | + TextField::create('FeatureTwoTitle', _t(__CLASS__ . '.Title', 'Title')), |
|
137 | + $dropdownField = DropdownField::create( |
|
138 | + 'FeatureTwoCategory', |
|
139 | + _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'), |
|
140 | + singleton(BaseHomePage::class)->dbObject('FeatureTwoCategory')->enumValues() |
|
141 | + ), |
|
142 | + HTMLEditorField::create( |
|
143 | + 'FeatureTwoContent', |
|
144 | + _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content') |
|
145 | + ), |
|
146 | + TextField::create( |
|
147 | + 'FeatureTwoButtonText', |
|
148 | + _t(__CLASS__ . '.FeatureButtonText', 'Button text') |
|
149 | + ), |
|
150 | + TreeDropdownField::create( |
|
151 | + 'FeatureTwoLinkID', |
|
152 | + _t(__CLASS__ . '.FeatureLink', 'Page to link to'), |
|
153 | + SiteTree::class |
|
154 | + )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in')) |
|
155 | + ) |
|
156 | + )->setHeadingLevel(3)); |
|
157 | + $dropdownField->setEmptyString('none'); |
|
158 | + }); |
|
159 | + |
|
160 | + return parent::getCMSFields(); |
|
161 | + } |
|
162 | 162 | } |