/** * Injects special form fields before the form gets calculated. * * @return void * * @author Sascha Koehler <*****@*****.**>, Sebastian Diel <*****@*****.**> * @since 12.02.2013 */ public function injectSpecialFormFields() { if (array_key_exists($this->class, self::$useSpamCheck)) { $this->formFields['PtCaptchaInputField'] = array('type' => 'PtCaptchaInputField', 'title' => _t('CustomHtmlFormField.PtCaptchaInputField_Title'), 'form' => $this, 'checkRequirements' => array('isFilledIn' => true, 'hasLength' => CustomHtmlFormConfiguration::SpamCheck_numberOfCharsInCaptcha(), 'PtCaptchaInput' => true)); $this->formFields['PtCaptchaImageField'] = array('type' => 'PtCaptchaImageField', 'title' => _t('CustomHtmlFormField.PtCaptchaImageField_Title'), 'form' => $this, 'maxLength' => CustomHtmlFormConfiguration::SpamCheck_numberOfCharsInCaptcha()); } }
/** * Returns the number of chars that should be displayed in the SpamCheck captcha. * * @return int * * @author Sascha Koehler <*****@*****.**> * @since 2012-12-10 */ public static function SpamCheck_numberOfCharsInCaptcha() { if (is_null(self::$SpamCheck_numberOfCharsInCaptcha)) { self::$SpamCheck_numberOfCharsInCaptcha = self::getConfig()->SpamCheck_numberOfCharsInCaptcha; if (empty(self::$SpamCheck_numberOfCharsInCaptcha)) { self::$SpamCheck_numberOfCharsInCaptcha = 8; } } return self::$SpamCheck_numberOfCharsInCaptcha; }
/** * Initializes the field. * * @param string $name Name of the field * @param string $title Title of the field * @param mixed $value Value of the field * @param int $maxLength Max input length * @param Form $form Form to relate field with * * @author Sascha Koehler <*****@*****.**>, * Sebastian Diel <*****@*****.**> * @since 12.02.2013 */ public function __construct($name, $title = null, $value = null, $maxLength = null, $form = null) { parent::__construct($name, $title, $value, $maxLength, $form); $this->setTempDir(ASSETS_PATH . '/pt-captcha'); $this->setWidth(CustomHtmlFormConfiguration::SpamCheck_width()); $this->setHeight(CustomHtmlFormConfiguration::SpamCheck_height()); $this->setJpgQuality(CustomHtmlFormConfiguration::SpamCheck_jpgQuality()); $this->setNrOfChars(CustomHtmlFormConfiguration::SpamCheck_numberOfCharsInCaptcha()); $this->setFont(Director::baseFolder() . '/customhtmlform/fonts/Aller_Rg.ttf'); $this->setFormIdentifier($form->getName() . $this->getName()); }