1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CWP\AgencyExtensions\Model; |
4
|
|
|
|
5
|
|
|
use CWP\CWP\PageTypes\BaseHomePage; |
6
|
|
|
use SilverStripe\Forms\HTMLEditor\HTMLEditorField; |
7
|
|
|
use SilverStripe\Versioned\Versioned; |
8
|
|
|
use SilverStripe\Core\Injector\Injector; |
9
|
|
|
use SilverStripe\Assets\Image; |
10
|
|
|
use SilverStripe\CMS\Model\SiteTree; |
11
|
|
|
use SilverStripe\Forms\TextField; |
12
|
|
|
use SilverStripe\AssetAdmin\Forms\UploadField; |
|
|
|
|
13
|
|
|
use SilverStripe\Forms\TreeDropdownField; |
14
|
|
|
use SilverStripe\Forms\LabelField; |
15
|
|
|
use SilverStripe\Forms\CheckboxField; |
16
|
|
|
use SilverStripe\Forms\CompositeField; |
17
|
|
|
use SilverStripe\Forms\FieldList; |
18
|
|
|
use SilverStripe\ORM\DataObject; |
19
|
|
|
use SilverStripe\Forms\FileHandleField; |
20
|
|
|
|
21
|
|
|
class CarouselItem extends DataObject |
22
|
|
|
{ |
23
|
|
|
private static $table_name = 'CarouselItem'; |
|
|
|
|
24
|
|
|
|
25
|
|
|
private static $extensions = [ |
|
|
|
|
26
|
|
|
Versioned::class |
27
|
|
|
]; |
28
|
|
|
|
29
|
|
|
private static $versioned_gridfield_extensions = true; |
|
|
|
|
30
|
|
|
|
31
|
|
|
private static $db = [ |
|
|
|
|
32
|
|
|
'Title' => 'Varchar(255)', |
33
|
|
|
'Content' => 'HTMLText', |
34
|
|
|
'SortOrder' => 'Int', |
35
|
|
|
'PrimaryCallToActionLabel' => 'Varchar(255)', |
36
|
|
|
'SecondaryCallToActionLabel' => 'Varchar(255)' |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
private static $has_one = [ |
|
|
|
|
40
|
|
|
'Parent' => BaseHomePage::class, |
41
|
|
|
'Image' => Image::class, |
42
|
|
|
'PrimaryCallToAction' => SiteTree::class, |
43
|
|
|
'SecondaryCallToAction' => SiteTree::class |
44
|
|
|
]; |
45
|
|
|
|
46
|
|
|
private static $owns = [ |
|
|
|
|
47
|
|
|
'Image' |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
private static $summary_fields = [ |
|
|
|
|
51
|
|
|
'Image.CMSThumbnail' => 'Image', |
52
|
|
|
'Title' => 'Title', |
53
|
|
|
'Content.FirstSentence' => 'Text', |
54
|
|
|
'PrimaryCallToAction.Title' => 'Primary CTA', |
55
|
|
|
'SecondaryCallToAction.Title' => 'Secondary CTA' |
56
|
|
|
]; |
57
|
|
|
|
58
|
|
|
private static $searchable_fields = [ |
|
|
|
|
59
|
|
|
'Title', |
60
|
|
|
'Content' |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
public function getCMSFields() |
64
|
|
|
{ |
65
|
|
|
$fields = new FieldList( |
66
|
|
|
// Set title |
67
|
|
|
TextField::create('Title', 'Title', null, 255), |
68
|
|
|
// Content |
69
|
|
|
HtmlEditorField::create('Content') |
70
|
|
|
->setRows(5) |
71
|
|
|
->setDescription( |
72
|
|
|
_t( |
73
|
|
|
__CLASS__ . '.CONTENT_HELPTIP', |
74
|
|
|
'Recommended: Use less than 50 words. For carousel slides, use a similar amount of content ' . |
75
|
|
|
'as other items to ensure carousel height does not vary.' |
76
|
|
|
) |
77
|
|
|
), |
78
|
|
|
// Image |
79
|
|
|
Injector::inst()->create(FileHandleField::class, 'Image', 'Image') |
80
|
|
|
->setAllowedFileCategories('image') |
81
|
|
|
->setDescription( |
82
|
|
|
_t( |
83
|
|
|
__CLASS__ . '.IMAGE_HELPTIP', |
84
|
|
|
'Recommended: Use high resolution images greater than 1600x900px.' |
85
|
|
|
) |
86
|
|
|
), |
87
|
|
|
// Call to actions |
88
|
|
|
TextField::create('PrimaryCallToActionLabel'), |
89
|
|
|
TreeDropdownField::create( |
90
|
|
|
'PrimaryCallToActionID', |
91
|
|
|
_t(__CLASS__ . '.PRIMARYCALLTOACTION', 'Primary Call To Action Link'), |
92
|
|
|
SiteTree::class |
93
|
|
|
), |
94
|
|
|
TextField::create('SecondaryCallToActionLabel'), |
95
|
|
|
TreeDropdownField::create( |
96
|
|
|
'SecondaryCallToActionID', |
97
|
|
|
_t(__CLASS__ . '.SECONDARYCALLTOACTION', 'Secondary Call To Action Link'), |
98
|
|
|
SiteTree::class |
99
|
|
|
) |
100
|
|
|
); |
101
|
|
|
|
102
|
|
|
$this->extend('updateCMSFields', $fields); |
103
|
|
|
|
104
|
|
|
return $fields; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function canCreate($member = null, $context = array()) |
108
|
|
|
{ |
109
|
|
|
return $this->Parent()->canCreate($member); |
|
|
|
|
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function canEdit($member = null) |
113
|
|
|
{ |
114
|
|
|
return $this->Parent()->canEdit($member); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function canDelete($member = null) |
118
|
|
|
{ |
119
|
|
|
return $this->Parent()->canDelete($member); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function canView($member = null) |
123
|
|
|
{ |
124
|
|
|
return $this->Parent()->canView($member); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|
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