Skip to content

Commit

Permalink
Changes in userform
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogdani committed May 1, 2021
1 parent 8aea3e3 commit e8af70a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
25 changes: 17 additions & 8 deletions modules/userform/userform.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public function process()

// Placeholders & values array
$replacables = [];
$text = '';

/**
* Check for error in POST data
Expand Down Expand Up @@ -332,6 +333,10 @@ public function showForm($param, Out $out)
{
$uid = uniqid( 'form' );
$this->loadForm($param['content']);
$label_class = $param['label_class'];
$input_class = $param['input_class'];
$buttons_class = $param['buttons_class'];
$nojs = $param['nojs'];

if ($param['inline'] || $this->data['inline']) {
$form_class = 'form-inline';
Expand Down Expand Up @@ -427,28 +432,31 @@ public function showForm($param, Out $out)
if ($sitekey) {

if ($_SESSION['adm_lang']) {
$captcha_lang = "'hl': '" . $_SESSION['adm_lang'] . "',";
$captcha_lang = "'hl': '" . $_SESSION['adm_lang'] . "'";
}

$captcha_script = <<<EOD
$html .= <<<EOD
<div class="g-recaptcha" data-sitekey="{$sitekey}"></div>
<script src="https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&render=explicit"></script>
<script>
<script type="text/javascript">
if (typeof recaptchaCallback !== 'function') {
var called = false;
function recaptchaCallback(){
if (called) return;
$('.g-recaptcha').each(function(i, el){
grecaptcha.render(el, {
{$captcha_lang}
'sitekey' : $(el).data('sitekey')
});
});
called = true;
}
}
</script>
EOD;
$html .= '<div class="g-recaptcha" data-sitekey="' . $sitekey. '"></div>';
$out->setQueue('modules', '<script src="https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&render=explicit" async defer></script>', true);
$out->setQueue('modules', $captcha_script, true);



}
$html .= '<div class="' . $input_class . ' ' . $buttons_class . '">' .
Expand All @@ -460,10 +468,11 @@ function recaptchaCallback(){
'</form>' .
'</div>';

if (!$data['nojs']) {
if (!$nojs) {
$js = [];

$out->setQueue('modules', "\n" . '<script src="' . $out->link2() . MOD_DIR . 'userform/userform.js'. '"></script>', true);
$out->setQueue('modules', "\n" . '<script src="' . $out->link2()
. MOD_DIR . 'userform/userform.js'. '"></script>', true);
array_push($js, "userform.whatchForm('" . $uid . "');");

if (is_array($upload)) {
Expand Down
1 change: 1 addition & 0 deletions version
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
5.5.9[] = "Changes in userform"
5.5.9[] = "Minor code fixes"
5.5.8[] = "Removed support for bower in userform_ctrl"
5.5.8[] = "DownloadAndCount::resolvePath is static method"
Expand Down

0 comments on commit e8af70a

Please sign in to comment.