|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CWP\CWP\PageTypes; |
|
4
|
|
|
|
|
5
|
|
|
use CWP\CWP\Model\Quicklink; |
|
6
|
|
|
use Page; |
|
|
|
|
|
|
7
|
|
|
use SilverStripe\CMS\Model\SiteTree; |
|
8
|
|
|
use SilverStripe\Core\Injector\Injector; |
|
9
|
|
|
use SilverStripe\Forms\DropdownField; |
|
10
|
|
|
use SilverStripe\Forms\FieldList; |
|
11
|
|
|
use SilverStripe\Forms\GridField\GridField; |
|
12
|
|
|
use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter; |
|
13
|
|
|
use SilverStripe\Forms\GridField\GridFieldAddNewButton; |
|
14
|
|
|
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; |
|
15
|
|
|
use SilverStripe\Forms\GridField\GridFieldDeleteAction; |
|
16
|
|
|
use SilverStripe\Forms\HTMLEditor\HTMLEditorField; |
|
17
|
|
|
use SilverStripe\Forms\TextField; |
|
18
|
|
|
use SilverStripe\Forms\ToggleCompositeField; |
|
19
|
|
|
use SilverStripe\Forms\TreeDropdownField; |
|
20
|
|
|
use Symbiote\GridFieldExtensions\GridFieldOrderableRows; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* **BaseHomePage** is the basic home page. |
|
24
|
|
|
* By default it is hidden from the CMS - we rely on developers creating their own |
|
25
|
|
|
* `HomePage` class in the `mysite/code` which will extend from the **BaseHomePage**. |
|
26
|
|
|
*/ |
|
27
|
|
|
class BaseHomePage extends Page |
|
28
|
|
|
{ |
|
29
|
|
|
private static $icon_class = 'font-icon-p-home'; |
|
|
|
|
|
|
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
|
|
|
} |
|
163
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths