custom/plugins/LaudertFriendlyCaptcha/src/Resources/views/storefront/component/captcha/friendlyCaptcha.html.twig line 1

Open in your IDE?
  1. {% block component_captcha_friendly_captcha %}
  2.     {% set configNamespace = constant('Laudert\\FriendlyCaptcha\\LaudertFriendlyCaptcha::CONFIG_KEY') %}
  3.     {% set siteKey = config('%s.config.siteKey'|format(configNamespace)) %}
  4.     {% set secretKey = config('%s.config.secretKey'|format(configNamespace)) %}
  5.     {% if siteKey and secretKey %}
  6.         {% set locale = app.request.locale|slice(0, 2) %}
  7.         {% set supportedLanguages = [
  8.             'en', 'fr', 'de', 'it', 'nl', 'pt', 'es', 'ca', 'da',
  9.             'ja', 'el', 'uk', 'bg', 'cs', 'sk', 'no', 'fi', 'lt',
  10.             'pl', 'et', 'hr', 'sr', 'sl', 'hu', 'ro', 'nb', 'zh'
  11.         ] %}
  12.         {% set friendlyCaptchaOptions = {
  13.             jsPluginOptions: {
  14.                 deliveryMethod: config('%s.config.deliveryMethod'|format(configNamespace)),
  15.                 polyfill: config('%s.config.polyfill'|format(configNamespace))
  16.             },
  17.             puzzleEndpoints: {
  18.                 global: 'https://api.friendlycaptcha.com/api/v1/puzzle',
  19.                 europe: 'https://eu-api.friendlycaptcha.eu/api/v1/puzzle'
  20.             },
  21.             lang: locale in supportedLanguages ? locale : 'en'
  22.         } %}
  23.         {% set puzzleEndpoint = friendlyCaptchaOptions.puzzleEndpoints.global %}
  24.         {% if config('%s.config.endpointSelection'|format(configNamespace)) == 'europe' %}
  25.             {% set puzzleEndpoint = friendlyCaptchaOptions.puzzleEndpoints.europe %}
  26.             {% if config('%s.config.endpointSelectionFallback'|format(configNamespace)) %}
  27.                 {% set puzzleEndpoint = puzzleEndpoint ~ "," ~ friendlyCaptchaOptions.puzzleEndpoints.global %}
  28.             {% endif %}
  29.         {% endif %}
  30.         {% block component_friendly_captcha_form_row %}
  31.             <div class="form-row friendly-captcha">
  32.                 {% block component_friendly_captcha_form_group %}
  33.                     <div class="form-group {% if additionalClass %}{{ additionalClass }}{% else %}col-md-6{% endif %}">
  34.                         {% block component_friendly_captcha_widget %}
  35.                             {% set themeName = config('%s.config.theme.name'|format(configNamespace)) %}
  36.                             <div
  37.                                 {# @see https://docs.friendlycaptcha.com/#/theme?id=dark-mode #}
  38.                                 class="frc-captcha{% if 'dark' === themeName %} dark{% endif %}"
  39.                                 {# this needs to be set with the html api or friendly captcha will issue a warning in the console. #}
  40.                                 data-sitekey="{{ siteKey }}" data-lang="{{ friendlyCaptchaOptions.lang }}"
  41.                                 data-friendly-captcha-plugin="true" data-start="{{ config('%s.config.startMode'|format(configNamespace)) }}"
  42.                                 data-puzzle-endpoint="{{ puzzleEndpoint }}"
  43.                                 data-friendly-captcha-plugin-options='{{ friendlyCaptchaOptions.jsPluginOptions|json_encode }}'
  44.                             >
  45.                                 {# this div cannot be self closing because the form rows would break #}
  46.                             </div>
  47.                         {% endblock %}
  48.                         <noscript>
  49.                             {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  50.                                 type: 'warning',
  51.                                 heading: 'captcha.noscriptHeadline'|trans|sw_sanitize,
  52.                                 content: 'captcha.noscriptNotice'|trans|sw_sanitize
  53.                             } %}
  54.                         </noscript>
  55.                     </div>
  56.                 {% endblock %}
  57.             </div>
  58.         {% endblock %}
  59.     {% endif %}
  60. {% endblock %}