This repository has been archived by the owner on Jan 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
118 lines (98 loc) · 4.51 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
use Pagekit\Application as App;
return [
'name' => 'spqr/cookiewarning',
'type' => 'extension',
'main' => function ($app) {
},
'autoload' => [
],
'nodes' => [],
'routes' => [],
'menu' => [],
'permissions' => [],
'settings' => 'cookiewarning-settings',
'resources' => [
'spqr/cookiewarning:' => '',
],
'config' => [
'url' => '',
'position' => 'bottom',
'theme' => 'classic',
'message' => '',
'dismissbuttontext' => '',
'policytext' => '',
'popup' => [
'textcolour' => '#404040',
'backgroundcolour' => '#efefef',
],
'button' => [
'textcolour' => '#ffffff',
'backgroundcolour' => '#8ec760',
],
],
'events' => [
'site' => function ($event, $app) {
$app->on('view.content', function ($event, $test) use ($app) {
$module = App::module('spqr/cookiewarning');
$config = $module->config;
$position = (!empty($config['position']) ? $config['position']
: 'bottom');
$theme = (!empty($config['theme']) ? $config['theme']
: 'classic');
$url = (!empty($config['url']) ? App::url($config['url'])
: '#');
$message = (!empty($config['message']) ? $config['message']
: __('This website uses cookies. This ensures that the website is working correctly for your best experience on this website.'));
$dismiss = (!empty($config['dismissbuttontext'])
? $config['dismissbuttontext'] : __('Dismiss'));
$policytext = (!empty($config['policytext'])
? $config['policytext'] : __('Learn more'));
$buttontextcolour
= (!empty($config['button']['textcolour'])
? $config['button']['textcolour'] : '#ffffff');
$buttonbackgroundcolour
= (!empty($config['button']['backgroundcolour'])
? $config['button']['backgroundcolour'] : '#8ec760');
$popuptextcolour
= (!empty($config['popup']['textcolour'])
? $config['popup']['textcolour'] : '#404040');
$popupbackgroundcolour
= (!empty($config['popup']['backgroundcolour'])
? $config['popup']['backgroundcolour'] : '#efefef');
$script
= "window.addEventListener('load', function(){
window.cookieconsent.initialise({
'palette': {
'popup': {
'background': '$popupbackgroundcolour',
'text': '$popuptextcolour'
},
'button': {
'background': '$buttonbackgroundcolour',
'text': '$buttontextcolour'
}
},
'theme': '$theme',
'position': '$position',
'content': {
'message': '$message',
'dismiss': '$dismiss',
'link': '$policytext',
'href': '$url'
}
})});";
$app['styles']->add('cookieconsent',
'spqr/cookiewarning:app/assets/cookieconsent/cookieconsent.min.css');
$app['scripts']->add('cookieconsent',
'spqr/cookiewarning:app/assets/cookieconsent/cookieconsent.min.js');
$app['scripts']->add('cookiewarning', $script, [], 'string');
});
},
'view.scripts' => function ($event, $scripts) use ($app) {
$scripts->register('cookiewarning-settings',
'spqr/cookiewarning:app/bundle/cookiewarning-settings.js',
['~extensions', 'input-link', 'vue']);
},
],
];