Skip to content

Commit

Permalink
[FEATURE] Implement cookie consent from bootstrap_package branch 9.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
buepro committed May 23, 2018
1 parent af5b450 commit 02acde3
Show file tree
Hide file tree
Showing 24 changed files with 1,135 additions and 36 deletions.
93 changes: 93 additions & 0 deletions Classes/DataProcessing/ConstantsProcessor.php
@@ -0,0 +1,93 @@
<?php

/*
* This file is part of the package buepro/pizpalue.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

/*
* This file has been copied from the bootstrap_packeage V9
*/
namespace Buepro\Pizpalue\DataProcessing;

use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;

/**
* Minimal TypoScript configuration
* Assign all available typoscript constants for a key to template view, the
* default key that is used is `page` and the default variable is `constants`.
*
* 10 = Buepro\Pizpalue\DataProcessing\ConstantsProcessor
*
*
* Advanced TypoScript configuration
*
* 10 = Buepro\Pizpalue\DataProcessing\ConstantsProcessor
* 10 {
* key = page
* as = constants
* }
*/
class ConstantsProcessor implements DataProcessorInterface
{
/**
* @param ContentObjectRenderer $cObj The data of the content element or page
* @param array $contentObjectConfiguration The configuration of Content Object
* @param array $processorConfiguration The configuration of this processor
* @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View)
* @return array the processed data as key/value store
*/
public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
{
// The key to process
$key = $cObj->stdWrapValue('key', $processorConfiguration);
if (empty($key)) {
$key = 'page';
}

// Collect variables
$flatConstants = $this->getFlatConstants($key);
$typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class);
$typoScriptParser->parse($flatConstants);
$typoScriptArray = $typoScriptParser->setup;
$typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
$constants = $typoScriptService->convertTypoScriptArrayToPlainArray($typoScriptArray);

// Set the target variable
$targetVariableName = $cObj->stdWrapValue('as', $processorConfiguration);
if (!empty($targetVariableName)) {
$processedData[$targetVariableName] = $constants;
} else {
$processedData['constants'] = $constants;
}

return $processedData;
}

/**
* @param string $key
* @return array
*/
public function getFlatConstants($key)
{
$flatvariables = '';
$prefix = $key . '.';
if (!isset($GLOBALS['TSFE']->tmpl->flatSetup)
|| !is_array($GLOBALS['TSFE']->tmpl->flatSetup)
|| count($GLOBALS['TSFE']->tmpl->flatSetup) === 0) {
$GLOBALS['TSFE']->tmpl->generateConfig();
}
foreach ($GLOBALS['TSFE']->tmpl->flatSetup as $constant => $value) {
if (strpos($constant, $prefix) === 0) {
$flatvariables .= substr($constant, strlen($prefix)) . ' = ' . $value . PHP_EOL;
}
}
return $flatvariables;
}
}
13 changes: 12 additions & 1 deletion Configuration/TypoScript/Main/ConstantsBsp.txt
Expand Up @@ -87,6 +87,18 @@ plugin.bootstrap_package.settings.less {
# cat=pizpalue: customer style/1034/1080; type=string; label=Default link disabled background
navbar-default-link-disabled-bg = transparent

# cat=pizpalue: customer style/1080/1010; type=string; label= Cookie consent panel z-index
cookieconsent-zindex = 1080

# cat=pizpalue: customer style/1080/1020; type=string; label= Cookie consent panel background
cookieconsent-bg = @gray-darker

# cat=pizpalue: customer style/1080/1030; type=string; label= Cookie consent panel color
cookieconsent-color = contrast(@cookieconsent-bg, black, white, 43%)

# cat=pizpalue: customer style/1080/1030; type=string; label= Cookie consent panel link color
cookieconsent-link-color = @brand-primary

# cat=pizpalue: customer style/1039/1110; type=string; label=Register tabs bar background color
pp-tab-v1-background = @gray-lighter

Expand All @@ -96,7 +108,6 @@ plugin.bootstrap_package.settings.less {
# cat=pizpalue: customer style/1039/1130; type=string; label=Register border color
pp-tab-v1-border-color = #ddd


pp-tab-v1-background-hover = mix(@pp-tab-v1-background,@pp-tab-v1-active-background)
nav-tabs-active-link-hover-color = contrast(@pp-tab-v1-background)
nav-tabs-active-link-hover-bg = @pp-tab-v1-active-background
Expand Down
Empty file.
21 changes: 21 additions & 0 deletions Configuration/TypoScript/Main/ConstantsCustomer.txt
Expand Up @@ -100,6 +100,27 @@ page.theme {
}


# ---------------------------------------------------------- #
# cookie consent
# ---------------------------------------------------------- #

page.theme.cookieconsent {
# cat=pizpalue: customer/1080/0110; type=boolean; label=Enable Cookie Consent: For more information about this solution please head over to https://cookieconsent.insites.com/
enable = 1

# cat=pizpalue: customer/1080/1010; type=options[Basic=basic, Basic Close=basic-close, Basic Header=basic-header]; label=Layout
layout = basic

# cat=pizpalue: customer/1080/1020; type=options[Banner Top=top, Banner Bottom=bottom, Floating Top Left=top-left, Floating Top Right=top-right, Floating Bottom Left=bottom-left, Floating Bottom Right=bottom-right]; label=Position: Position is used to describe where on the screen your popup should display. We also use 'position' to assume the shape of your popup. If you specify 'top' or 'bottom', we assume that a full width 'banner' is required. If however you specify a horizontal direction, we assume that a corner popup is required (which we call 'floating').
position = bottom-left

content {
# cat=pizpalue: customer/1080/1040; type=string; label=Privacy Police: Insert a full Link to the privacy police page or a page uid from your current TYPO3 System.
href =
}
}


# ---------------------------------------------------------- #
# appicons
# ---------------------------------------------------------- #
Expand Down
28 changes: 28 additions & 0 deletions Configuration/TypoScript/Main/ConstantsCustomerVarious.txt
Expand Up @@ -52,6 +52,34 @@ page.theme {
}


# ---------------------------------------------------------- #
# cookie consent
# ---------------------------------------------------------- #

page.theme {
cookieconsent {
# cat=pizpalue: customer various/1080/1230; type=boolean; label=Static Position: The popup uses position fixed to stay in one place on the screen despite any scroll bars. This option makes the popup position static so it displays at the top of the page. A height animation has also been added by default so the popup doesn’t make the page jump, but gradually grows and fades in.
static = 0
# cat=pizpalue: customer various/1080/1250; type=boolean; label=Revokable: If set true, revoke button is displayed every time. If false, revoke button is only displayed for advanced compliance options (opt-in and opt-out) and in countries that require revokable consent. The latter can be disabled by regionalLaw.
revokable = 0
# cat=pizpalue: customer various/1080/1260; type=boolean; label=Location Detection: Location is simply a tool for getting the two letter country code that the user is in.
location = 0
law {
# cat=pizpalue: customer various/1280/1070; type=string; label=Country Code: Rather than getting the country code from the location services, you can hard code a particular country into the tool.
countryCode =
# cat=pizpalue: customer various/1280/1080; type=boolean; label=Regional Law: If false, then we only enable the popup if the country has the cookie law. We ignore all other country specific rules.
regionalLaw = 1
}
# cat=pizpalue: customer various/1080/1290; type=options[Informal=info, Opt-In=opt-in, Opt-Out=opt-out]; label=Compliance: The informal confirmation does not require any further adjustments to your JavaScript. The Opt-In and Opt-Out options are not out-of-the-box solutions, manual adjustments to your software are necessary. For your support we provide the events bk2k.cookie.enable, bk2k.cookie.disable and bk2k.cookie.revoke. These events allow you to let your application react to them and to set or remove cookies accordingly. The cookie that contains the current status is called cookieconsent_status.
type = info
cookie {
# cat=pizpalue: customer various/1080/1300; type=int; label=Expiry Days: The cookies expire date, specified in days (specify -1 for no expiry)
expiryDays = 365
}
}
}


# ---------------------------------------------------------- #
# appicons
# ---------------------------------------------------------- #
Expand Down
12 changes: 7 additions & 5 deletions Configuration/TypoScript/Main/constants.txt
Expand Up @@ -6,18 +6,20 @@
# customsubcategory=1020=Customer
# customsubcategory=1030=Frame
# customsubcategory=1032=Style
# customsubcategory=1033=Style font
# customsubcategory=1034=Style header
# customsubcategory=1035=Style footer
# customsubcategory=1039=Style various
# customsubcategory=1033=Font
# customsubcategory=1034=Header
# customsubcategory=1035=Footer
# customsubcategory=1039=Various
# customsubcategory=1040=Logo
# customsubcategory=1060=Menu
# customsubcategory=1080=Cookie consent
# customsubcategory=1110=Appicon
# customsubcategory=1210=Storage
# customsubcategory=1410=SEO
# customsubcategory=1510=Features


<INCLUDE_TYPOSCRIPT: source="FILE:EXT:pizpalue/Extensions/bootstrap_package/Configuration/TypoScript/constants.txt">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:pizpalue/Configuration/TypoScript/Main/ConstantsBsp.txt">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:pizpalue/Configuration/TypoScript/Main/ConstantsGeneral.txt">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:pizpalue/Configuration/TypoScript/Main/ConstantsAgency.txt">
Expand Down Expand Up @@ -55,7 +57,7 @@ plugin {
# ---------------------------------------------------------- #
page {
fluidtemplate {
#layoutRootPath = EXT:pizpalue/Resources/Private/Layouts/Page/
layoutRootPath = EXT:pizpalue/Resources/Private/Layouts/Page/
partialRootPath = EXT:pizpalue/Resources/Private/Partials/Page/
templateRootPath = EXT:pizpalue/Resources/Private/Templates/Page/
}
Expand Down
22 changes: 19 additions & 3 deletions Configuration/TypoScript/Main/setup.txt
Expand Up @@ -18,9 +18,9 @@ config {
// Branding
headerComment (

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Eine Webseite von buechler.pro
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Eine Webseite basierend der Distribution pizpalue von buechler.pro
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

)

Expand Down Expand Up @@ -66,6 +66,10 @@ page.meta.google-site-verification = {$pizpalue.seo.google.siteVerification}
#=============#
# page object #
#=============#

#---------#
# general #
#---------#
page {
shortcutIcon >

Expand Down Expand Up @@ -101,11 +105,18 @@ page {
}


#----------#
# language #
#----------#
[globalString = LIT:1 = {$pizpalue.menu.language.enable}]
# href link tag for search engines
page.headerData.110 < lib.pizpalue.hrefLinkTag
[global]


#-------------------#
# style definitions #
#-------------------#
[globalString = LIT:1 = {$pizpalue.features.useStyle}]
page {
includeCSS {
Expand All @@ -118,6 +129,10 @@ page {
}
[global]


#----------------------------------#
# content element scroll animation #
#----------------------------------#
[globalString = LIT:1 = {$pizpalue.features.useCeScrollAnimation}]
page {
includeCSS {
Expand All @@ -131,6 +146,7 @@ page {
}
[global]


#==============#
# localization #
#==============#
Expand Down
14 changes: 14 additions & 0 deletions Documentation/Configuration/Index.rst
Expand Up @@ -41,3 +41,17 @@ Parameter Value
[FE][pageNotFound_handling] REDIRECT:https://www.pizpalue.buechler.pro/404/
[FE][pageNotFound_handling_statheader] HTTP/1.0 404 Not Found
========================================== ===================================================

.. _cookieconsent:

Cookie consent
--------------

To show a cookie dialog the "Enable Cookie Consent"-parameter has to be set (available through the constant editor
under "PIZPALUE: CUSTOMER"). As well a link to a privacy policy page can be set in the cookie dialog.

Further configurations regarding the cookie dialog can be found und "PIZPALUE: CUSTOMER VARIOUS" in the constant editor.

.. _info
For Google Analytics a control block can be embedded by using the string ###GoogleAnalyticsStatus### in a content
element.
@@ -0,0 +1,54 @@
######################
### TEMPLATE BLOCK ###
######################
#
# TypoScript Example:
# ---------------
#
# 10 < lib.block
# 10.templateName = MyBlock
#
#
# Fluid Example:
# ---------------
#
# <f:cObject typoscriptObjectPath="lib.block" data="{template: 'MyBlock'}" />
#
######################
lib.block = FLUIDTEMPLATE
lib.block {

################
### TEMPLATE ###
################
templateName = Default
templateName {
override {
field = template
}
}
templateRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Templates/Blocks/
10 = {$plugin.bootstrap_package_blocks.view.templateRootPath}
}
partialRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Partials/Blocks/
10 = {$plugin.bootstrap_package_blocks.view.partialRootPath}
}
layoutRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Layouts/Blocks/
10 = {$plugin.bootstrap_package_blocks.view.layoutRootPath}
}

##########################
### DATA PREPROCESSING ###
##########################
dataProcessing {
1 = Buepro\Pizpalue\DataProcessing\ConstantsProcessor
1 {
as = theme
key = page.theme
}
}

}

0 comments on commit 02acde3

Please sign in to comment.