-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.php
116 lines (114 loc) · 4.01 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
<?php
require_once __DIR__ . '/lib/matomo.php';
Kirby::plugin('sylvainjule/matomo', array(
'areas' => require_once __DIR__ . '/lib/area.php',
'options' => array(
'token' => false,
'url' => false,
'id' => false,
'active' => true,
'debug' => false,
'blacklist' => ['127.0.0.1', '::1'],
'trackUsers' => false,
'area' => true,
'area.label' => 'Matomo',
'area.headline' => null,
),
'snippets' => array(
'matomo' => __DIR__ . '/lib/snippets/matomo.php'
),
'sections' => array(
'matomo-main' => array(
'props' => array(
'chart' => function($chart = true) {
return $chart;
},
'overview' => function($overview = true) {
return $overview;
},
'periods' => function($periods = ['year', 'month', 'week', 'day']) {
return $periods;
},
'widgets' => function($widgets = ['referrerType', 'websites', 'socials', 'devicesType', 'keywords', 'popularPages']) {
return $widgets;
},
'defaults' => function($defaults = ['period' => 'month', 'limit' => 5]) {
return $defaults;
},
),
'computed' => array(
'lang' => function() {
return kirby()->user()->language();
}
)
),
'matomo-sidebar' => array(
'props' => array(
'link' => function($link = true) {
return $link;
},
'realtime' => function($realtime = true) {
return $realtime;
},
'summary' => function($summary = true) {
return $summary;
},
),
'computed' => array(
'url' => function() {
return option('sylvainjule.matomo.url');
}
)
),
'matomo-page' => array(
'props' => array(
'overview' => function($overview = false) {
return $overview;
},
'period' => function($period = 'month') {
return $period;
},
),
'computed' => array(
'uri' => function() {
if(kirby()->multilang()) {
$uris = [];
foreach(kirby()->languages() as $language) {
$code = $language->code();
// re-create the uri from the public url
$currentUrl = $this->model()->url($code); // get the page url
$currentUri = str_replace(site()->url(), '', $currentUrl); // substract the site url to get the uri
$currentUri = '/' . ltrim($currentUri, '/'); // make sure it starts by a single forward slash
$uris[$code] = $currentUri;
}
return $uris;
}
else {
// re-create the uri from the public url
$currentUrl = $this->model()->url(); // get the page url
$currentUri = str_replace(site()->url(), '', $currentUrl); // substract the site url to get the uri
$currentUri = '/' . ltrim($currentUri, '/'); // make sure it starts by a single forward slash
return $currentUri;
}
},
'lang' => function() {
return array(
'multilang' => kirby()->multilang(),
'default' => kirby()->defaultLanguage() ? kirby()->defaultLanguage()->code() : false,
'current' => kirby()->languageCode() ?? false,
'overview' => $this->overview
);
}
)
)
),
'translations' => array(
'en' => require_once __DIR__ . '/lib/languages/en.php',
'de' => require_once __DIR__ . '/lib/languages/de.php',
'fr' => require_once __DIR__ . '/lib/languages/fr.php',
'es' => require_once __DIR__ . '/lib/languages/es.php',
),
'api' => array(
'routes' => require_once __DIR__ . '/lib/routes.php',
),
));