feat: captcha field for form editor

This commit is contained in:
Björn Fromme
2024-07-17 15:57:01 +02:00
parent 096571b605
commit 4991d972c2
8 changed files with 103 additions and 3 deletions
+1
View File
@@ -17,6 +17,7 @@
"ext-pdo": "*",
"ext-simplexml": "*",
"b13/container": "^1.3",
"blueways/bw-captcha": "^3.1",
"christophlehmann/imageoptimizer": "^3.0",
"fluidtypo3/vhs": "^6.0",
"frappant/frp-form-answers": "@dev",
Generated
+61 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "25f76f1685e8ee310648c90e4c0af0f8",
"content-hash": "81e82ebeb975c1f1a71ab3938cc49b02",
"packages": [
{
"name": "b13/container",
@@ -68,6 +68,66 @@
},
"time": "2022-05-18T08:20:38+00:00"
},
{
"name": "blueways/bw-captcha",
"version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/maikschneider/bw_captcha.git",
"reference": "167103690b17bcc9a9ec8ec6693ea10036db1bbe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maikschneider/bw_captcha/zipball/167103690b17bcc9a9ec8ec6693ea10036db1bbe",
"reference": "167103690b17bcc9a9ec8ec6693ea10036db1bbe",
"shasum": ""
},
"require": {
"typo3/cms-core": "^10.0 || ^11.0 || ^12.0"
},
"require-dev": {
"bk2k/bootstrap-package": "dev-master",
"friendsofphp/php-cs-fixer": "^3.12",
"roave/security-advisories": "dev-latest",
"saschaegerer/phpstan-typo3": "12.0.x-dev",
"typo3/cms-base-distribution": "^12.0",
"typo3/cms-lowlevel": "^12.0"
},
"type": "typo3-cms-extension",
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": "public",
"extension-key": "bw_captcha"
}
},
"autoload": {
"psr-4": {
"Gregwar\\Captcha\\": "Libraries/Captcha/src/Gregwar/Captcha",
"Blueways\\BwCaptcha\\": "Classes"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Maik Schneider",
"email": "[email protected]",
"role": "Developer"
}
],
"description": "TYPO3 extension that integrates gregwar/captcha into Form",
"keywords": [
"typo3"
],
"support": {
"issues": "https://github.com/maikschneider/bw_captcha/issues",
"source": "https://github.com/maikschneider/bw_captcha/tree/v3.1.0"
},
"time": "2023-09-17T14:14:45+00:00"
},
{
"name": "christophlehmann/imageoptimizer",
"version": "3.1.1",
@@ -1,5 +1,6 @@
@import 'EXT:form/Configuration/TypoScript/setup.typoscript'
@import 'EXT:form_element_linked_checkbox/Configuration/TypoScript/setup.typoscript'
@import 'EXT:bw_captcha/Configuration/TypoScript/setup.typoscript'
plugin.tx_form.view {
templateRootPaths.10 = EXT:ep_theme/Resources/Private/Templates/Form/
@@ -193,3 +193,4 @@ plugin.tx_eptheme {
@import 'EXT:seo/Configuration/TypoScript/XmlSitemap/constants.typoscript'
@import 'EXT:typo3_encore/Configuration/TypoScript/constants.typoscript'
@import 'EXT:news/Configuration/TypoScript/constants.txt'
@import 'EXT:bw_captcha/Configuration/TypoScript/constants.typoscript'
@@ -14,7 +14,7 @@ TYPO3:
templateRootPaths:
1505042810: 'EXT:ep_theme/Resources/Private/Templates/Form/'
partialRootPaths:
1505042810: 'EXT:ep_theme/Resources/Private/Partials/Form/'
1623227657: 'EXT:ep_theme/Resources/Private/Partials/Form/'
layoutRootPaths:
1505042810: 'EXT:ep_theme/Resources/Private/Layouts/Form/'
@@ -29,7 +29,7 @@ TYPO3:
templateRootPaths:
1505042810: 'EXT:ep_theme/Resources/Private/Templates/Form/'
partialRootPaths:
1505042810: 'EXT:ep_theme/Resources/Private/Partials/Form/'
1623227657: 'EXT:ep_theme/Resources/Private/Partials/Form/'
layoutRootPaths:
1505042810: 'EXT:ep_theme/Resources/Private/Layouts/Form/'
contactform:
@@ -133,3 +133,11 @@ renderables:
validators:
-
identifier: NotEmpty
-
type: Captcha
identifier: captcha
label: Captcha
properties:
fluidAdditionalAttributes:
required: required
autocomplete: 'off'
@@ -0,0 +1,29 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:formvh="http://typo3.org/ns/TYPO3/CMS/Form/ViewHelpers"
data-namespace-typo3-fluid="true">
<formvh:renderRenderable renderable="{element}">
<f:render partial="Field/Field" arguments="{element: element}" contentAs="elementContent">
<div class="flex items-center space-x-2">
<f:form.textfield property="{element.identifier}"
id="{element.uniqueIdentifier}"
value=""
class="form-field"
errorClass="form-field--has-error"
placeholder="Bitte die Zeichen aus der Grafik eingeben"
additionalAttributes="{formvh:translateElementProperty(element: element, property: 'fluidAdditionalAttributes')}"/>
<img src="{f:uri.page(pageType:3413)}" alt="Captcha image" loading="lazy" onload="this.parentElement.classList.remove('captcha--reloading'); return false;"/>
<f:if condition="{element.properties.showRefresh}">
<button type="button" class="captcha__reload" data-url="{f:uri.page(pageType:3413)}" onclick="const div = this.parentElement; div.classList.add('captcha--reloading', 'captcha--spin'); let captchaUrl = this.dataset.url; this.previousElementSibling.setAttribute('src', captchaUrl + (/\?/.test(captchaUrl) ? '&' : '?') + 'now=' + Date.now()); setTimeout(function(){div.classList.remove('captcha--spin')},400); return false;">
<svg width="31" height="28" xmlns="http://www.w3.org/2000/svg">
<g fill="#000" fill-rule="evenodd">
<path d="M10 10.7 6.3 8.5a11 11 0 0 1 20 3l2.5-.8h.4v-.3A14 14 0 0 0 3.6 7L.3 5l1.8 8.3 8-2.6ZM31 23l-1.7-8-8 2.5 3.7 2.1a10.9 10.9 0 0 1-19.8-2.3l-2 .6-1 .3a13.9 13.9 0 0 0 17 9.3 14 14 0 0 0 8.4-6.4l3.4 2Z"/>
</g>
</svg>
</button>
</f:if>
</div>
</f:render>
</formvh:renderRenderable>
</html>