public function Field($properties=array()) {
        $siteKey=$this->getSiteKey();
        $secretKey=$this->_secretKey ? $this->_secretKey : self::config()->secret_key;

        if(empty($siteKey) || empty($secretKey)) {
            user_error('You must configure Nocaptcha.site_key and Nocaptcha.secret_key, you can retrieve these at https://google.com/recaptcha', E_USER_ERROR);
        }

        Requirements::javascript('undefinedoffset/silverstripe-nocaptcha:javascript/NocaptchaField.js');
        Requirements::customScript(
            "var _noCaptchaFields=_noCaptchaFields || [];_noCaptchaFields.push('".$this->ID()."');",
            "NocaptchaField-" . $this->ID()
        );
        Requirements::customScript(
            "(function() {\n" .
                "var gr = document.createElement('script'); gr.type = 'text/javascript'; gr.async = true;\n" .
                "gr.src = ('https:' == document.location.protocol ? 'https://www' : 'http://www') + " .
                "'.google.com/recaptcha/api.js?render=explicit&hl=" .
                Locale::getPrimaryLanguage(i18n::get_locale()) .
                "&onload=noCaptchaFieldRender';\n" .
                "var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gr, s);\n" .
            "})();\n",
            'NocaptchaField-lib'
        );

        return parent::Field($properties);
    }
public function Field($properties=array()) {
        $siteKey=$this->getSiteKey();
        $secretKey=$this->_secretKey ? $this->_secretKey : self::config()->secret_key;

        if(empty($siteKey) || empty($secretKey)) {
            user_error('You must configure Nocaptcha.site_key and Nocaptcha.secret_key, you can retrieve these at https://google.com/recaptcha', E_USER_ERROR);
        }

        Requirements::javascript('undefinedoffset/silverstripe-nocaptcha:javascript/NocaptchaField.js');
        Requirements::customScript(
            "var _noCaptchaFields=_noCaptchaFields || [];_noCaptchaFields.push('".$this->ID()."');",
            "NocaptchaField-" . $this->ID()
        );
        Requirements::customScript(
            "(function() {\n" .
                "var gr = document.createElement('script'); gr.type = 'text/javascript'; gr.async = true;\n" .
                "gr.src = ('https:' == document.location.protocol ? 'https://www' : 'http://www') + " .
                "'.google.com/recaptcha/api.js?render=explicit&hl=" .
                Locale::getPrimaryLanguage(i18n::get_locale()) .
                "&onload=noCaptchaFieldRender';\n" .
                "var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gr, s);\n" .
            "})();\n",
            'NocaptchaField-lib'
        );

        return parent::Field($properties);
    }
public function Field ( $ properties = array ( ) ) { $ siteKey = $ this -> getSiteKey ( ) ; $ secretKey = $ this -> _secretKey ? $ this -> _secretKey : self :: config ( ) -> secret_key ; if ( empty ( $ siteKey ) || empty ( $ secretKey ) ) { user_error ( 'You must configure Nocaptcha.site_key and Nocaptcha.secret_key, you can retrieve these at https://google.com/recaptcha' , E_USER_ERROR ) ; } Requirements :: javascript ( 'undefinedoffset/silverstripe-nocaptcha:javascript/NocaptchaField.js' ) ; Requirements :: customScript ( "var _noCaptchaFields=_noCaptchaFields || [];_noCaptchaFields.push('" . $ this -> ID ( ) . "');" , "NocaptchaField-" . $ this -> ID ( ) ) ; Requirements :: customScript ( "(function() {\n" . "var gr = document.createElement('script'); gr.type = 'text/javascript'; gr.async = true;\n" . "gr.src = ('https:' == document.location.protocol ? 'https://www' : 'http://www') + " . "'.google.com/recaptcha/api.js?render=explicit&hl=" . Locale :: getPrimaryLanguage ( i18n :: get_locale ( ) ) . "&onload=noCaptchaFieldRender';\n" . "var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gr, s);\n" . "})();\n" , 'NocaptchaField-lib' ) ; return parent :: Field ( $ properties ) ; }
Adds in the requirements for the field
@param array $properties Array of properties for the form element (not used)
@return string Rendered field template
Adds in the requirements for the field