1 | <?php |
||
2 | |||
3 | namespace DNADesign\Elemental\Models; |
||
4 | |||
5 | use SilverStripe\Forms\FieldList; |
||
6 | use SilverStripe\Forms\HTMLEditor\HTMLEditorField; |
||
7 | use SilverStripe\Forms\HTMLEditor\TinyMCEConfig; |
||
8 | use SilverStripe\ORM\FieldType\DBField; |
||
9 | |||
10 | class ElementContent extends BaseElement |
||
11 | { |
||
12 | private static $icon = 'font-icon-block-content'; |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
13 | |||
14 | private static $db = [ |
||
15 | 'HTML' => 'HTMLText' |
||
16 | ]; |
||
17 | |||
18 | private static $table_name = 'ElementContent'; |
||
19 | |||
20 | private static $singular_name = 'content block'; |
||
0 ignored issues
–
show
|
|||
21 | |||
22 | private static $plural_name = 'content blocks'; |
||
0 ignored issues
–
show
|
|||
23 | |||
24 | private static $description = 'HTML text block'; |
||
0 ignored issues
–
show
|
|||
25 | |||
26 | /** |
||
27 | * Re-title the HTML field to Content |
||
28 | * |
||
29 | * {@inheritDoc} |
||
30 | */ |
||
31 | public function getCMSFields() |
||
32 | { |
||
33 | $this->beforeUpdateCMSFields(function (FieldList $fields) { |
||
34 | /** @var HTMLEditorField $editorField */ |
||
35 | $editorField = $fields->fieldByName('Root.Main.HTML'); |
||
36 | $editorField->setTitle(_t(__CLASS__ . '.ContentLabel', 'Content')); |
||
37 | }); |
||
38 | |||
39 | return parent::getCMSFields(); |
||
40 | } |
||
41 | |||
42 | public function getSummary() |
||
43 | { |
||
44 | return DBField::create_field('HTMLText', $this->HTML)->Summary(20); |
||
45 | } |
||
46 | |||
47 | protected function provideBlockSchema() |
||
48 | { |
||
49 | $blockSchema = parent::provideBlockSchema(); |
||
50 | $blockSchema['content'] = $this->getSummary(); |
||
51 | return $blockSchema; |
||
52 | } |
||
53 | |||
54 | public function getType() |
||
55 | { |
||
56 | return _t(__CLASS__ . '.BlockType', 'Content'); |
||
57 | } |
||
58 | } |
||
59 |