1 | <?php namespace StudioBonito\SilverStripe\SpamProtection\Honeypot\FormField; |
||
8 | class HoneypotField extends TextField |
||
9 | { |
||
10 | /** |
||
11 | * The number of seconds before you can submit a valid request. |
||
12 | * |
||
13 | * @var int |
||
14 | * @config |
||
15 | */ |
||
16 | private static $time_limit = 5; |
||
|
|||
17 | |||
18 | /** |
||
19 | * Reject the field if the honeypot has been filled or if the form has been submitted to quickly. |
||
20 | * |
||
21 | * @param $validator |
||
22 | 6 | * |
|
23 | * @return bool |
||
24 | 6 | */ |
|
25 | public function validate($validator) |
||
46 | |||
47 | /** |
||
48 | * Since this isn't a hidden field, the title will continue to show in the form. |
||
49 | * This prevents that from happening, since a hidden field will not show the validation message. |
||
50 | * |
||
51 | * @codeCoverageIgnore |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | public function Title() |
||
59 | |||
60 | /** |
||
61 | * Override the Type to remove the class namespace. |
||
62 | * |
||
63 | * @codeCoverageIgnore |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function Type() |
||
71 | |||
72 | /** |
||
73 | * Override the Field to add the Captcha and Timestamp fields. |
||
74 | * |
||
75 | * @codeCoverageIgnore |
||
76 | * |
||
77 | * @param array $properties |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | public function Field($properties = array()) |
||
87 | |||
88 | /** |
||
89 | * Create the Captcha Field. |
||
90 | * |
||
91 | * @codeCoverageIgnore |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | protected function createHoneypotField() |
||
108 | |||
109 | /** |
||
110 | * Create the Timestamp Field. |
||
111 | * |
||
112 | * @codeCoverageIgnore |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | protected function createTimestampField() |
||
129 | |||
130 | /** |
||
131 | * Return a configured style rule for the fields, if none is configured use a default display:none rule |
||
132 | * |
||
133 | * @codeCoverageIgnore |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | public function getFieldStyle() |
||
147 | } |
||
148 |
This check marks private properties in classes that are never used. Those properties can be removed.