From c8084968c500e058b848b95cf74d1ed62cd49423 Mon Sep 17 00:00:00 2001 From: Gordon Anderson Date: Fri, 20 Apr 2018 11:13:48 +0700 Subject: [PATCH] FIX: Fixes suggested in PR, mostly minor --- code/MathSpamProtectorField.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/MathSpamProtectorField.php b/code/MathSpamProtectorField.php index 918ddb5..5400bf5 100644 --- a/code/MathSpamProtectorField.php +++ b/code/MathSpamProtectorField.php @@ -37,7 +37,7 @@ class MathSpamProtectorField extends TextField public function Field($properties = array()) { - if (Config::inst()->get('SilverStripe\SpamProtection\Maths\MathSpamProtectorField', 'enabled')) { + if ($this->config()->get('enabled')) { return parent::Field($properties); } @@ -46,7 +46,7 @@ class MathSpamProtectorField extends TextField public function FieldHolder($properties = array()) { - if (Config::inst()->get('SilverStripe\SpamProtection\Maths\MathSpamProtectorField', 'enabled')) { + if ($this->config()->get('enabled')) { return parent::FieldHolder($properties); } @@ -60,7 +60,7 @@ class MathSpamProtectorField extends TextField */ public function Title() { - $prefix = Config::inst()->get('SilverStripe\SpamProtection\Maths\MathSpamProtection', 'question_prefix'); + $prefix = $this->config()->get('question_prefix'); if (!$prefix) { $prefix = _t('MathSpamProtectionField.SPAMQUESTION', "Spam protection question: %s"); @@ -68,7 +68,7 @@ class MathSpamProtectorField extends TextField return sprintf( $prefix, - $this->get_math_question() + $this->getMathsQuestion() ); } @@ -81,11 +81,11 @@ class MathSpamProtectorField extends TextField */ public function validate($validator) { - if (!Config::inst()->get('SilverStripe\SpamProtection\Maths\MathSpamProtectorField', 'enabled')) { + if (!$this->config()->get( 'enabled')) { return true; } - if (!$this->correct_answer($this->Value())) { + if (!$this->isCorrectAnswer($this->Value())) { $validator->validationError( $this->name, _t( @@ -107,7 +107,7 @@ class MathSpamProtectorField extends TextField * * @return string */ - public function get_math_question() + public function getMathsQuestion() { /** @var Session $session */ $session = Controller::curr()->getRequest()->getSession(); @@ -138,7 +138,7 @@ class MathSpamProtectorField extends TextField * * @return bool */ - public function correct_answer($answer) + public function isCorrectAnswer($answer) { $session = Controller::curr()->getRequest()->getSession(); @@ -151,7 +151,7 @@ class MathSpamProtectorField extends TextField $word = MathSpamProtectorField::digit_to_word($v1 + $v2); - return ($word == strtolower($answer) || (Config::inst()->get('MathSpamProtectorField', 'allow_numeric_answer') && (($v1 + $v2) == $answer))); + return ($word == strtolower($answer) || ($this->config()->get('allow_numeric_answer') && (($v1 + $v2) == $answer))); } /**