diff --git a/.ddev/config.yaml b/.ddev/config.yaml index 2f195cc..b6b7069 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -3,68 +3,72 @@ type: typo3 docroot: public php_version: "8.2" webserver_type: nginx-fpm -router_http_port: "80" -router_https_port: "443" xdebug_enabled: false additional_hostnames: [] additional_fqdns: [] database: - type: mariadb - version: "10.4" -nfs_mount_enabled: false -mutagen_enabled: false + type: mariadb + version: "10.4" +webimage_extra_packages: [libxml2-utils] use_dns_when_possible: true composer_version: "2" web_environment: -- TYPO3_CONTEXT=Development/Local + - TYPO3_CONTEXT=Development/Local nodejs_version: "16" +corepack_enable: false -# Key features of ddev's config.yaml: +# Key features of DDEV's config.yaml: # name: # Name of the project, automatically provides # http://projectname.ddev.site and https://projectname.ddev.site -# type: # drupal6/7/8, backdrop, typo3, wordpress, php +# type: # backdrop, craftcms, django4, drupal, drupal6, drupal7, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress +# See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more +# information on the different project types +# "drupal" covers recent Drupal 8+ # docroot: # Relative path to the directory containing index.php. -# php_version: "7.4" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1" +# php_version: "8.2" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4" # You can explicitly specify the webimage but this -# is not recommended, as the images are often closely tied to ddev's' behavior, +# is not recommended, as the images are often closely tied to DDEV's' behavior, # so this can break upgrades. # webimage: # nginx/php docker image. # database: -# type: # mysql, mariadb -# version: # database version, like "10.3" or "8.0" -# Note that mariadb_version or mysql_version from v1.18 and earlier -# will automatically be converted to this notation with just a "ddev config --auto" +# type: # mysql, mariadb, postgres +# version: # database version, like "10.11" or "8.0" +# MariaDB versions can be 5.5-10.8, 10.11, and 11.4. +# MySQL versions can be 5.5-8.0. +# PostgreSQL versions can be 9-17. -# router_http_port: # Port to be used for http (defaults to port 80) -# router_https_port: # Port for https (defaults to 443) +# router_http_port: # Port to be used for http (defaults to global configuration, usually 80) +# router_https_port: # Port for https (defaults to global configuration, usually 443) -# xdebug_enabled: false # Set to true to enable xdebug and "ddev start" or "ddev restart" +# xdebug_enabled: false # Set to true to enable Xdebug and "ddev start" or "ddev restart" # Note that for most people the commands -# "ddev xdebug" to enable xdebug and "ddev xdebug off" to disable it work better, -# as leaving xdebug enabled all the time is a big performance hit. +# "ddev xdebug" to enable Xdebug and "ddev xdebug off" to disable it work better, +# as leaving Xdebug enabled all the time is a big performance hit. -# xhprof_enabled: false # Set to true to enable xhprof and "ddev start" or "ddev restart" +# xhprof_enabled: false # Set to true to enable Xhprof and "ddev start" or "ddev restart" # Note that for most people the commands -# "ddev xhprof" to enable xhprof and "ddev xhprof off" to disable it work better, -# as leaving xhprof enabled all the time is a big performance hit. +# "ddev xhprof" to enable Xhprof and "ddev xhprof off" to disable it work better, +# as leaving Xhprof enabled all the time is a big performance hit. -# webserver_type: nginx-fpm # or apache-fpm +# webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn # timezone: Europe/Berlin +# If timezone is unset, DDEV will attempt to derive it from the host system timezone +# using the $TZ environment variable or the /etc/localtime symlink. # This is the timezone used in the containers and by PHP; # it can be set to any valid timezone, # see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones # For example Europe/Dublin or MST7MDT # composer_root: -# Relative path to the composer root directory from the project root. This is +# Relative path to the Composer root directory from the project root. This is # the directory which contains the composer.json and where all Composer related # commands are executed. @@ -77,12 +81,17 @@ nodejs_version: "16" # - preview # - snapshot # Alternatively, an explicit Composer version may be specified, for example "2.2.18". -# To reinstall Composer after the image was built, run "ddev debug refresh". +# To reinstall Composer after the image was built, run "ddev debug rebuild". -# nodejs_version: "16" -# change from the default system Node.js version to another supported version, like 12, 14, 17, 18. -# Note that you can use 'ddev nvm' or nvm inside the web container to provide nearly any -# Node.js version, including v6, etc. +# nodejs_version: "20" +# change from the default system Node.js version to any other version. +# See https://ddev.readthedocs.io/en/stable/users/configuration/config/#nodejs_version for more information +# and https://www.npmjs.com/package/n#specifying-nodejs-versions for the full documentation, +# Note that using of 'ddev nvm' is discouraged because "nodejs_version" is much easier to use, +# can specify any version, and is more robust than using 'nvm'. + +# corepack_enable: false +# Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm # additional_hostnames: # - somename @@ -96,10 +105,26 @@ nodejs_version: "16" # would provide http and https URLs for "example.com" and "sub1.example.com" # Please take care with this because it can cause great confusion. -# upload_dir: custom/upload/dir -# would set the destination path for ddev import-files to /custom/upload/dir -# When mutagen is enabled this path is bind-mounted so that all the files -# in the upload_dir don't have to be synced into mutagen +# upload_dirs: "custom/upload/dir" +# +# upload_dirs: +# - custom/upload/dir +# - ../private +# +# would set the destination paths for ddev import-files to /custom/upload/dir +# When Mutagen is enabled this path is bind-mounted so that all the files +# in the upload_dirs don't have to be synced into Mutagen. + +# disable_upload_dirs_warning: false +# If true, turns off the normal warning that says +# "You have Mutagen enabled and your 'php' project type doesn't have upload_dirs set" + +# ddev_version_constraint: "" +# Example: +# ddev_version_constraint: ">= 1.22.4" +# This will enforce that the running ddev version is within this constraint. +# See https://github.com/Masterminds/semver#checking-version-constraints for +# supported constraint formats # working_dir: # web: /var/www/html @@ -108,20 +133,25 @@ nodejs_version: "16" # These values specify the destination directory for ddev ssh and the # directory in which commands passed into ddev exec are run. -# omit_containers: [db, dba, ddev-ssh-agent] +# omit_containers: [db, ddev-ssh-agent] # Currently only these containers are supported. Some containers can also be # omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit -# the "db" container, several standard features of ddev that access the +# the "db" container, several standard features of DDEV that access the # database container will be unusable. In the global configuration it is also # possible to omit ddev-router, but not here. -# nfs_mount_enabled: false -# Great performance improvement but requires host configuration first. -# See https://ddev.readthedocs.io/en/stable/users/performance/#using-nfs-to-mount-the-project-into-the-container - -# mutagen_enabled: false -# Performance improvement using mutagen asynchronous updates. -# See https://ddev.readthedocs.io/en/latest/users/performance/#using-mutagen +# performance_mode: "global" +# DDEV offers performance optimization strategies to improve the filesystem +# performance depending on your host system. Should be configured globally. +# +# If set, will override the global config. Possible values are: +# - "global": uses the value from the global config. +# - "none": disables performance optimization for this project. +# - "mutagen": enables Mutagen for this project. +# - "nfs": enables NFS for this project. +# +# See https://ddev.readthedocs.io/en/stable/users/install/performance/#nfs +# See https://ddev.readthedocs.io/en/stable/users/install/performance/#mutagen # fail_on_hook_fail: False # Decide whether 'ddev start' should be interrupted by a failing hook @@ -142,20 +172,12 @@ nodejs_version: "16" # The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic # unless explicitly specified. -# phpmyadmin_port: "8036" -# phpmyadmin_https_port: "8037" -# The PHPMyAdmin ports can be changed from the default 8036 and 8037 - -# host_phpmyadmin_port: "8036" -# The phpmyadmin (dba) port is not normally bound on the host at all, instead being routed -# through ddev-router, but it can be specified and bound. - -# mailhog_port: "8025" -# mailhog_https_port: "8026" -# The MailHog ports can be changed from the default 8025 and 8026 +# mailpit_http_port: "8025" +# mailpit_https_port: "8026" +# The Mailpit ports can be changed from the default 8025 and 8026 -# host_mailhog_port: "8025" -# The mailhog port is not normally bound on the host at all, instead being routed +# host_mailpit_port: "8025" +# The mailpit port is not normally bound on the host at all, instead being routed # through ddev-router, but it can be bound directly to localhost if specified here. # webimage_extra_packages: [php7.4-tidy, php-bcmath] @@ -178,32 +200,32 @@ nodejs_version: "16" # ngrok_args: --basic-auth username:pass1234 # Provide extra flags to the "ngrok http" command, see -# https://ngrok.com/docs#http or run "ngrok http -h" +# https://ngrok.com/docs/ngrok-agent/config or run "ngrok http -h" # disable_settings_management: false -# If true, ddev will not create CMS-specific settings files like -# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalConfiguration.php +# If true, DDEV will not create CMS-specific settings files like +# Drupal's settings.php/settings.ddev.php or TYPO3's additional.php # In this case the user must provide all such settings. # You can inject environment variables into the web container with: # web_environment: -# - SOMEENV=somevalue -# - SOMEOTHERENV=someothervalue +# - SOMEENV=somevalue +# - SOMEOTHERENV=someothervalue # no_project_mount: false -# (Experimental) If true, ddev will not mount the project into the web container; +# (Experimental) If true, DDEV will not mount the project into the web container; # the user is responsible for mounting it manually or via a script. # This is to enable experimentation with alternate file mounting strategies. # For advanced users only! # bind_all_interfaces: false # If true, host ports will be bound on all network interfaces, -# not just the localhost interface. This means that ports +# not the localhost interface only. This means that ports # will be available on the local network if the host firewall # allows it. # default_container_timeout: 120 -# The default time that ddev waits for all containers to become ready can be increased from +# The default time that DDEV waits for all containers to become ready can be increased from # the default 120. This helps in importing huge databases, for example. #web_extra_exposed_ports: @@ -216,12 +238,16 @@ nodejs_version: "16" # https_port: 4000 # http_port: 3999 # Allows a set of extra ports to be exposed via ddev-router +# Fill in all three fields even if you don’t intend to use the https_port! +# If you don’t add https_port, then it defaults to 0 and ddev-router will fail to start. +# # The port behavior on the ddev-webserver must be arranged separately, for example # using web_extra_daemons. # For example, with a web app on port 3000 inside the container, this config would # expose that web app on https://.ddev.site:9999 and http://.ddev.site:9998 # web_extra_exposed_ports: -# - container_port: 3000 +# - name: myapp +# container_port: 3000 # http_port: 9998 # https_port: 9999 @@ -236,10 +262,10 @@ nodejs_version: "16" # override_config: false # By default, config.*.yaml files are *merged* into the configuration # But this means that some things can't be overridden -# For example, if you have 'nfs_mount_enabled: true'' you can't override it with a merge +# For example, if you have 'use_dns_when_possible: true'' you can't override it with a merge # and you can't erase existing hooks or all environment variables. # However, with "override_config: true" in a particular config.*.yaml file, -# 'nfs_mount_enabled: false' can override the existing values, and +# 'use_dns_when_possible: false' can override the existing values, and # hooks: # post-start: [] # or @@ -249,8 +275,8 @@ nodejs_version: "16" # can have their intended affect. 'override_config' affects only behavior of the # config.*.yaml file it exists in. -# Many ddev commands can be extended to run tasks before or after the -# ddev command is executed, for example "post-start", "post-import-db", +# Many DDEV commands can be extended to run tasks before or after the +# DDEV command is executed, for example "post-start", "post-import-db", # "pre-composer", "post-composer" # See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more # information on the commands that can be extended and the tasks you can define diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..604c9d6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,64 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +# TS/JS-Files +[*.{ts,js}] +indent_size = 2 + +# JSON-Files +[{*.json,.prettierrc}] +indent_style = tab + +# YAML-Files +[*.{yaml,yml}] +indent_size = 2 + +# NEON-Files +[*.neon] +indent_size = 2 +indent_style = tab + +# package.json +[package.json] +indent_size = 2 + +# TypoScript +[*.{typoscript,tsconfig}] +indent_size = 2 + +# XLF-Files +[*.xlf] +indent_style = tab + +# SQL-Files +[*.sql] +indent_style = tab +indent_size = 2 + +# .htaccess +[{_.htaccess,.htaccess}] +indent_style = tab + +[{/var/**,Libraries/**}] +charset = unset +end_of_line = unset +insert_final_newline = unset +trim_trailing_whitespace = unset +indent_style = unset +indent_size = unset + +[*.php] +indent_style = unset + +# end of file diff --git a/.github/workflows/sca.yml b/.github/workflows/sca.yml index dbc3e1e..6af1222 100644 --- a/.github/workflows/sca.yml +++ b/.github/workflows/sca.yml @@ -1,12 +1,50 @@ name: Static Code Analysis on: - - pull_request - - push + push: + branches: + - main + - 'renovate/**' + pull_request: + branches: + - main jobs: + sca: + name: SCA + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - tests: - uses: maikschneider/reusable-workflows/.github/workflows/sca.yml@main - with: - php-version: 8.2 \ No newline at end of file + # Setup DDEV + - name: Setup DDEV + uses: ddev/github-action-setup-ddev@v1 + with: + autostart: false + + # Install dependencies + - name: Install Composer dependencies + run: | + ddev start + ddev composer config github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} + ddev composer install + + - name: Composer audit + run: ddev composer audit + + - name: Run static code analysis + run: ddev composer ci:sca + + - uses: staabm/annotate-pull-request-from-checkstyle-action@v1 + name: Annotate PHP CS Fixer + with: + files: php-cs-fixer.xml + notices-as-warnings: true + + - uses: staabm/annotate-pull-request-from-checkstyle-action@v1 + name: Annotate PHPStan + with: + files: phpstan.xml + notices-as-warnings: true diff --git a/.phpstorm.meta.php b/.phpstorm.meta.php deleted file mode 100644 index 0d50baa..0000000 --- a/.phpstorm.meta.php +++ /dev/null @@ -1,89 +0,0 @@ - \TYPO3\CMS\Core\Context\DateTimeAspect::class, - 'visibility' => \TYPO3\CMS\Core\Context\VisibilityAspect::class, - 'backend.user' => \TYPO3\CMS\Core\Context\UserAspect::class, - 'frontend.user' => \TYPO3\CMS\Core\Context\UserAspect::class, - 'workspace' => \TYPO3\CMS\Core\Context\WorkspaceAspect::class, - 'language' => \TYPO3\CMS\Core\Context\LanguageAspect::class, - 'typoscript' => \TYPO3\CMS\Core\Context\TypoScriptAspect::class, - ])); - - expectedArguments( - \TYPO3\CMS\Core\Context\DateTimeAspect::get(), - 0, - 'timestamp', - 'iso', - 'timezone', - 'full', - 'accessTime' - ); - - expectedArguments( - \TYPO3\CMS\Core\Context\VisibilityAspect::get(), - 0, - 'includeHiddenPages', - 'includeHiddenContent', - 'includeDeletedRecords' - ); - - expectedArguments( - \TYPO3\CMS\Core\Context\UserAspect::get(), - 0, - 'id', - 'username', - 'isLoggedIn', - 'isAdmin', - 'groupIds', - 'groupNames' - ); - - expectedArguments( - \TYPO3\CMS\Core\Context\WorkspaceAspect::get(), - 0, - 'id', - 'isLive', - 'isOffline' - ); - - expectedArguments( - \TYPO3\CMS\Core\Context\LanguageAspect::get(), - 0, - 'id', - 'contentId', - 'fallbackChain', - 'overlayType', - 'legacyLanguageMode', - 'legacyOverlayType' - ); - - expectedArguments( - \TYPO3\CMS\Core\Context\TypoScriptAspect::get(), - 0, - 'forcedTemplateParsing' - ); -} \ No newline at end of file diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 1c719ec..bf995d4 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -14,4 +14,4 @@ services: Blueways\BwCaptcha\EventListener\ModifyRegistrationValidatorResultEventListener: tags: - name: event.listener - identifier: 'bw-captcha/sf-event-mgt-registration' \ No newline at end of file + identifier: 'bw-captcha/sf-event-mgt-registration' diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 1e3956e..1a6acb3 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -1,40 +1,40 @@ plugin.tx_bwcaptcha { - settings { - # cat=bw_captcha; type=int; label=Seconds until captchas are invalid - lifetime = 3600 - # cat=bw_captcha; type=boolean; label=Show reload button - refreshButton = 1 - # cat=bw_captcha; type=int; label=The length of the captcha - length = 5 - # cat=bw_captcha; type=string; label=The charset of the captcha - charset = abcdefghijklmnpqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ - # cat=bw_captcha; type=int; label=The width of the image - width = 150 - # cat=bw_captcha; type=int; label=The height of the image - height = 40 - # cat=bw_captcha; type=string; label=Custom font file(s) to use (comma-seperated): Could be: "EXT:my_site/Resources/Public/Fonts/myFont.ttf" (extension path), "1:myfolder/myFont.ttf" (combined identifier), "23" (file UID), "file:23" - fontFiles = EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha0.ttf,EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha1.ttf,EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha3.ttf,EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha4.ttf,EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha5.ttf - # cat=bw_captcha; type=string; label=Text color (e.g. 255,0,0) - textColor = - # cat=bw_captcha; type=string; label=Line color (e.g. 0,0,0) - lineColor = - # cat=bw_captcha; type=string; label=Background color (e.g. 255,255,255) - backgroundColor = - # cat=bw_captcha; type=boolean; label=Distortion - distortion = - # cat=bw_captcha; type=int; label=The maximum number of lines to draw in front of - maxFrontLines = - # cat=bw_captcha; type=int; label=The maximum number of lines to draw behind - maxBehindLines = - # cat=bw_captcha; type=int; label=The maximum angle of char - maxAngle = - # cat=bw_captcha; type=int; label=The maximum offset of char - maxOffset = - # cat=bw_captcha; type=boolean; label=Is the interpolation enabled? - interpolation = - # cat=bw_captcha; type=boolean; label=Ignore all effects - ignoreAllEffects = - # cat=bw_captcha; type=boolean; label=Show audio button for speech output - audioButton = 1 - } + settings { + # cat=bw_captcha; type=int; label=Seconds until captchas are invalid + lifetime = 3600 + # cat=bw_captcha; type=boolean; label=Show reload button + refreshButton = 1 + # cat=bw_captcha; type=int; label=The length of the captcha + length = 5 + # cat=bw_captcha; type=string; label=The charset of the captcha + charset = abcdefghijklmnpqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ + # cat=bw_captcha; type=int; label=The width of the image + width = 150 + # cat=bw_captcha; type=int; label=The height of the image + height = 40 + # cat=bw_captcha; type=string; label=Custom font file(s) to use (comma-seperated): Could be: "EXT:my_site/Resources/Public/Fonts/myFont.ttf" (extension path), "1:myfolder/myFont.ttf" (combined identifier), "23" (file UID), "file:23" + fontFiles = EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha0.ttf,EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha1.ttf,EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha3.ttf,EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha4.ttf,EXT:bw_captcha/Libraries/Captcha/src/Gregwar/Captcha/Font/captcha5.ttf + # cat=bw_captcha; type=string; label=Text color (e.g. 255,0,0) + textColor = + # cat=bw_captcha; type=string; label=Line color (e.g. 0,0,0) + lineColor = + # cat=bw_captcha; type=string; label=Background color (e.g. 255,255,255) + backgroundColor = + # cat=bw_captcha; type=boolean; label=Distortion + distortion = + # cat=bw_captcha; type=int; label=The maximum number of lines to draw in front of + maxFrontLines = + # cat=bw_captcha; type=int; label=The maximum number of lines to draw behind + maxBehindLines = + # cat=bw_captcha; type=int; label=The maximum angle of char + maxAngle = + # cat=bw_captcha; type=int; label=The maximum offset of char + maxOffset = + # cat=bw_captcha; type=boolean; label=Is the interpolation enabled? + interpolation = + # cat=bw_captcha; type=boolean; label=Ignore all effects + ignoreAllEffects = + # cat=bw_captcha; type=boolean; label=Show audio button for speech output + audioButton = 1 + } } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 274b486..3799731 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -1,69 +1,70 @@ plugin.tx_form { - settings { - yamlConfigurations { - 1623227656 = EXT:bw_captcha/Configuration/Yaml/FormConfiguration.yaml - } - } + settings { + yamlConfigurations { + 1623227656 = EXT:bw_captcha/Configuration/Yaml/FormConfiguration.yaml + } + } - _CSS_DEFAULT_STYLE ( - .captcha { margin-bottom: .5rem; } - .captcha a { margin-left: .5rem; } - .captcha--reloading img { opacity: 0.5; } - .captcha--reloading a { cursor: auto; } - .captcha--spin .captcha__reload svg { animation: spin 0.8s infinite linear; } - .captcha__audio__mute { display: none; } - .captcha--playing .captcha__audio__mute { display: inherit; } - .captcha--playing .captcha__audio__sound { display: none; } - @keyframes spin { - from {transform:rotate(359deg);} - to {transform:rotate(0deg);} + _CSS_DEFAULT_STYLE ( + .captcha { margin-bottom: .5rem; } + .captcha a { margin-left: .5rem; } + .captcha--reloading img { opacity: 0.5; } + .captcha--reloading a { cursor: auto; } + .captcha--spin .captcha__reload svg { animation: spin 0.8s infinite linear; } + .captcha__audio__mute { display: none; } + .captcha--playing .captcha__audio__mute { display: inherit; } + .captcha--playing .captcha__audio__sound { display: none; } + @keyframes spin { + from {transform:rotate(359deg);} + to {transform:rotate(0deg);} } - ) + ) } plugin.tx_bwcaptcha { - settings { - lifetime = {$plugin.tx_bwcaptcha.settings.lifetime} - refreshButton = {$plugin.tx_bwcaptcha.settings.refreshButton} - length = {$plugin.tx_bwcaptcha.settings.length} - charset = {$plugin.tx_bwcaptcha.settings.charset} - width = {$plugin.tx_bwcaptcha.settings.width} - height = {$plugin.tx_bwcaptcha.settings.height} - fontFiles = {$plugin.tx_bwcaptcha.settings.fontFiles} - textColor = {$plugin.tx_bwcaptcha.settings.textColor} - lineColor = {$plugin.tx_bwcaptcha.settings.lineColor} - backgroundColor = {$plugin.tx_bwcaptcha.settings.backgroundColor} - distortion = {$plugin.tx_bwcaptcha.settings.distortion} - maxFrontLines = {$plugin.tx_bwcaptcha.settings.maxFrontLines} - maxBehindLines = {$plugin.tx_bwcaptcha.settings.maxBehindLines} - maxAngle = {$plugin.tx_bwcaptcha.settings.maxAngle} - maxOffset = {$plugin.tx_bwcaptcha.settings.maxOffset} - interpolation = {$plugin.tx_bwcaptcha.settings.interpolation} - ignoreAllEffects = {$plugin.tx_bwcaptcha.settings.ignoreAllEffects} - audioButton = {$plugin.tx_bwcaptcha.settings.audioButton} - } + settings { + lifetime = {$plugin.tx_bwcaptcha.settings.lifetime} + refreshButton = {$plugin.tx_bwcaptcha.settings.refreshButton} + length = {$plugin.tx_bwcaptcha.settings.length} + charset = {$plugin.tx_bwcaptcha.settings.charset} + width = {$plugin.tx_bwcaptcha.settings.width} + height = {$plugin.tx_bwcaptcha.settings.height} + fontFiles = {$plugin.tx_bwcaptcha.settings.fontFiles} + textColor = {$plugin.tx_bwcaptcha.settings.textColor} + lineColor = {$plugin.tx_bwcaptcha.settings.lineColor} + backgroundColor = {$plugin.tx_bwcaptcha.settings.backgroundColor} + distortion = {$plugin.tx_bwcaptcha.settings.distortion} + maxFrontLines = {$plugin.tx_bwcaptcha.settings.maxFrontLines} + maxBehindLines = {$plugin.tx_bwcaptcha.settings.maxBehindLines} + maxAngle = {$plugin.tx_bwcaptcha.settings.maxAngle} + maxOffset = {$plugin.tx_bwcaptcha.settings.maxOffset} + interpolation = {$plugin.tx_bwcaptcha.settings.interpolation} + ignoreAllEffects = {$plugin.tx_bwcaptcha.settings.ignoreAllEffects} + audioButton = {$plugin.tx_bwcaptcha.settings.audioButton} + } } plugin.tx_sfeventmgt { - view { - partialRootPaths.999999 = EXT:bw_captcha/Resources/Private/SfEventMgt/ - } - settings.registration.captcha { - bwCaptcha < plugin.tx_bwcaptcha.settings - } + view { + partialRootPaths.999999 = EXT:bw_captcha/Resources/Private/SfEventMgt/ + } + + settings.registration.captcha { + bwCaptcha < plugin.tx_bwcaptcha.settings + } } captcha = PAGE captcha { - typeNum = 3413 + typeNum = 3413 - config { - disableAllHeaderCode = 1 - xhtml_cleaning = 0 - admPanel = 0 - debug = 0 - } + config { + disableAllHeaderCode = 1 + xhtml_cleaning = 0 + admPanel = 0 + debug = 0 + } } audio < captcha -audio.typeNum = 3414 \ No newline at end of file +audio.typeNum = 3414 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..5b353ba --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,294 @@ +## GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +### Preamble + +The licenses for most software are designed to take away your freedom +to share and change it. By contrast, the GNU General Public License is +intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + +We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, +we want its recipients to know that what they have is not the +original, so that any problems introduced by others will not reflect +on the original authors' reputations. + +Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at +all. + +The precise terms and conditions for copying, distribution and +modification follow. + +### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +**0.** This License applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work +based on the Program" means either the Program or any derivative work +under copyright law: that is to say, a work containing the Program or +a portion of it, either verbatim or with modifications and/or +translated into another language. (Hereinafter, translation is +included without limitation in the term "modification".) Each licensee +is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the Program +(independent of having been made by running the Program). Whether that +is true depends on what the Program does. + +**1.** You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a +fee. + +**2.** You may modify your copy or copies of the Program or any +portion of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + +**a)** You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. + + +**b)** You must cause any work that you distribute or publish, that in +whole or in part contains or is derived from the Program or any part +thereof, to be licensed as a whole at no charge to all third parties +under the terms of this License. + + +**c)** If the modified program normally reads commands interactively +when run, you must cause it, when started running for such interactive +use in the most ordinary way, to print or display an announcement +including an appropriate copyright notice and a notice that there is +no warranty (or else, saying that you provide a warranty) and that +users may redistribute the program under these conditions, and telling +the user how to view a copy of this License. (Exception: if the +Program itself is interactive but does not normally print such an +announcement, your work based on the Program is not required to print +an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +**3.** You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + +**a)** Accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of Sections 1 +and 2 above on a medium customarily used for software interchange; or, + + +**b)** Accompany it with a written offer, valid for at least three +years, to give any third party, for a charge no more than your cost of +physically performing source distribution, a complete machine-readable +copy of the corresponding source code, to be distributed under the +terms of Sections 1 and 2 above on a medium customarily used for +software interchange; or, + + +**c)** Accompany it with the information you received as to the offer +to distribute corresponding source code. (This alternative is allowed +only for noncommercial distribution and only if you received the +program in object code or executable form with such an offer, in +accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +**4.** You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt otherwise +to copy, modify, sublicense or distribute the Program is void, and +will automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + +**5.** You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +**6.** Each time you redistribute the Program (or any work based on +the Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + +**7.** If, as a consequence of a court judgment or allegation of +patent infringement or for any other reason (not limited to patent +issues), conditions are imposed on you (whether by court order, +agreement or otherwise) that contradict the conditions of this +License, they do not excuse you from the conditions of this License. +If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, +then as a consequence you may not distribute the Program at all. For +example, if a patent license would not permit royalty-free +redistribution of the Program by all those who receive copies directly +or indirectly through you, then the only way you could satisfy both it +and this License would be to refrain entirely from distribution of the +Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +**8.** If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + +**9.** The Free Software Foundation may publish revised and/or new +versions of the General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Program does not specify a +version number of this License, you may choose any version ever +published by the Free Software Foundation. + +**10.** If you wish to incorporate parts of the Program into other +free programs whose distribution conditions are different, write to +the author to ask for permission. For software which is copyrighted by +the Free Software Foundation, write to the Free Software Foundation; +we sometimes make exceptions for this. Our decision will be guided by +the two goals of preserving the free status of all derivatives of our +free software and of promoting the sharing and reuse of software +generally. + +**NO WARRANTY** + +**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + +### END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md index d60e5da..d3057ce 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ Add the captcha element via Form Editor to your form or directly to your yaml fo ```yaml renderables: - - type: Captcha - identifier: captcha - label: Captcha - properties: - fluidAdditionalAttributes: - required: required - autocomplete: 'off' + - type: Captcha + identifier: captcha + label: Captcha + properties: + fluidAdditionalAttributes: + required: required + autocomplete: 'off' ``` ## Configuration @@ -121,7 +121,9 @@ plugin.tx_bwcaptcha { #### sf_event_mgt To use the captcha element in the [sf_event_mgt](https://github.com/derhansen/sf_event_mgt/) extension, you need to include the captcha -partial in your custom event [Registration](https://github.com/derhansen/sf_event_mgt/blob/main/Resources/Private/Templates/Event/Registration.html) template and activate the **sfEventMgt** feature in the extension settings: +partial in your custom +event [Registration](https://github.com/derhansen/sf_event_mgt/blob/main/Resources/Private/Templates/Event/Registration.html) template and +activate the **sfEventMgt** feature in the extension settings: ```diff @@ -141,15 +143,15 @@ your [form setup](https://docs.typo3.org/c/typo3/cms-form/main/en-us/I/Concepts/ ```yaml TYPO3: - CMS: - Form: - prototypes: - standard: - formElementsDefinition: - Form: - renderingOptions: - partialRootPaths: - 1680889288: 'EXT:your_ext/Resources/Private/Frontend/Partials/' + CMS: + Form: + prototypes: + standard: + formElementsDefinition: + Form: + renderingOptions: + partialRootPaths: + 1680889288: 'EXT:your_ext/Resources/Private/Frontend/Partials/' ``` ## Migration from version 3.x to 4.x @@ -158,7 +160,7 @@ This version aims to make solving the captcha more accessible. It introduces a n current captcha code. Missing `ARIA` properties have been added. * Check out - the [new captcha partial](https://github.com/maikschneider/bw_captcha/blob/master/Resources/Private/Frontend/Partials/Captcha.html) +the [new captcha partial](https://github.com/maikschneider/bw_captcha/blob/master/Resources/Private/Frontend/Partials/Captcha.html) * Audio button is enabled by default (can be disabled via `plugin.tx_bwcaptcha.settings.audioButton`) ## Migration from version 2.x to 3.x @@ -170,7 +172,7 @@ link. **tl;dr**: * Check out - the [new captcha partial](https://github.com/maikschneider/bw_captcha/blob/master/Resources/Private/Frontend/Partials/Captcha.html) +the [new captcha partial](https://github.com/maikschneider/bw_captcha/blob/master/Resources/Private/Frontend/Partials/Captcha.html) * Reload button is enabled by default (can be disabled via `plugin.tx_bwcaptcha.settings.refreshButton`) * You can re-enable the page cache, if disabled it because of this element @@ -183,20 +185,22 @@ for the pageType 3413, e.g.: ```yaml routeEnhancers: - PageTypeSuffix: - type: PageType - default: / - index: index - map: - /: 0 - .captcha: 3413 - .audio: 3414 + PageTypeSuffix: + type: PageType + default: / + index: index + map: + /: 0 + .captcha: 3413 + .audio: 3414 ``` +## License + +This project is licensed under [GNU General Public License 2.0 (or later)](LICENSE.md). + ## Contribute This extension was made by Maik Schneider: Feel free to contribute! -* [Github-Repository](https://github.com/maikschneider/bw_captcha) - Thanks to [blueways](https://www.blueways.de/) and [XIMA](https://www.xima.de/)! diff --git a/Resources/Private/Frontend/Partials/Captcha.html b/Resources/Private/Frontend/Partials/Captcha.html index f3e00e7..cf85f3c 100644 --- a/Resources/Private/Frontend/Partials/Captcha.html +++ b/Resources/Private/Frontend/Partials/Captcha.html @@ -1,60 +1,68 @@ - + - - - - + + + + - diff --git a/Resources/Private/SfEventMgt/Registration/Captcha/BwCaptcha.html b/Resources/Private/SfEventMgt/Registration/Captcha/BwCaptcha.html index a907e80..2129c64 100644 --- a/Resources/Private/SfEventMgt/Registration/Captcha/BwCaptcha.html +++ b/Resources/Private/SfEventMgt/Registration/Captcha/BwCaptcha.html @@ -1,6 +1,4 @@ - +
@@ -9,52 +7,60 @@ * -
- + +
+
- \ No newline at end of file + diff --git a/Resources/Private/Sounds/generate.sh b/Resources/Private/Sounds/generate.sh index 615fc1c..f897267 100755 --- a/Resources/Private/Sounds/generate.sh +++ b/Resources/Private/Sounds/generate.sh @@ -7,13 +7,13 @@ languages=( ) for index in "${languages[@]}" ; do - LANGUAGE="${index%%::*}" - VOICE="${index##*::}" +LANGUAGE="${index%%::*}" +VOICE="${index##*::}" - mkdir -p "$LANGUAGE" +mkdir -p "$LANGUAGE" - for x in {A..Z} - do +for x in {A..Z} +do lowerX=$(echo "$x" | tr '[:upper:]' '[:lower:]' ) say "$lowerX" -v $VOICE -o "$LANGUAGE/$lowerX.aiff" say "$x" -v $VOICE -o "$LANGUAGE/$lowerX-upper.aiff" @@ -23,19 +23,19 @@ for index in "${languages[@]}" ; do rm "$LANGUAGE/$lowerX.aiff" rm "$LANGUAGE/$lowerX-upper.aiff" - done +done - for x in {0..9} - do +for x in {0..9} +do say "$x" -v $VOICE -o "$LANGUAGE/$x.aiff" ffmpeg -i "$LANGUAGE/$x.aiff" -map_metadata -1 -fflags +bitexact "$LANGUAGE/$x.wav" rm "$LANGUAGE/$x.aiff" - done +done done say "[[slnc 400]]" -o "silence.aiff" ffmpeg -i "silence.aiff" -map_metadata -1 -fflags +bitexact "silence.wav" -rm silence.aiff \ No newline at end of file +rm silence.aiff diff --git a/Resources/Public/JavaScript/Backend/FormEditor/CaptchaViewModel.js b/Resources/Public/JavaScript/Backend/FormEditor/CaptchaViewModel.js index a68e965..211fd90 100644 --- a/Resources/Public/JavaScript/Backend/FormEditor/CaptchaViewModel.js +++ b/Resources/Public/JavaScript/Backend/FormEditor/CaptchaViewModel.js @@ -1,109 +1,17 @@ /** - * Module: @blueways/bw-captcha/Backend/FormEditor/CaptchaViewModel.js - */ -import $ from 'jquery'; -import * as Helper from '@typo3/form/backend/form-editor/helper.js' +* Module: @blueways/bw-captcha/Backend/FormEditor/CaptchaViewModel.js +*/ +import * as Helper from '@typo3/form/backend/form-editor/helper.js'; -/** - * @private - * - * @var object - */ -let _formEditorApp = null; - -/** - * @private - * - * @return object - */ -function getFormEditorApp() { - return _formEditorApp; -}; - -/** - * @private - * - * @return object - */ -function getPublisherSubscriber() { - return getFormEditorApp().getPublisherSubscriber(); -}; - -/** - * @private - * - * @return object - */ -function getUtility() { - return getFormEditorApp().getUtility(); -}; - -/** - * @private - * - * @param object - * @return object - */ -function getHelper() { - return Helper; -}; - -/** - * @private - * - * @return object - */ -function getCurrentlySelectedFormElement() { - return getFormEditorApp().getCurrentlySelectedFormElement(); -}; - -/** - * @private - * - * @param mixed test - * @param string message - * @param int messageCode - * @return void - */ -function assert(test, message, messageCode) { - return getFormEditorApp().assert(test, message, messageCode); -}; - -/** - * @private - * - * @return void - * @throws 1491643380 - */ -function _helperSetup() { - assert('function' === $.type(Helper.bootstrap), - 'The view model helper does not implement the method "bootstrap"', - 1491643380 - ); - Helper.bootstrap(getFormEditorApp()); -}; - -/** - * @private - * - * @return void - */ -function _subscribeEvents() { - getPublisherSubscriber().subscribe('view/stage/abstract/render/template/perform', function (topic, args) { - if (args[0].get('type') === 'Captcha') { - getFormEditorApp().getViewModel().getStage().renderSimpleTemplateWithValidators(args[0], args[1]); - } - }); -}; - -/** - * @public - * - * @param object formEditorApp - * @return void - */ export function bootstrap(formEditorApp) { - _formEditorApp = formEditorApp; - _helperSetup(); - _subscribeEvents(); -}; \ No newline at end of file + Helper.bootstrap(formEditorApp); + + formEditorApp.getPublisherSubscriber().subscribe( + 'view/stage/abstract/render/template/perform', + (topic, args) => { + if (args[0].get('type') === 'Captcha') { + formEditorApp.getViewModel().getStage().renderSimpleTemplateWithValidators(args[0], args[1]); + } + } + ); +} diff --git a/Resources/Public/JavaScript/Frontend/CaptchaAudio.js b/Resources/Public/JavaScript/Frontend/CaptchaAudio.js index 534ac7c..c50e3e1 100644 --- a/Resources/Public/JavaScript/Frontend/CaptchaAudio.js +++ b/Resources/Public/JavaScript/Frontend/CaptchaAudio.js @@ -1,27 +1,27 @@ function onClick() { - const div = this.parentElement; - window.captchaAudio = window.captchaAudio ? window.captchaAudio : new Audio(); - window.captchaAudio.addEventListener('ended', () => div.classList.remove('captcha--playing')); - if (window.captchaAudio.paused) { - div.classList.add('captcha--playing'); - const img = div.querySelector('img'); - const c = document.createElement('canvas'); - const ctx = c.getContext('2d'); - const data = new FormData(); - c.width = img.naturalWidth; - c.height = img.naturalHeight; - ctx.drawImage(img, 0, 0); - data.append('captchaDataUrl', c.toDataURL()); - fetch('{f:uri.page(pageType:3414)}', { - method: 'POST', - body: data - }).then(response => response.blob()).then(blob => { - window.captchaAudio.src = window.URL.createObjectURL(blob); - window.captchaAudio.play(); - }); - } else { - window.captchaAudio.pause(); - div.classList.remove('captcha--playing') - } - return false; -} \ No newline at end of file + const div = this.parentElement; + window.captchaAudio = window.captchaAudio ? window.captchaAudio : new Audio(); + window.captchaAudio.addEventListener('ended', () => div.classList.remove('captcha--playing')); + if (window.captchaAudio.paused) { + div.classList.add('captcha--playing'); + const img = div.querySelector('img'); + const c = document.createElement('canvas'); + const ctx = c.getContext('2d'); + const data = new FormData(); + c.width = img.naturalWidth; + c.height = img.naturalHeight; + ctx.drawImage(img, 0, 0); + data.append('captchaDataUrl', c.toDataURL()); + fetch('{f:uri.page(pageType:3414)}', { + method: 'POST', + body: data + }).then(response => response.blob()).then(blob => { + window.captchaAudio.src = window.URL.createObjectURL(blob); + window.captchaAudio.play(); + }); + } else { + window.captchaAudio.pause(); + div.classList.remove('captcha--playing') + } + return false; +} diff --git a/composer.json b/composer.json index 50cd43b..1fea214 100644 --- a/composer.json +++ b/composer.json @@ -1,60 +1,101 @@ { - "name": "blueways/bw-captcha", - "type": "typo3-cms-extension", - "description": "Captcha element with audio support for TYPO3 form components. The captcha generation does not rely on Google or third-party integrations.", - "require": { - "php": "^8.1", - "typo3/cms-core": "^12.0 || ^13.0", - "ext-gd": "*" - }, - "autoload": { - "psr-4": { - "Blueways\\BwCaptcha\\": "Classes", - "Gregwar\\Captcha\\": "Libraries/Captcha/src/Gregwar/Captcha", - "MaikSchneider\\Steganography\\": "Libraries/Steganography/src" - } - }, - "require-dev": { - "roave/security-advisories": "dev-latest", - "typo3/cms-base-distribution": "^12.4 || ^13.4", - "typo3/cms-lowlevel": "^12.4 || ^13.4", - "bk2k/bootstrap-package": "^15.0", - "friendsofphp/php-cs-fixer": "^3.12", - "saschaegerer/phpstan-typo3": "^1.9", - "helhum/typo3-console": "^7.0 || ^8.0", - "derhansen/sf_event_mgt": "^7.6 || ^8.0" - }, - "extra": { - "typo3/cms": { - "cms-package-dir": "{$vendor-dir}/typo3/cms", - "web-dir": "public", - "extension-key": "bw_captcha" - } - }, - "config": { - "allow-plugins": { - "typo3/class-alias-loader": true, - "typo3/cms-composer-installers": true - } - }, - "license": [ - "GPL-2.0-or-later" - ], - "authors": [ - { - "name": "Maik Schneider", - "email": "schneider.maik@me.com", - "role": "Developer" - } - ], - "keywords": [ - "TYPO3" - ], - "scripts": { - "php:fixer": "php vendor/bin/php-cs-fixer --config=php-cs-fixer.php fix", - "php:stan": "php vendor/bin/phpstan --generate-baseline=phpstan-baseline.neon --allow-empty-baseline", - "ci:php:lint": "find *.php . -name '*.php' ! -path './vendor/*' ! -path './var/*' ! -path '*node_modules/*' -print0 | xargs -0 -n 1 -P 4 php -l", - "ci:php:fixer": "php vendor/bin/php-cs-fixer --config=php-cs-fixer.php fix --dry-run -v --show-progress=dots", - "ci:php:stan": "php vendor/bin/phpstan --no-progress" - } + "name": "blueways/bw-captcha", + "description": "Captcha element with audio support for TYPO3 form components. The captcha generation does not rely on Google or third-party integrations.", + "license": [ + "GPL-2.0-or-later" + ], + "type": "typo3-cms-extension", + "keywords": [ + "TYPO3" + ], + "authors": [ + { + "name": "Maik Schneider", + "email": "schneider.maik@me.com", + "role": "Developer" + } + ], + "require": { + "php": "^8.1", + "ext-gd": "*", + "typo3/cms-core": "^12.0 || ^13.0" + }, + "require-dev": { + "armin/editorconfig-cli": "^2.0", + "bk2k/bootstrap-package": "^15.0", + "derhansen/sf_event_mgt": "^7.6 || ^8.0", + "ergebnis/composer-normalize": "^2.44", + "friendsofphp/php-cs-fixer": "^3.12", + "helhum/typo3-console": "^7.0 || ^8.0", + "helmich/typo3-typoscript-lint": "^3.2", + "roave/security-advisories": "dev-latest", + "saschaegerer/phpstan-typo3": "^1.9", + "ssch/typo3-rector": "^2.10", + "symfony/translation": "^7.1", + "typo3/cms-base-distribution": "^12.4 || ^13.4", + "typo3/cms-lowlevel": "^12.4 || ^13.4" + }, + "autoload": { + "psr-4": { + "Blueways\\BwCaptcha\\": "Classes", + "Gregwar\\Captcha\\": "Libraries/Captcha/src/Gregwar/Captcha", + "MaikSchneider\\Steganography\\": "Libraries/Steganography/src" + } + }, + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true, + "typo3/class-alias-loader": true, + "typo3/cms-composer-installers": true + } + }, + "extra": { + "typo3/cms": { + "cms-package-dir": "{$vendor-dir}/typo3/cms", + "extension-key": "bw_captcha", + "web-dir": "public" + } + }, + "scripts": { + "ci:composer:normalize": "@composer normalize --no-check-lock --dry-run", + "ci:editorconfig:lint": "ec --strict --git-only -n", + "ci:php:fixer": "php-cs-fixer --config=php-cs-fixer.php fix --dry-run --format=checkstyle > php-cs-fixer.xml || true", + "ci:php:lint": "find *.php . -name '*.php' ! -path './vendor/*' ! -path './var/*' ! -path '*node_modules/*' -print0 | xargs -0 -n 1 -P 4 php -l", + "ci:php:stan": "phpstan --no-progress --error-format=checkstyle > phpstan.xml || true", + "ci:rector": "rector --dry-run", + "ci:sca": [ + "@ci:composer:normalize", + "@ci:php:lint", + "@ci:php:fixer", + "@ci:php:stan", + "@ci:rector", + "@ci:editorconfig:lint", + "@ci:typoscript:lint", + "@ci:xml:lint", + "@ci:yaml:lint" + ], + "ci:typoscript:lint": "typoscript-lint --fail-on-warnings", + "ci:xml:lint": "find ./ -name '*.xlf' ! -path './vendor/*' ! -path './var/*' | xargs -r xmllint --schema vendor/symfony/translation/Resources/schemas/xliff-core-1.2-transitional.xsd --noout", + "ci:yaml:lint": "find ./ ! -path './vendor/*' ! -path '*/node_modules/*' \\( -name '*.yaml' -o -name '*.yml' \\) | xargs -r yaml-lint", + "composer:normalize": "@composer normalize --no-check-lock", + "editorconfig:fix": "ec --strict --fix --git-only -n", + "php:fixer": "php-cs-fixer --config=php-cs-fixer.php fix", + "php:lint": "find *.php . -name '*.php' ! -path './vendor/*' ! -path './var/*' ! -path '*node_modules/*' -print0 | xargs -0 -n 1 -P 4 php -l", + "php:stan": "phpstan --generate-baseline=phpstan-baseline.neon --allow-empty-baseline", + "rector": "rector", + "sca": [ + "@composer:normalize", + "@php:fixer", + "@rector", + "@editorconfig:fix", + "@php:lint", + "@php:stan", + "@typoscript:lint", + "@xml:lint", + "@yaml:lint" + ], + "typoscript:lint": "typoscript-lint", + "xml:lint": "find ./ -name '*.xlf' ! -path './vendor/*' ! -path './var/*' | xargs -r xmllint --schema vendor/symfony/translation/Resources/schemas/xliff-core-1.2-transitional.xsd --noout", + "yaml:lint": "find ./ ! -path './vendor/*' ! -path '*/node_modules/*' \\( -name '*.yaml' -o -name '*.yml' \\) | xargs -r yaml-lint" + } } diff --git a/ext_conf_template.txt b/ext_conf_template.txt index dcd84da..c9cac6a 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -1,2 +1,2 @@ # cat=basic/enable/050; type=boolean; label=sf_event_mgt: Enable to use bw_captcha with sf_event_mgt -sfEventMgt = 0 \ No newline at end of file +sfEventMgt = 0 diff --git a/ext_emconf.php b/ext_emconf.php index 93ea530..1f297bb 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,11 +8,10 @@ 'author_company' => 'XIMA Media GmbH', 'author_email' => 'maik.schneider@xima.de', 'state' => 'stable', - 'clearCacheOnLoad' => true, 'version' => '4.1.2', 'constraints' => [ 'depends' => [ - 'typo3' => '12.0.0-13.99.99', + 'typo3' => '12.4.0-13.4.99', ], 'conflicts' => [], 'suggests' => [], diff --git a/php-cs-fixer.php b/php-cs-fixer.php index 7d66b9d..ffdb9f1 100644 --- a/php-cs-fixer.php +++ b/php-cs-fixer.php @@ -42,6 +42,7 @@ // - Ensure Concatenation to have at least one whitespace around // - Remove trailing whitespace at the end of blank lines. return (new \PhpCsFixer\Config()) + ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) ->setRiskyAllowed(true) ->setRules([ '@DoctrineAnnotation' => true, diff --git a/phpstan.neon b/phpstan.neon index 68e39d0..7348fd6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,18 +1,18 @@ includes: - - vendor/saschaegerer/phpstan-typo3/extension.neon - - phpstan-baseline.neon + - vendor/saschaegerer/phpstan-typo3/extension.neon + - phpstan-baseline.neon parameters: - parallel: - maximumNumberOfProcesses: 5 + parallel: + maximumNumberOfProcesses: 5 - level: 8 + level: 8 - bootstrapFiles: - - vendor/autoload.php + bootstrapFiles: + - vendor/autoload.php - paths: - - Classes - - Configuration + paths: + - Classes + - Configuration - excludePaths: + excludePaths: diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..d14b9f7 --- /dev/null +++ b/rector.php @@ -0,0 +1,53 @@ +withPaths([ + __DIR__ . '/Classes', + __DIR__ . '/Configuration', + __DIR__ . '/ext_emconf.php', + __DIR__ . '/ext_localconf.php', + ]) + // uncomment to reach your current PHP version + // ->withPhpSets() + ->withPhpVersion(PhpVersion::PHP_81) + ->withSets([ + Typo3SetList::CODE_QUALITY, + Typo3SetList::GENERAL, + Typo3LevelSetList::UP_TO_TYPO3_12, + ]) + // To have a better analysis from PHPStan, we teach it here some more things + ->withPHPStanConfigs([ + Typo3Option::PHPSTAN_FOR_RECTOR_PATH, + ]) + ->withRules([ + AddVoidReturnTypeWhereNoReturnRector::class, + ConvertImplicitVariablesToExplicitGlobalsRector::class, + ]) + ->withConfiguredRule(ExtEmConfRector::class, [ + ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.1.0-8.3.99', + ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '12.4.0-13.4.99', + ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [], + ]) + // If you use withImportNames(), you should consider excluding some TYPO3 files. + ->withSkip([ + // @see https://github.com/sabbelasichon/typo3-rector/issues/2536 + __DIR__ . '/**/Configuration/ExtensionBuilder/*', + NameImportingPostRector::class => [ + 'ext_localconf.php', // This line can be removed since TYPO3 11.4, see https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.4/Important-94280-MoveContentsOfExtPhpIntoLocalScopes.html + 'ext_tables.php', // This line can be removed since TYPO3 11.4, see https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.4/Important-94280-MoveContentsOfExtPhpIntoLocalScopes.html + 'ClassAliasMap.php', + ], + ]) +; diff --git a/renovate.json b/renovate.json index a4f93e2..602630a 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,9 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base" - ], - "ignorePaths": ["Libraries/**"] + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ], + "ignorePaths": [ + "Libraries/**" + ] }