1 | <?php |
||
20 | class EditableLiteralField extends EditableFormField |
||
21 | { |
||
22 | private static $singular_name = 'HTML Block'; |
||
23 | |||
24 | private static $plural_name = 'HTML Blocks'; |
||
25 | |||
26 | private static $table_name = 'EditableLiteralField'; |
||
27 | |||
28 | /** |
||
29 | * Mark as literal only |
||
30 | * |
||
31 | * @config |
||
32 | * @var bool |
||
33 | */ |
||
34 | private static $literal = true; |
||
35 | |||
36 | /** |
||
37 | * Get the name of the editor config to use for HTML sanitisation. Defaults to the active config. |
||
38 | * |
||
39 | * @var string |
||
40 | * @config |
||
41 | */ |
||
42 | private static $editor_config = null; |
||
43 | |||
44 | private static $db = [ |
||
45 | 'Content' => 'HTMLText', // From CustomSettings |
||
46 | 'HideFromReports' => 'Boolean(0)', // from CustomSettings |
||
47 | 'HideLabel' => 'Boolean(0)' |
||
48 | ]; |
||
49 | |||
50 | private static $defaults = [ |
||
51 | 'HideFromReports' => false |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * Returns the {@see HTMLEditorConfig} instance to use for sanitisation |
||
56 | * |
||
57 | * @return HTMLEditorConfig |
||
58 | */ |
||
59 | protected function getEditorConfig() |
||
67 | |||
68 | /** |
||
69 | * Safely sanitise html content, if enabled |
||
70 | * |
||
71 | * @param string $content Raw html |
||
72 | * @return string Safely sanitised html |
||
73 | */ |
||
74 | protected function sanitiseContent($content) |
||
87 | |||
88 | /** |
||
89 | * Get HTML Content of this literal field |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getContent() |
||
99 | |||
100 | /** |
||
101 | * Set the content with the given value |
||
102 | * |
||
103 | * @param string $content |
||
104 | */ |
||
105 | public function setContent($content) |
||
111 | |||
112 | /** |
||
113 | * @return FieldList |
||
114 | */ |
||
115 | public function getCMSFields() |
||
137 | |||
138 | public function getFormField() |
||
154 | |||
155 | protected function updateFormField($field) |
||
165 | |||
166 | public function showInReports() |
||
170 | } |
||
171 |