praiadeseselle/site/modules/PrivacyWire/PrivacyWireConfig.php

415 lines
24 KiB
PHP
Raw Permalink Normal View History

2024-04-04 15:12:59 +02:00
<?php namespace ProcessWire;
class PrivacyWireConfig extends ModuleConfig
{
public function __construct()
{
$textarea_type = 'textarea';
if ($this->wire()->modules->isInstalled('InputfieldTinyMCE')) {
$textarea_type = 'tinymce';
} elseif ($this->wire()->modules->isInstalled('InputfieldCkeditor')) {
$textarea_type = 'ckeditor';
}
$this->add([
[ // general config
'name' => 'privacywire-general',
'type' => 'fieldset',
'label' => 'General Options',
'children' => [
[
'name' => 'is_active',
'type' => 'checkbox',
'label' => $this->_('Do you want to activate PrivacyWire?')
],
[ // opt-in type
'name' => 'cookie_groups',
'type' => 'asmselect',
'label' => $this->_('Available Cookie Groups'),
'description' => sprintf($this->_("Select the cookie groups displayed to the user. If more than the two default groups ('%s' and '%s') are allowed, the option window will be shown to the user."), $this->_("All Cookies"), $this->_("Necessary Cookies")),
'options' => [
"all" => $this->_("All Cookies"),
"necessary" => $this->_("Necessary Cookies"),
"functional" => $this->_("Functional Cookies"),
"statistics" => $this->_("Statistics Cookies"),
'marketing' => $this->_("Marketing Cookies"),
'external_media' => $this->_("External Media Cookies")
],
],
[ // version, integer
'name' => 'version',
'type' => 'integer',
'label' => $this->_('Versioning'),
'description' => $this->_("When you increase the version number, all users have to opt-in again. This version number is saved with the users consent in the cookie."),
'min' => 1,
'columnWidth' => 25,
],
[ // respect "do not track"
'name' => 'respectDNT',
'type' => 'checkbox',
'label' => $this->_('DNT: Do Not Track'),
'description' => $this->_("If enabled, PrivacyWire checks if the users browser sends the DNT-Header. If so, no cookie banner will be shown and the user will be handled like 'Only Necessary Cookies' would be chosen."),
'checkboxLabel' => $this->_('Respect "Do Not Track" Settings from the browser'),
'columnWidth' => 25,
],
[ // handle bots as only necessary
'name' => 'checkForBots',
'type' => 'checkbox',
'label' => $this->_('Bots: Hide Banner'),
'description' => $this->_("If enabled, PrivacyWire checks if the user-agent is some kind of bot. If so, no cookie banner will be shown and the user will be handled like 'Only Necessary Cookies' would be chosen. This im"),
'checkboxLabel' => $this->_('Treat bots as "only necessary" is chosen'),
'columnWidth' => 25,
],
[ // Message Timeout
'name' => 'messageTimeout',
'type' => 'integer',
'label' => $this->_('Consent Saving Confirmation Duration'),
'description' => $this->_("How many milliseconds should the consent saving confirmation be visible after the user makes a choice."),
'columnWidth' => 25,
],
],
],
[ // groups labels
'name' => 'privacywire-group-labels',
'type' => 'fieldset',
'label' => 'Cookie Groups Labels',
'children' => [
[ // label for cookie group: necessary
'name' => 'cookies_necessary_label',
'type' => 'text',
'label' => $this->_('Necessary Cookies'),
'useLanguages' => true,
'columnWidth' => 50,
'value' => $this->_("Necessary Cookies"),
],
[ // label for cookie group: functional
'name' => 'cookies_functional_label',
'type' => 'text',
'label' => $this->_('Functional Cookies'),
'showIf' => 'cookie_groups=functional',
'useLanguages' => true,
'columnWidth' => 50,
'value' => $this->_("Functional Cookies"),
],
[ // label for cookie group: statistics
'name' => 'cookies_statistics_label',
'type' => 'text',
'label' => $this->_('Statistics Cookies'),
'showIf' => 'cookie_groups=statistics',
'useLanguages' => true,
'columnWidth' => 50,
'value' => $this->_("Statistics Cookies"),
],
[ // label for cookie group: marketing
'name' => 'cookies_marketing_label',
'type' => 'text',
'label' => $this->_('Marketing Cookies'),
'showIf' => 'cookie_groups=marketing',
'useLanguages' => true,
'columnWidth' => 50,
'value' => $this->_("Statistics Cookies"),
],
[ // label for cookie group: external media
'name' => 'cookies_external_media_label',
'type' => 'text',
'label' => $this->_('External Media Cookies'),
'showIf' => 'cookie_groups=external_media',
'useLanguages' => true,
'columnWidth' => 50,
'value' => $this->_("External Media Cookies")
],
],
],
[ // banner
'name' => 'privacywire-banner',
'type' => 'fieldset',
'label' => 'Banner Options',
'children' => [
[ // banner headline (optional)
'name' => 'content_banner_title',
'type' => 'text',
'label' => $this->_('Title'),
'description' => $this->_("Optional: If empty, no headline will be shown in the banner."),
'useLanguages' => true,
'columnWidth' => 100,
],
[ // banner body copy
'name' => 'content_banner_text',
'type' => $textarea_type,
'label' => $this->_('Text'),
//'toolbar' => 'Bold, Italic, NumberedList, BulletedList, PWLink, Unlink, PWImage, Table',
'useLanguages' => true,
'columnWidth' => 100,
],
[ // banner show details
'name' => 'content_banner_details_show',
'type' => 'checkbox',
'label' => $this->_('Additional details in the options banner'),
'description' => $this->_("If enabled, you will have the possibility to display additional headline and text elements within the options banner where the user can select the cookies allowed."),
'checkboxLabel' => $this->_('Display additional details in the options banner'),
'columnWidth' => 100,
],
[ // banner details headline (optional)
'name' => 'content_banner_details_title',
'type' => 'text',
'label' => $this->_('Details Headline'),
'description' => $this->_("Optional: If empty, no headline will be shown in the banner."),
'showIf' => "content_banner_details_show=1",
'useLanguages' => true,
'columnWidth' => 100,
],
[ // banner details text
'name' => 'content_banner_details_text',
'type' => $textarea_type,
'label' => $this->_('Details Text'),
//'toolbar' => 'Bold, Italic, NumberedList, BulletedList, PWLink, Unlink, PWImage, Table',
'showIf' => "content_banner_details_show=1",
'useLanguages' => true,
'columnWidth' => 100,
],
],
],
[ // links
'name' => 'privacywire-links',
'type' => 'fieldset',
'label' => 'Links Options',
'children' => [
[ // privacy policy url
'name' => 'content_banner_privacy_link',
'type' => 'url',
'label' => $this->_('Privacy Policy URL'),
'description' => $this->_("If you want to output a link to your privacy policy page, add the URL to this page here."),
'useLanguages' => true,
'columnWidth' => 50,
],
[ // privacy policy link title
'name' => 'content_banner_privacy_title',
'type' => 'text',
'label' => $this->_('Privacy Policy link title'),
'description' => $this->_("The text of the link to your privacy policy page."),
//'showIf' => "content_banner_privacy_link!=''",
'useLanguages' => true,
'columnWidth' => 50,
],
[ // imprint url
'name' => 'content_banner_imprint_link',
'type' => 'url',
'label' => $this->_('Imprint URL'),
'description' => $this->_("If you want to output a link to your imprint page, add the URL to this page here."),
'useLanguages' => true,
'columnWidth' => 50,
],
[ // imprint link title
'name' => 'content_banner_imprint_title',
'type' => 'text',
'label' => $this->_('Imprint link title'),
'description' => $this->_("The text of the link to your imprint page."),
//'showIf' => "content_banner_imprint_link!=''",
'useLanguages' => true,
'columnWidth' => 50,
],
],
],
[ // buttons
'name' => 'privacywire-buttons',
'type' => 'fieldset',
'label' => 'Buttons Options',
'children' => [
[ // Button Label: Allow All
'name' => 'content_banner_button_allow_all',
'type' => 'text',
'label' => $this->_('Button Label: Allow All Cookies'),
'useLanguages' => true,
'columnWidth' => 33,
],
[ // Button Label: Allow Necessary
'name' => 'content_banner_button_allow_necessary',
'type' => 'text',
'label' => $this->_('Button Label: Allow Necessary Cookies'),
'useLanguages' => true,
'columnWidth' => 33,
],
[ // Button Label: Choose Cookies
'name' => 'content_banner_button_choose',
'type' => 'text',
'label' => $this->_('Button Label: Choose Cookies'),
'useLanguages' => true,
'columnWidth' => 34,
],
[ // Button Label: Toggle Cookies Options
'name' => 'content_banner_button_toggle',
'type' => 'text',
'label' => $this->_('Button Label: Toggle Cookie Options'),
'useLanguages' => true,
'columnWidth' => 33,
],
[ // Show another "Accept all" instead of the "Toggle" Button
'name' => 'content_banner_button_all_instead_toggle',
'type' => 'checkbox',
'label' => $this->_('Choose Window: "Accept all" instead of "Toggle"'),
'checkboxLabel' => $this->_('Show "Accept all" Button instead of "Toggle" Button'),
'columnWidth' => 33,
],
[ // Button Label: Save Preferences
'name' => 'content_banner_button_save',
'type' => 'text',
'label' => $this->_('Button Label: Save Preferences'),
'useLanguages' => true,
'columnWidth' => 34,
'value' => "",
],
[ // Saved Message Text
'name' => 'content_banner_save_message',
'type' => 'text',
'label' => $this->_('Message: Save Confirmation'),
'useLanguages' => true,
'columnWidth' => 33,
],
[ // Textformatter Button Label
'name' => 'textformatter_choose_label',
'type' => 'text',
'label' => $this->_('Textformatter Button label'),
'useLanguages' => true,
'columnWidth' => 33,
],
[ // Ask for consent Button label
'name' => 'ask_content_button_label',
'type' => 'text',
'label' => $this->_('Button Label: Ask for consent'),
'description' => $this->_("You can insert the current cookie category name by using the placeholder {category}."),
'useLanguages' => true,
'columnWidth' => 34,
],
[ // ask for consent text field
'name' => 'ask_consent_message',
'type' => $textarea_type,
'label' => $this->_('Text above button: Ask for consent'),
'description' => $this->_("You can insert the current cookie category name by using the placeholder {category}."),
//'toolbar' => 'Bold, Italic, NumberedList, BulletedList, PWLink, Unlink, PWImage, Table',
'useLanguages' => true,
'columnWidth' => 100,
],
],
],
[ // advanced options
'name' => 'privacywire-advanced',
'type' => 'fieldset',
'label' => 'Advanced Options',
'children' => [
[ // Output mode
'name' => 'output_mode',
'type' => 'select',
'label' => $this->_('Output mode of PrivacyWire JS Core'),
'description' => $this->_("Choose if you want to render the PrivacyWire JS Core as inline script or regular script tag."),
'options' => [
"regular" => $this->_("Regular script tag"),
"inline" => $this->_("Inline script"),
],
'columnWidth' => 50,
],
[ // banner header tag
'name' => 'banner_header_tag',
'type' => 'select',
'label' => $this->_('Banner Header Tag'),
'description' => $this->_("Choose between <header> and <div>."),
'options' => [
"div" => $this->_("<div>"),
"header" => $this->_("<header>"),
],
'columnWidth' => 50,
],
[ // add basic css styles or not
'name' => 'add_basic_css_styling',
'type' => 'checkbox',
'label' => $this->_('CSS: Add basic CSS Styling'),
'description' => $this->_("If enabled, PrivacyWire will automatically include some very basic css styles to the output."),
'checkboxLabel' => $this->_('Add basic CSS Styling'),
'columnWidth' => 50,
],
[ // use consent detection by class?
'name' => 'detect_consents_by_class',
'type' => 'checkbox',
'label' => $this->_('Detect consent windows by class `require-consent` instead of data-attribute.'),
'description' => $this->_("If enabled, PrivacyWire will use a class selector instead of data-attribute selector to detect elements which require consent. This is more performant."),
'checkboxLabel' => $this->_('Use consent detection by class instead of data-attribute'),
'columnWidth' => 50,
],
[ // alternate banner template
'name' => 'alternate_banner_template',
'type' => 'text',
'label' => $this->_('Alternate Banner Template'),
'description' => $this->_("If you want to replace the original banner template (located in site/modules/PrivacyWire/PrivacyWireBanner.php ) insert the alternative file path here (starting from webroot without leading slash )"),
'columnWidth' => 50,
],
[ // alternate inline consent template
'name' => 'alternate_inline_consent_template',
'type' => 'text',
'label' => $this->_('Alternate Inline Consent Template'),
'description' => $this->_("If you want to replace the original inline consent template (located in site/modules/PrivacyWire/PrivacyWireConsentBlueprint.php ) insert the alternative file path here (starting from webroot without leading slash )"),
'columnWidth' => 50,
],
[ // Trigger a custom js function
'name' => 'trigger_custom_js_function',
'type' => 'text',
'label' => $this->_('Trigger a custom js function'),
'description' => $this->_("If you want to trigger a custom js function after saving the cookie banner, insert the name of the function here"),
'columnWidth' => 50,
],
[ // render manually
'name' => 'render_manually',
'type' => 'checkbox',
'label' => $this->_('Render Banner and Header Content Manually'),
'description' => $this->_("If you want to render PrivacyWire header and banner content manually instead of letting the module render them for you, check this option."),
'notes' => $this->_("Use \n`\$modules->get('PrivacyWire')->headContent` to render header tags and \n`\$modules->get('PrivacyWire')->bodyContent` to render body content. \n**OR** if you want to have the total flexibility where and how you embed the required scripts and markup, have a look into the PrivacyWire.module and read the comments ;-)"),
'columnWidth' => 50,
],
],
],
]);
}
public function getDefaults()
{
return [
'is_active' => true,
'version' => 1,
'cookie_groups' => ["all", "necessary"],
'respectDNT' => false,
'checkForBots' => false,
'cookies_necessary_label' => $this->_('Necessary'),
'cookies_functional_label' => $this->_('Functional'),
'cookies_statistics_label' => $this->_('Statistics'),
'cookies_marketing_label' => $this->_('Marketing'),
'cookies_external_media_label' => $this->_('External Media'),
'content_banner_title' => $this->_("This website is using cookies to provide a good browsing experience"),
'content_banner_text' => $this->_("These include essential cookies that are necessary for the operation of the site, as well as others that are used only for anonymous statistical purposes, for comfort settings or to display personalized content. You can decide for yourself which categories you want to allow. Please note that based on your settings, not all functions of the website may be available."),
'content_banner_details_show' => false,
'content_banner_details_title' => $this->_("This is how and why we use cookies"),
'content_banner_details_text' => $this->_("Here you can store more detailed information on the cookies used or describe individual cookies in depth."),
'content_banner_privacy_link' => null,
'content_banner_privacy_title' => $this->_("Privacy Policy"),
'content_banner_imprint_link' => null,
'content_banner_imprint_title' => $this->_("Imprint"),
'content_banner_button_allow_all' => $this->_("Accept all"),
'content_banner_button_allow_necessary' => $this->_("Accept necessary cookies only"),
'content_banner_button_choose' => $this->_("Choose cookies"),
'content_banner_button_save' => $this->_("Save preferences"),
'content_banner_button_toggle' => $this->_("Toggle options"),
'content_banner_save_message' => $this->_("Your cookie preferences have been saved."),
'content_banner_button_all_instead_toggle' => false,
'textformatter_choose_label' => $this->_("Show or edit my Cookie Consent"),
'trigger_custom_js_function' => "",
'messageTimeout' => 1500,
'add_basic_css_styling' => true,
'ask_consent_message' => $this->_("To load this element, it is required to consent to the following cookie category: {category}."),
'ask_content_button_label' => $this->_("Load {category} cookies"),
'banner_header_tag' => 'div',
'alternate_banner_template' => '',
'alternate_inline_consent_template' => '',
'render_manually' => false,
'detect_consents_by_class' => false,
'output_mode' => 'regular'
];
}
}