|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dynamic\Elements\Flexslider\Elements; |
|
4
|
|
|
|
|
5
|
|
|
use DNADesign\Elemental\Models\BaseElement; |
|
6
|
|
|
use Dynamic\FlexSlider\Model\SlideImage; |
|
7
|
|
|
use SilverStripe\Forms\FieldList; |
|
8
|
|
|
use SilverStripe\ORM\FieldType\DBField; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class ElementSlideshow |
|
12
|
|
|
* @package Dynamic\Elements\Flexslider\Elements |
|
13
|
|
|
* |
|
14
|
|
|
* @property string Content |
|
15
|
|
|
*/ |
|
16
|
|
|
class ElementSlideshow extends BaseElement |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
private static $icon = 'font-icon-block-carousel'; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private static $table_name = 'ElementSlideshow'; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var array |
|
30
|
|
|
*/ |
|
31
|
|
|
private static $db = [ |
|
|
|
|
|
|
32
|
|
|
'Content' => 'HTMLText', |
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var array |
|
37
|
|
|
*/ |
|
38
|
|
|
private static $owns = [ |
|
|
|
|
|
|
39
|
|
|
'Slides', |
|
40
|
|
|
]; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var bool |
|
44
|
|
|
*/ |
|
45
|
|
|
private static $inline_editable = false; |
|
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
private static $slide_tab_title = 'Main'; |
|
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param bool $includerelations |
|
54
|
|
|
* @return array |
|
55
|
|
|
*/ |
|
56
|
1 |
|
public function fieldLabels($includerelations = true) |
|
57
|
|
|
{ |
|
58
|
1 |
|
$labels = parent::fieldLabels($includerelations); |
|
59
|
|
|
|
|
60
|
1 |
|
$labels['Content'] = _t(__CLASS__.'.ContentLabel', 'Description'); |
|
61
|
|
|
|
|
62
|
1 |
|
return $labels; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return FieldList |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getCMSFields() |
|
69
|
|
|
{ |
|
70
|
1 |
|
$this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
71
|
1 |
|
$fields->dataFieldByName('Content') |
|
72
|
1 |
|
->setRows(5) |
|
73
|
1 |
|
->setDescription(_t( |
|
74
|
1 |
|
__CLASS__ . '.ContentDescription', |
|
75
|
1 |
|
'optional. Add introductory copy to your slideshow.' |
|
76
|
|
|
)); |
|
77
|
1 |
|
}); |
|
78
|
|
|
|
|
79
|
1 |
|
return parent::getCMSFields(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return \SilverStripe\ORM\FieldType\DBHTMLText |
|
84
|
|
|
*/ |
|
85
|
1 |
|
public function getSummary() |
|
86
|
|
|
{ |
|
87
|
1 |
|
$count = $this->Slides()->count(); |
|
|
|
|
|
|
88
|
1 |
|
$label = _t( |
|
89
|
1 |
|
SlideImage::class . '.PLURALS', |
|
90
|
1 |
|
'{count} Slide|{count} Slides', |
|
91
|
1 |
|
[ 'count' => $count ] |
|
92
|
|
|
); |
|
93
|
1 |
|
return DBField::create_field('HTMLText', $label)->Summary(20); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @return array |
|
98
|
|
|
*/ |
|
99
|
|
|
protected function provideBlockSchema() |
|
100
|
|
|
{ |
|
101
|
|
|
$blockSchema = parent::provideBlockSchema(); |
|
102
|
|
|
$blockSchema['content'] = $this->getSummary(); |
|
103
|
|
|
return $blockSchema; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return string |
|
108
|
|
|
*/ |
|
109
|
1 |
|
public function getType() |
|
110
|
|
|
{ |
|
111
|
1 |
|
return _t(__CLASS__.'.BlockType', 'Slideshow'); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|