@@ 8-44 (lines=37) @@ | ||
5 | use SheaDawson\Blocks\Model\Block; |
|
6 | use SilverStripe\Forms\TextareaField; |
|
7 | ||
8 | class EmailSignupBlock extends Block |
|
9 | { |
|
10 | /** |
|
11 | * @return string |
|
12 | */ |
|
13 | public function singular_name() |
|
14 | { |
|
15 | return _t('EmailSignupBlock.SINGULARNAME', 'Email Signup Block'); |
|
16 | } |
|
17 | ||
18 | /** |
|
19 | * @return string |
|
20 | */ |
|
21 | public function plural_name() |
|
22 | { |
|
23 | return _t('EmailSignupBlock.PLURALNAME', 'Email Signup Blocks'); |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * @var array |
|
28 | */ |
|
29 | private static $db = [ |
|
30 | 'EmbedCode' => 'HTMLText', |
|
31 | ]; |
|
32 | ||
33 | /** |
|
34 | * @return FieldList |
|
35 | */ |
|
36 | public function getCMSFields() |
|
37 | { |
|
38 | $fields = parent::getCMSFields(); |
|
39 | ||
40 | $fields->addFieldToTab('Root.Main', TextareaField::create('EmbedCode')->setTitle('Embed code for signup form')); |
|
41 | ||
42 | return $fields; |
|
43 | } |
|
44 | } |
@@ 11-57 (lines=47) @@ | ||
8 | /** |
|
9 | * Class EmbedCodeBlock |
|
10 | */ |
|
11 | class EmbedCodeBlock extends Block |
|
12 | { |
|
13 | ||
14 | /** |
|
15 | * @return string |
|
16 | */ |
|
17 | public function singular_name() |
|
18 | { |
|
19 | return _t('EmbedCodeBlock.SINGULARNAME', 'Embed Code Block'); |
|
20 | } |
|
21 | ||
22 | /** |
|
23 | * @return string |
|
24 | */ |
|
25 | public function plural_name() |
|
26 | { |
|
27 | return _t('EmbedCodeBlock.PLURALNAME', 'Embed Code Blocks'); |
|
28 | } |
|
29 | /** |
|
30 | * @var string |
|
31 | */ |
|
32 | private static $description = 'Block providing ability to embed code (generally javascript)'; |
|
33 | ||
34 | /** |
|
35 | * @var array |
|
36 | */ |
|
37 | private static $db = [ |
|
38 | 'Code' => 'HTMLText', |
|
39 | ]; |
|
40 | ||
41 | /** |
|
42 | * @return \FieldList |
|
43 | */ |
|
44 | public function getCMSFields() |
|
45 | { |
|
46 | $fields = parent::getCMSFields(); |
|
47 | ||
48 | $fields->replaceField( |
|
49 | 'Code', |
|
50 | TextareaField::create('Code') |
|
51 | ->setTitle('Embed Code') |
|
52 | ); |
|
53 | ||
54 | return $fields; |
|
55 | } |
|
56 | ||
57 | } |
@@ 8-45 (lines=38) @@ | ||
5 | use SheaDawson\Blocks\Model\Block; |
|
6 | use SilverStripe\Assets\Image; |
|
7 | ||
8 | class ImageBlock extends Block |
|
9 | { |
|
10 | /** |
|
11 | * @return string |
|
12 | */ |
|
13 | public function singular_name() |
|
14 | { |
|
15 | return _t('ImageBlock.SINGULARNAME', 'Image Block'); |
|
16 | } |
|
17 | ||
18 | /** |
|
19 | * @return string |
|
20 | */ |
|
21 | public function plural_name() |
|
22 | { |
|
23 | return _t('ImageBlock.PLURALNAME', 'Image Blocks'); |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * @var array |
|
28 | */ |
|
29 | private static $has_one = array( |
|
30 | 'Image' => Image::class, |
|
31 | ); |
|
32 | ||
33 | /** |
|
34 | * @return \SilverStripe\Forms\FieldList |
|
35 | */ |
|
36 | public function getCMSFields() |
|
37 | { |
|
38 | $fields = parent::getCMSFields(); |
|
39 | ||
40 | $fields->dataFieldByName('Title')->setDescription('Internal reference only'); |
|
41 | $fields->dataFieldByName('Image')->setFolderName('Uploads/ImageBlocks'); |
|
42 | ||
43 | return $fields; |
|
44 | } |
|
45 | } |