diff --git a/Classes/Domain/Model/User.php b/Classes/Domain/Model/User.php new file mode 100644 index 0000000..ccab759 --- /dev/null +++ b/Classes/Domain/Model/User.php @@ -0,0 +1,30 @@ +friendlyCaptcha; + } + + /** + * @param int $friendlyCaptcha + */ + public function setFriendlyCaptcha(int $friendlyCaptcha): void + { + $this->friendlyCaptcha = $friendlyCaptcha; + } + + +} \ No newline at end of file diff --git a/Classes/Domain/Repository/UserRepository.php b/Classes/Domain/Repository/UserRepository.php new file mode 100644 index 0000000..3bdc05a --- /dev/null +++ b/Classes/Domain/Repository/UserRepository.php @@ -0,0 +1,8 @@ +validate($value)->hasErrors(); + } +} \ No newline at end of file diff --git a/Classes/Domain/Validator/ServersideValidator.php b/Classes/Domain/Validator/ServersideValidator.php new file mode 100644 index 0000000..ea5a87a --- /dev/null +++ b/Classes/Domain/Validator/ServersideValidator.php @@ -0,0 +1,21 @@ +validate($value)->hasErrors(); + } +} \ No newline at end of file diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php new file mode 100644 index 0000000..2c98551 --- /dev/null +++ b/Configuration/Extbase/Persistence/Classes.php @@ -0,0 +1,13 @@ + [ + 'subclasses' => [ + '\BalatD\FriendlyCaptcha\Domain\Model\User' => \BalatD\FriendlyCaptcha\Domain\Model\User::class, + ], + ], + \BalatD\FriendlyCaptcha\Domain\Model\User::class => [ + 'tableName' => 'fe_users', + 'recordType' => 0, + ], +]; \ No newline at end of file diff --git a/Configuration/TSconfig/Ext/FeManager/customfields.tsconfig b/Configuration/TSconfig/Ext/FeManager/customfields.tsconfig new file mode 100644 index 0000000..462b39e --- /dev/null +++ b/Configuration/TSconfig/Ext/FeManager/customfields.tsconfig @@ -0,0 +1,14 @@ +tx_femanager { + flexForm { + new { + addFieldOptions { + friendlyCaptcha = FriendlyCaptcha + } + } + edit{ + addFieldOptions { + friendlyCaptcha = FriendlyCaptcha + } + } + } +} \ No newline at end of file diff --git a/Configuration/TypoScript/Ext/FeManager/fieldvalidations.typoscript b/Configuration/TypoScript/Ext/FeManager/fieldvalidations.typoscript new file mode 100644 index 0000000..deedb06 --- /dev/null +++ b/Configuration/TypoScript/Ext/FeManager/fieldvalidations.typoscript @@ -0,0 +1,14 @@ +plugin.tx_femanager.settings { + new { + validation { + _enable.client = 1 + _enable.server = 1 + + friendlyCaptcha { + required = 1 + # custom validation method: + friendlyCaptcha = 1 + } + } + } +} \ No newline at end of file diff --git a/Configuration/TypoScript/Ext/FeManager/setup.typoscript b/Configuration/TypoScript/Ext/FeManager/setup.typoscript new file mode 100644 index 0000000..35a9ebe --- /dev/null +++ b/Configuration/TypoScript/Ext/FeManager/setup.typoscript @@ -0,0 +1,10 @@ +plugin.tx_femanager { + view { + partialRootPaths { + 50 = EXT:db_friendlycaptcha/Resources/Private/Partials/FeManager/ + } + } +} + + + \ No newline at end of file diff --git a/Configuration/TypoScript/Ext/FeManager/translation.typoscript b/Configuration/TypoScript/Ext/FeManager/translation.typoscript new file mode 100644 index 0000000..aaa9f58 --- /dev/null +++ b/Configuration/TypoScript/Ext/FeManager/translation.typoscript @@ -0,0 +1,12 @@ +plugin.tx_femanager { + _LOCAL_LANG { + en { + tx_femanager_domain_model_user.friendlyCaptcha = FriendlyCaptcha + validationErrorFriendlyCaptcha = FriendlyCaptcha required + } + de { + tx_femanager_domain_model_user.friendlyCaptcha = FriendlyCaptcha + validationErrorFriendlyCaptcha = FriendlyCaptcha erforderlich + } + } +} diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 8ce932c..7bd3012 100755 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -22,3 +22,6 @@ page.includeJSFooterlibs{ friendlycaptcha = https://unpkg.com/friendly-challenge@0.8.3/widget.min.js friendlycaptcha.external = 1 } + +// Includes FeManager + diff --git a/README.md b/README.md index f5b0636..17605c5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ### **STILL WIP** -A TYPO3 Extension that brings the Friendly Captcha functionality to EXT:form, based on the work of EXT:recaptcha. +A TYPO3 Extension that brings the Friendly Captcha functionality to EXT:form and EXT:femanager, based on the work of EXT:recaptcha. ## Installation ### Composer diff --git a/Resources/Private/Partials/FeManager/Fields/FriendlyCaptcha.html b/Resources/Private/Partials/FeManager/Fields/FriendlyCaptcha.html new file mode 100644 index 0000000..700233b --- /dev/null +++ b/Resources/Private/Partials/FeManager/Fields/FriendlyCaptcha.html @@ -0,0 +1,15 @@ +{namespace frc=BalatD\FriendlyCaptcha\ViewHelpers} +{namespace femanager=In2code\Femanager\ViewHelpers} + +
+ +
+
\ No newline at end of file diff --git a/composer.json b/composer.json index 940effa..378a519 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,8 @@ ], "suggest": { - "typo3/cms-form": "^10.0" + "typo3/cms-form": "^10.0", + "in2code/femanager": "^6" }, "require": { diff --git a/ext_localconf.php b/ext_localconf.php index 6bade3f..028c697 100755 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -18,4 +18,26 @@ 1999 = EXT:db_friendlycaptcha/Configuration/Yaml/FormEditorSetup.yaml } '); + + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(' + + '); + + $extbaseObjectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class); + $extbaseObjectContainer + ->registerImplementation( + \In2code\Femanager\Domain\Validator\ServersideValidator::class, + \BalatD\FriendlyCaptcha\Domain\Validator\ServersideValidator::class + ); + $extbaseObjectContainer + ->registerImplementation( + \In2code\Femanager\Domain\Validator\ClientsideValidator::class, + \BalatD\FriendlyCaptcha\Domain\Validator\ClientsideValidator::class + ); + + if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('femanager')) { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\In2code\Femanager\Domain\Repository\UserRepository::class] = [ + 'className' => \BalatD\FriendlyCaptcha\Domain\Repository\UserRepository::class + ]; + } }); diff --git a/ext_tables.sql b/ext_tables.sql new file mode 100644 index 0000000..c9eabee --- /dev/null +++ b/ext_tables.sql @@ -0,0 +1,3 @@ +CREATE TABLE fe_users ( + friendly_captcha tinyint(1) NOT NULL DEFAULT '0' +); \ No newline at end of file