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
|
|
|
* Set to false to prevent an in-line edit form from showing in an elemental area. Instead the element will be |
37
|
|
|
* clickable and a GridFieldDetailForm will be used. |
38
|
|
|
* |
39
|
|
|
* @config |
40
|
|
|
* @var bool |
41
|
|
|
*/ |
42
|
|
|
private static $inline_editable = false; |
|
|
|
|
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private static $slide_tab_title = 'Main'; |
|
|
|
|
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param bool $includerelations |
51
|
|
|
* @return array |
52
|
|
|
*/ |
53
|
1 |
|
public function fieldLabels($includerelations = true) |
54
|
|
|
{ |
55
|
1 |
|
$labels = parent::fieldLabels($includerelations); |
56
|
|
|
|
57
|
1 |
|
$labels['Content'] = _t(__CLASS__.'.ContentLabel', 'Description'); |
58
|
|
|
|
59
|
1 |
|
return $labels; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return FieldList |
64
|
|
|
*/ |
65
|
|
|
public function getCMSFields() |
66
|
|
|
{ |
67
|
1 |
|
$this->beforeUpdateCMSFields(function (FieldList $fields) { |
68
|
1 |
|
$fields->dataFieldByName('Content') |
69
|
1 |
|
->setRows(5) |
70
|
1 |
|
->setDescription(_t(__CLASS__ . '.ContentDescription', 'optional. Add introductory copy to your slideshow.')); |
71
|
1 |
|
}); |
72
|
|
|
|
73
|
1 |
|
return parent::getCMSFields(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return \SilverStripe\ORM\FieldType\DBHTMLText |
78
|
|
|
*/ |
79
|
1 |
|
public function getSummary() |
80
|
|
|
{ |
81
|
1 |
|
$count = $this->Slides()->count(); |
|
|
|
|
82
|
1 |
|
$label = _t( |
83
|
1 |
|
SlideImage::class . '.PLURALS', |
84
|
1 |
|
'{count} Slide|{count} Slides', |
85
|
1 |
|
[ 'count' => $count ] |
86
|
|
|
); |
87
|
1 |
|
return DBField::create_field('HTMLText', $label)->Summary(20); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return array |
92
|
|
|
*/ |
93
|
|
|
protected function provideBlockSchema() |
94
|
|
|
{ |
95
|
|
|
$blockSchema = parent::provideBlockSchema(); |
96
|
|
|
$blockSchema['content'] = $this->getSummary(); |
97
|
|
|
return $blockSchema; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
1 |
|
public function getType() |
104
|
|
|
{ |
105
|
1 |
|
return _t(__CLASS__.'.BlockType', 'Slideshow'); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|