mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
API Refactor field mapping from FormSpamProtectionExtension into SpamProtector API EditableSpamProtectionField may now be configured for spam on an individual field basis Translations added
This commit is contained in:
parent
39f7f0be45
commit
9abe13fcb6
@ -13,7 +13,6 @@ if(class_exists('EditableFormField')) {
|
|||||||
static $singular_name = 'Spam Protection Field';
|
static $singular_name = 'Spam Protection Field';
|
||||||
|
|
||||||
static $plural_name = 'Spam Protection Fields';
|
static $plural_name = 'Spam Protection Fields';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields to include spam detection for
|
* Fields to include spam detection for
|
||||||
*
|
*
|
||||||
@ -27,11 +26,10 @@ if(class_exists('EditableFormField')) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
|
|
||||||
// Get protector
|
// Get protector
|
||||||
$protector = FormSpamProtectionExtension::get_protector();
|
$protector = FormSpamProtectionExtension::get_protector();
|
||||||
if(empty($protector)) return false;
|
if(!$protector) return false;
|
||||||
|
|
||||||
// Extract saved field mappings and update this field.
|
// Extract saved field mappings and update this field.
|
||||||
$fieldMapping = array();
|
$fieldMapping = array();
|
||||||
foreach($this->getCandidateFields() as $otherField) {
|
foreach($this->getCandidateFields() as $otherField) {
|
||||||
@ -80,7 +78,7 @@ if(class_exists('EditableFormField')) {
|
|||||||
'EditableSpamProtectionField.SPAMFIELDMAPPING',
|
'EditableSpamProtectionField.SPAMFIELDMAPPING',
|
||||||
'Spam Field Mapping'
|
'Spam Field Mapping'
|
||||||
))->setDescription(_t(
|
))->setDescription(_t(
|
||||||
'EditableSpamProtectionField.SPAMFIELDMAPPINGDESCRIPTION',
|
'EditableSpamProtectionField.SPAMFIELDMAPPINGDESCRIPTION',
|
||||||
'Select the form fields that correspond to any relevant spam protection identifiers'
|
'Select the form fields that correspond to any relevant spam protection identifiers'
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class FormSpamProtectionExtension extends Extension {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate a SpamProtector instance
|
* Instantiate a SpamProtector instance
|
||||||
*
|
*
|
||||||
* @param array $options Configuration options
|
* @param array $options Configuration options
|
||||||
* @return SpamProtector
|
* @return SpamProtector
|
||||||
*/
|
*/
|
||||||
@ -51,15 +51,15 @@ class FormSpamProtectionExtension extends Extension {
|
|||||||
// generate the spam protector
|
// generate the spam protector
|
||||||
if(isset($options['protector'])) {
|
if(isset($options['protector'])) {
|
||||||
$protector = $options['protector'];
|
$protector = $options['protector'];
|
||||||
|
|
||||||
if(is_string($protector)) {
|
|
||||||
$protector = Injector::inst()->create($protector);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$protector = Config::inst()->get('FormSpamProtectionExtension', 'default_spam_protector');
|
$protector = Config::inst()->get('FormSpamProtectionExtension', 'default_spam_protector');
|
||||||
$protector = Injector::inst()->create($protector);
|
|
||||||
}
|
}
|
||||||
return $protector;
|
|
||||||
|
if($protector && class_exists($protector)) {
|
||||||
|
return Injector::inst()->create($protector);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user