1 | <?php |
||
10 | |||
11 | // @todo |
||
12 | use EditableEmailField; |
||
13 | use EditableFormField; |
||
14 | use EditableNumericField; |
||
15 | use EditableTextField; |
||
16 | |||
17 | /** |
||
18 | * Editable Spam Protecter Field. Used with the User Defined Forms module (if |
||
19 | * installed) to allow the user to have captcha fields with their custom forms |
||
20 | * |
||
21 | * @package spamprotection |
||
22 | */ |
||
23 | // @todo update namespaced for userforms when it is 4.0 compatible |
||
24 | if (class_exists('EditableFormField')) { |
||
25 | class EditableSpamProtectionField extends EditableFormField |
||
26 | { |
||
27 | private static $singular_name = 'Spam Protection Field'; |
||
|
|||
28 | |||
29 | private static $plural_name = 'Spam Protection Fields'; |
||
30 | |||
31 | private static $table_name = 'EditableSpamProtectionField'; |
||
32 | |||
33 | /** |
||
34 | * Fields to include spam detection for |
||
35 | * |
||
36 | * @var array |
||
37 | * @config |
||
38 | */ |
||
39 | private static $check_fields = array( |
||
40 | EditableEmailField::class, |
||
41 | EditableTextField::class, |
||
42 | EditableNumericField::class |
||
43 | ); |
||
44 | |||
45 | private static $db = array( |
||
46 | 'SpamFieldSettings' => 'Text' |
||
47 | ); |
||
48 | |||
49 | /** |
||
50 | * @var FormField |
||
51 | */ |
||
52 | protected $formField = null; |
||
53 | |||
54 | public function getFormField() |
||
78 | |||
79 | /** |
||
80 | * @param FormField $field |
||
81 | * @return self |
||
82 | */ |
||
83 | public function setFormField(FormField $field) |
||
89 | |||
90 | /** |
||
91 | * Gets the list of all candidate spam detectable fields on this field's form |
||
92 | * |
||
93 | * @return DataList |
||
94 | */ |
||
95 | protected function getCandidateFields() |
||
113 | |||
114 | /** |
||
115 | * This method is in place for userforms 2.x |
||
116 | * |
||
117 | * @deprecated 3.0 Please use {@link getCMSFields()} instead |
||
118 | */ |
||
119 | public function getFieldConfiguration() |
||
123 | |||
124 | /** |
||
125 | * Write the spam field mapping values to a serialised DB field |
||
126 | * |
||
127 | * {@inheritDoc} |
||
128 | */ |
||
129 | public function onBeforeWrite() |
||
145 | |||
146 | /** |
||
147 | * Used in userforms 3.x and above |
||
148 | * |
||
149 | * {@inheritDoc} |
||
150 | */ |
||
151 | public function getCMSFields() |
||
192 | |||
193 | /** |
||
194 | * Try to retrieve a value for the given spam field map name from the serialised data |
||
195 | * |
||
196 | * @param string $mapSetting |
||
197 | * @return string |
||
198 | */ |
||
199 | public function spamMapValue($mapSetting) |
||
211 | |||
212 | /** |
||
213 | * Using custom validateField method |
||
214 | * as Spam Protection Field implementations may have their own error messages |
||
215 | * and may not be based on the field being required, e.g. Honeypot Field |
||
216 | * |
||
217 | * @param array $data |
||
218 | * @param Form $form |
||
219 | * @return void |
||
220 | */ |
||
221 | public function validateField($data, $form) |
||
255 | |||
256 | public function getFieldValidationOptions() |
||
257 | { |
||
258 | return new FieldList(); |
||
277 |
This check marks private properties in classes that are never used. Those properties can be removed.