PluginProbe
Contact Forms by Cimatti / 1.9.2
Contact Forms by Cimatti v1.9.2
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
← All changes | classes/Element/Captcha2.php +60 -30 1.4.01.9.2 View file →
@@ -1,30 +1,60 @@
1 -<?php
2 -class AccuaForm_Element_Captcha2 extends Element {
3 - protected $privateKey = "";
4 - protected $publicKey = "";
5 -
6 - public function __construct($label = "", array $properties = null) {
7 - parent::__construct($label, "recaptcha_response_field", $properties);
8 - $this->setValidation(new AccuaForm_Validation_Captcha2($this->privateKey, __("The reCATPCHA response provided was incorrect. Please re-try.", 'accua-form-api')));
9 - }
10 -
11 - public function render() {
12 - $lang = $this->form->getLanguage();
13 - $field_id = $this->attributes["id"];
14 - $publicKey = htmlspecialchars($this->publicKey, ENT_QUOTES);
15 - $jspath = ACCUA_FORMS_DIR_URL . 'accua-recaptcha2.js';
16 - echo <<<EOT
17 -<script type="text/javascript">
18 -<!--
19 -if (typeof(accuaform_recaptcha2_ajax_loaded) == "undefined" || !accuaform_recaptcha2_ajax_loaded) {
20 - var accuaform_recaptcha2_ajax_loaded = true;
21 - document.write('<sc'+'ript type="text/javascript" src="$jspath"></sc'+'ript>');
22 - document.write('<sc'+'ript type="text/javascript" src="https://www.google.com/recaptcha/api.js?onload=accua_forms_onload_recaptcha2&amp;render=explicit&amp;hl={$lang}"></sc'+'ript>');
23 -}
24 -document.write('<sc'+'ript type="text/javascript">jQuery(function(){accua_forms_show_recaptcha2("{$field_id}", {sitekey: "{$this->publicKey}"});});</sc'+'ript>');
25 -// -->
26 -</script>
27 -<div id="{$field_id}" class="accua_forms_recaptcha2_container"></div>
28 -EOT;
29 - }
30 -}
1 +<?php
2 +class AccuaForm_Element_Captcha2 extends Element {
3 + protected $privateKey = "";
4 + protected $publicKey = "";
5 +
6 + public function __construct($label = "", $unused = null, array $properties = null) {
7 + if ($properties === null && is_array($unused)) {
8 + $properties = $unused;
9 + }
10 + parent::__construct($label, "recaptcha_response_field", $properties);
11 + $validator = new AccuaForm_Validation_Captcha2b(__("The reCATPCHA response provided was incorrect. Please re-try.", 'contact-forms'));
12 + $validator->configure(array('privateKey'=>$this->privateKey));
13 + $this->setValidation($validator);
14 + }
15 +
16 + public function render() {
17 + $js_lang = _accua_forms_json_encode($this->form->getLanguage());
18 + $js_field_id = _accua_forms_json_encode($this->attributes["id"]);//$this->form->attributes['id'] per id del form
19 + $js_publicKey = _accua_forms_json_encode($this->publicKey);
20 + $js_path = _accua_forms_json_encode(ACCUA_FORMS_DIR_URL . 'accua-recaptcha2.js');
21 +
22 + $field_id = htmlspecialchars($this->attributes["id"], ENT_QUOTES);
23 + echo <<<EOT
24 +<script type="text/javascript">
25 +<!--
26 +if (typeof(accuaform_recaptcha2_ajax_loaded) == "undefined" || !accuaform_recaptcha2_ajax_loaded) {
27 + var accuaform_recaptcha2_ajax_loaded = true;
28 + var accuaform_recaptcha2_ajax_delaying = true;
29 + var accuaform_recaptcha2_ajax_loading = true ;
30 + var accuaform_recaptcha2_ajax_controller = jQuery({});
31 + var accuaform_recaptcha2_ajax_initialized = {};
32 + jQuery(".accuaforms-field-required, .pfbc-fieldwrap > *").one('change', function() {
33 + if(accuaform_recaptcha2_ajax_delaying){
34 + accuaform_recaptcha2_ajax_delaying = false;
35 + jQuery.getScript( $js_path , function(){
36 + jQuery.getScript( "https://www.recaptcha.net/recaptcha/api.js?onload=accua_forms_onload_recaptcha2&render=explicit&hl=" + $js_lang );
37 + accuaform_recaptcha2_ajax_loading = false;
38 + accuaform_recaptcha2_ajax_controller.trigger('loaded');
39 + });
40 + }
41 + });
42 +}
43 +if (!accuaform_recaptcha2_ajax_initialized[ $js_field_id ]) {
44 + accuaform_recaptcha2_ajax_initialized[ $js_field_id ] = true;
45 + jQuery(function(){
46 + if (accuaform_recaptcha2_ajax_loading) {
47 + accuaform_recaptcha2_ajax_controller.one('loaded', function(){
48 + accua_forms_show_recaptcha2( $js_field_id , { sitekey: $js_publicKey });
49 + })
50 + } else {
51 + accua_forms_show_recaptcha2( $js_field_id , { sitekey: $js_publicKey });
52 + }
53 + });
54 +}
55 +// -->
56 +</script>
57 +<div id="{$field_id}" class="accua_forms_recaptcha2_container" style="min-height: 78px !important;"></div>
58 +EOT;
59 + }
60 +}