Allow question prefix to be replaced

This commit is contained in:
Will Rossiter 2014-11-05 15:52:42 +13:00
parent bd581c7f7c
commit ae63604f08

View File

@ -15,6 +15,13 @@ class MathSpamProtectorField extends TextField {
*/
private static $enabled = true;
/**
* @config
*
* @var string
*/
private static $question_prefix;
public function Field($properties = array()) {
if(Config::inst()->get('MathSpamProtectorField', 'enabled')) {
return parent::Field($properties);
@ -37,8 +44,14 @@ class MathSpamProtectorField extends TextField {
* @return string
*/
public function Title() {
$prefix = Config::inst()->get('MathSpamProtection', 'question_prefix');
if(!$prefix) {
$prefix = _t('MathSpamProtectionField.SPAMQUESTION', "Spam protection question: %s");
}
return sprintf(
_t('MathSpamProtectionField.SPAMQUESTION', "Spam protection question: %s"),
$prefix,
self::get_math_question()
);
}