示例#1
0
 /**
  * Initialize the object and in front-end, get the public an private key from page layout
  * @param array
  */
 public function __construct($arrAttributes = null)
 {
     parent::__construct($arrAttributes);
     $this->mandatory = true;
     $this->arrAttributes['required'] = true;
     if (TL_MODE == 'BE') {
         return;
     }
     global $objPage;
     $layout = $this->getPageLayout($objPage);
     $this->reCaptcha = new Lib\Captcha();
     $this->reCaptcha->setSsl($this->Environment->ssl);
     //Use keys only if both are set, else default keys
     if (strlen($layout->recPublicKey) && strlen($layout->recPrivateKey)) {
         $this->reCaptcha->setPublicKey($layout->recPublicKey);
         $this->reCaptcha->setPrivateKey($layout->recPrivateKey);
     } else {
         $this->reCaptcha->setPublicKey('6LfECAUAAAAAABFYnrzQvfUgwRzsxvziubNBoSw0');
         $this->reCaptcha->setPrivateKey('6LfECAUAAAAAACvo8uibMG4JnRcr5mXIA6YdDt_v');
     }
     // Dirty workaround to add language to api url, because due to a bug Google
     // does not take language from RecaptchaOptions above, see also:
     // https://groups.google.com/forum/?fromgroups#!topic/recaptcha/o-YdYJlnRVM
     $this->reCaptcha->setPublicKey($this->reCaptcha->getPublicKey() . '&hl=' . $GLOBALS['TL_LANGUAGE']);
     $this->theme = strlen($layout->recTheme) ? $layout->recTheme : 'red';
     //Custom theme file
     if ($layout->recTheme == 'custom') {
         if ($layout->recCustomTemplate != null) {
             $this->strTemplate = $layout->recCustomTemplate;
         } else {
             //Fallback to clean template
             $this->theme = 'clean';
         }
     }
 }