1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ilateral\SilverStripe\Carousel\Model; |
4
|
|
|
|
5
|
|
|
use SilverStripe\ORM\DataObject; |
6
|
|
|
use SilverStripe\Forms\LiteralField; |
7
|
|
|
use SilverStripe\Forms\NumericField; |
8
|
|
|
use SilverStripe\Forms\FieldGroup; |
9
|
|
|
use SilverStripe\Forms\CheckboxField; |
10
|
|
|
use SilverStripe\Forms\GridField\GridField; |
11
|
|
|
use SilverStripe\Forms\GridField\GridFieldAddNewButton; |
12
|
|
|
use Symbiote\GridFieldExtensions\GridFieldOrderableRows; |
13
|
|
|
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor; |
14
|
|
|
use SilverStripe\Assets\Image; |
15
|
|
|
use Sheadawson\Linkable\Models\Link; |
|
|
|
|
16
|
|
|
use Page; |
|
|
|
|
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Representation of a slide object that can be extended to add extra |
21
|
|
|
* data (such as links, additional content, etc) |
22
|
|
|
* |
23
|
|
|
* @author i-lateral (http://www.i-lateral.com) |
24
|
|
|
* @package carousel |
25
|
|
|
*/ |
26
|
|
|
class CarouselSlide extends DataObject |
27
|
|
|
{ |
28
|
|
|
|
29
|
|
|
private static $table_name = 'CarouselSlide'; |
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* DB Columns |
33
|
|
|
* |
34
|
|
|
* @var array |
35
|
|
|
* @config |
36
|
|
|
*/ |
37
|
|
|
private static $db = [ |
|
|
|
|
38
|
|
|
'Title' => 'Varchar(99)', |
39
|
|
|
'Sort' => 'Int' |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Has One relations |
44
|
|
|
* |
45
|
|
|
* @var array |
46
|
|
|
* @config |
47
|
|
|
*/ |
48
|
|
|
private static $has_one = [ |
|
|
|
|
49
|
|
|
'Parent' => Page::class, |
50
|
|
|
'Image' => Image::class, |
51
|
|
|
//'Link' => Link::class |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Ownership of relations |
56
|
|
|
* |
57
|
|
|
* @var array |
58
|
|
|
*/ |
59
|
|
|
private static $owns = [ |
|
|
|
|
60
|
|
|
'Image' |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Default casting for functions to templates |
65
|
|
|
* |
66
|
|
|
* @var array |
67
|
|
|
* @config |
68
|
|
|
*/ |
69
|
|
|
private static $casting = array( |
|
|
|
|
70
|
|
|
'Thumbnail' => 'Varchar' |
71
|
|
|
); |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Summary columns/fields for this object |
75
|
|
|
* |
76
|
|
|
* @var array |
77
|
|
|
* @config |
78
|
|
|
*/ |
79
|
|
|
private static $summary_fields = array( |
|
|
|
|
80
|
|
|
'Thumbnail' => 'Image', |
81
|
|
|
'Title' => 'Title' |
82
|
|
|
); |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Default sorting of this object |
86
|
|
|
* |
87
|
|
|
* @var string |
88
|
|
|
* @config |
89
|
|
|
*/ |
90
|
|
|
private static $default_sort = "Sort ASC"; |
|
|
|
|
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get fully rendered image for template |
94
|
|
|
* |
95
|
|
|
* @return HTMLText |
|
|
|
|
96
|
|
|
*/ |
97
|
|
|
public function getRenderedImage() |
98
|
|
|
{ |
99
|
|
|
$parent = $this->Parent(); |
|
|
|
|
100
|
|
|
$profile = $parent->CarouselProfile; |
101
|
|
|
|
102
|
|
|
return $this->Image->{$profile}(); |
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function getCMSFields() |
106
|
|
|
{ |
107
|
|
|
$fields = parent::getCMSFields(); |
108
|
|
|
|
109
|
|
|
$fields->removeByName('ParentID'); |
110
|
|
|
$fields->removeByName('Sort'); |
111
|
|
|
/*$fields->addFieldToTab( |
112
|
|
|
'Root.Main', |
113
|
|
|
LinkField::create('LinkID', 'Link to page or file') |
114
|
|
|
);*/ |
115
|
|
|
|
116
|
|
|
return $fields; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getThumbnail() |
120
|
|
|
{ |
121
|
|
|
if($this->Image()) { |
|
|
|
|
122
|
|
|
return $this->Image()->CMSThumbnail(); |
123
|
|
|
} else { |
124
|
|
|
return '(No Image)'; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Check parent permissions |
130
|
|
|
* |
131
|
|
|
* @return Boolean |
132
|
|
|
*/ |
133
|
|
|
public function canView($member = null) { |
134
|
|
|
$extended = $this->extend('canView', $member); |
135
|
|
|
if($extended && $extended !== null) return $extended; |
136
|
|
|
|
137
|
|
|
return $this->Parent()->canView($member); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Anyone can create a carousel slide |
142
|
|
|
* |
143
|
|
|
* @return Boolean |
144
|
|
|
*/ |
145
|
|
|
public function canCreate($member = null, $context = []) { |
146
|
|
|
$extended = $this->extend('canCreate', $member, $context); |
147
|
|
|
if($extended && $extended !== null) return $extended; |
148
|
|
|
|
149
|
|
|
return true; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Check parent permissions |
154
|
|
|
* |
155
|
|
|
* @return Boolean |
156
|
|
|
*/ |
157
|
|
|
public function canEdit($member = null) { |
158
|
|
|
$extended = $this->extend('canEdit', $member); |
159
|
|
|
if($extended && $extended !== null) return $extended; |
160
|
|
|
|
161
|
|
|
return $this->Parent()->canEdit($member); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Check parent permissions |
166
|
|
|
* |
167
|
|
|
* @return Boolean |
168
|
|
|
*/ |
169
|
|
|
public function canDelete($member = null) { |
170
|
|
|
$extended = $this->extend('canDelete', $member); |
171
|
|
|
if($extended && $extended !== null) return $extended; |
172
|
|
|
|
173
|
|
|
return $this->Parent()->canEdit($member); |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
|
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