... | ... |
@@ -14,16 +14,81 @@ class TemplateListener |
14 | 14 |
{ |
15 | 15 |
public function onOutputFrontendTemplate($strBuffer) |
16 | 16 |
{ |
17 |
- $Template = new \FrontendTemplate('cookieconsent'); |
|
18 |
- |
|
19 |
- if (strpos($strBuffer,'<head>')) |
|
17 |
+ if (($rootPage = \PageModel::findByPk($GLOBALS['objPage']->rootId)) !== null && $rootPage->cookieconsent_enable) |
|
20 | 18 |
{ |
21 |
- $strInject = '<script src="system/modules/eSM_cookieconsent/assets/js/lib/cookieconsent.min.js"></script>'; |
|
19 |
+ $arrServices = deserialize($rootPage->cookieconsent_services); |
|
20 |
+ |
|
21 |
+ $arrServiceConfiguration = array(); |
|
22 |
+ |
|
23 |
+ if (in_array('analytics',$arrServices)) |
|
24 |
+ { |
|
25 |
+ $arrServiceConfiguration[] = array |
|
26 |
+ ( |
|
27 |
+ 'analytics' => array |
|
28 |
+ ( |
|
29 |
+ 'category' => 'statistics', |
|
30 |
+ 'type' => 'dynamic-script', |
|
31 |
+ 'search' => 'analytics', |
|
32 |
+ 'language' => array |
|
33 |
+ ( |
|
34 |
+ 'locale' => array |
|
35 |
+ ( |
|
36 |
+ 'de' => array |
|
37 |
+ ( |
|
38 |
+ 'name' => 'Google Analytics', |
|
39 |
+ ), |
|
40 |
+ 'en' => array |
|
41 |
+ ( |
|
42 |
+ 'name' => 'Google Analytics', |
|
43 |
+ ), |
|
44 |
+ ), |
|
45 |
+ ), |
|
46 |
+ ), |
|
47 |
+ ); |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+ if (in_array('matomo',$arrServices)) |
|
51 |
+ { |
|
52 |
+ $arrServiceConfiguration[] = array |
|
53 |
+ ( |
|
54 |
+ 'piwik' => array |
|
55 |
+ ( |
|
56 |
+ 'category' => 'statistics', |
|
57 |
+ 'type' => 'dynamic-script', |
|
58 |
+ 'search' => 'piwik', |
|
59 |
+ 'language' => array |
|
60 |
+ ( |
|
61 |
+ 'locale' => array |
|
62 |
+ ( |
|
63 |
+ 'de' => array |
|
64 |
+ ( |
|
65 |
+ 'name' => 'Piwik', |
|
66 |
+ ), |
|
67 |
+ 'en' => array |
|
68 |
+ ( |
|
69 |
+ 'name' => 'Piwik', |
|
70 |
+ ), |
|
71 |
+ ), |
|
72 |
+ ), |
|
73 |
+ ), |
|
74 |
+ ); |
|
75 |
+ } |
|
22 | 76 |
|
23 |
- $strInject .= $Template->parse(); |
|
77 |
+ $Template = new \FrontendTemplate('cookieconsent'); |
|
24 | 78 |
|
25 |
- $strBuffer = str_replace('<head>','<head>' . $strInject,$strBuffer); |
|
79 |
+ $Template->privacy_policy_link = $rootPage->cookieconsent_link != '' ? "'".$rootPage->cookieconsent_link."'" : "null"; |
|
80 |
+ $Template->services = json_encode($arrServiceConfiguration); |
|
81 |
+ |
|
82 |
+ if (strpos($strBuffer, '<head>')) |
|
83 |
+ { |
|
84 |
+ $strInject = '<script src="system/modules/eSM_cookieconsent/assets/js/lib/cookieconsent.min.js"></script>'; |
|
85 |
+ |
|
86 |
+ $strInject .= $Template->parse(); |
|
87 |
+ |
|
88 |
+ $strBuffer = str_replace('<head>', '<head>' . $strInject, $strBuffer); |
|
89 |
+ } |
|
26 | 90 |
} |
91 |
+ |
|
27 | 92 |
return $strBuffer; |
28 | 93 |
} |
29 | 94 |
} |
30 | 95 |
\ No newline at end of file |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
<script> |
2 | 2 |
window.CookieConsent.init({ |
3 | 3 |
// More link URL on bar |
4 |
- modalMainTextMoreLink: null, |
|
4 |
+ modalMainTextMoreLink: <?= $this->privacy_policy_link ?>, |
|
5 | 5 |
// How lond to wait until bar comes up |
6 | 6 |
barTimeout: 1000, |
7 | 7 |
// Look and feel |
... | ... |
@@ -98,30 +98,7 @@ |
98 | 98 |
}, |
99 | 99 |
// List actual services here |
100 | 100 |
services: { |
101 |
- // Unique name |
|
102 |
- analytics: { |
|
103 |
- // Existing category Unique name |
|
104 |
- // This example shows how to block Google Analytics |
|
105 |
- category: 'statistics', |
|
106 |
- // Type of blocking to apply here. |
|
107 |
- // This depends on the type of script we are trying to block |
|
108 |
- // Can be: dynamic-script, script-tag, wrapped, localcookie |
|
109 |
- type: 'dynamic-script', |
|
110 |
- // Only needed if "type: dynamic-script" |
|
111 |
- // The filter will look for this keyword in inserted scipt tags |
|
112 |
- // and block if match found |
|
113 |
- search: 'analytics', |
|
114 |
- language: { |
|
115 |
- locale: { |
|
116 |
- de: { |
|
117 |
- name: 'Google Analytics' |
|
118 |
- }, |
|
119 |
- en: { |
|
120 |
- name: 'Google Analytics' |
|
121 |
- } |
|
122 |
- } |
|
123 |
- } |
|
124 |
- } |
|
101 |
+ <?= $this->services ?> |
|
125 | 102 |
} |
126 | 103 |
}); |
127 | 104 |
</script> |
128 | 105 |
\ No newline at end of file |