mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
440e30b611
Overhaul of spam protection to use an extension on Form rather than the SpamProtectorManager. More fluent interface and easier to replace the built in spam protection api with an alternative.
43 lines
1018 B
PHP
43 lines
1018 B
PHP
<?php
|
|
|
|
/**
|
|
* Editable Spam Protecter Field. Used with the User Defined Forms module (if
|
|
* installed) to allow the user to have captcha fields with their custom forms
|
|
*
|
|
* @package spamprotection
|
|
*/
|
|
if(class_exists('EditableFormField')) {
|
|
|
|
class EditableSpamProtectionField extends EditableFormField {
|
|
|
|
static $singular_name = 'Spam Protection Field';
|
|
|
|
static $plural_name = 'Spam Protection Fields';
|
|
|
|
public function getFormField() {
|
|
if($protector = Config::inst()->get('FormSpamProtectionExtension', 'default_spam_protector')) {
|
|
$protector = Injector::inst()->create($protector);
|
|
|
|
return $protector->getFormField($this->Name, $this->Title, null);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function getFieldValidationOptions() {
|
|
return new FieldList();
|
|
}
|
|
|
|
public function getRequired() {
|
|
return false;
|
|
}
|
|
|
|
public function Icon() {
|
|
return 'spamprotection/images/' . strtolower($this->class) . '.png';
|
|
}
|
|
|
|
public function showInReports() {
|
|
return false;
|
|
}
|
|
}
|
|
} |