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:
Damian Mooyman 2014-02-18 16:19:29 +13:00 committed by Will Rossiter
parent 39f7f0be45
commit 9abe13fcb6
2 changed files with 10 additions and 12 deletions

View File

@ -13,7 +13,6 @@ if(class_exists('EditableFormField')) {
static $singular_name = 'Spam Protection Field';
static $plural_name = 'Spam Protection Fields';
/**
* Fields to include spam detection for
*
@ -27,11 +26,10 @@ if(class_exists('EditableFormField')) {
);
public function getFormField() {
// Get protector
$protector = FormSpamProtectionExtension::get_protector();
if(empty($protector)) return false;
if(!$protector) return false;
// Extract saved field mappings and update this field.
$fieldMapping = array();
foreach($this->getCandidateFields() as $otherField) {
@ -80,7 +78,7 @@ if(class_exists('EditableFormField')) {
'EditableSpamProtectionField.SPAMFIELDMAPPING',
'Spam Field Mapping'
))->setDescription(_t(
'EditableSpamProtectionField.SPAMFIELDMAPPINGDESCRIPTION',
'EditableSpamProtectionField.SPAMFIELDMAPPINGDESCRIPTION',
'Select the form fields that correspond to any relevant spam protection identifiers'
));

View File

@ -43,7 +43,7 @@ class FormSpamProtectionExtension extends Extension {
/**
* Instantiate a SpamProtector instance
*
*
* @param array $options Configuration options
* @return SpamProtector
*/
@ -51,15 +51,15 @@ class FormSpamProtectionExtension extends Extension {
// generate the spam protector
if(isset($options['protector'])) {
$protector = $options['protector'];
if(is_string($protector)) {
$protector = Injector::inst()->create($protector);
}
} else {
$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;
}
}
/**