Added Matomo support.
This commit is contained in:
parent
373a2e4cce
commit
0e885f6311
4 changed files with 62 additions and 36 deletions
|
@ -259,6 +259,14 @@ if(!empty($userDisplayInfo))
|
|||
if(!empty($userInfo))
|
||||
Template::set('current_user2', $userInfo);
|
||||
|
||||
if(Config::has('matomo.endpoint') && Config::has('matomo.javascript') && Config::has('matomo.site')) {
|
||||
Template::set([
|
||||
'matomo_endpoint' => Config::get('matomo.endpoint', Config::TYPE_STR),
|
||||
'matomo_js' => Config::get('matomo.javascript', Config::TYPE_STR),
|
||||
'matomo_site' => Config::get('matomo.site', Config::TYPE_STR),
|
||||
]);
|
||||
}
|
||||
|
||||
$inManageMode = starts_with($_SERVER['REQUEST_URI'], '/manage');
|
||||
$hasManageAccess = User::hasCurrent()
|
||||
&& !User::getCurrent()->hasActiveWarning()
|
||||
|
|
|
@ -43,6 +43,10 @@ final class Config {
|
|||
return $value ?? $default ?? self::DEFAULTS[$type];
|
||||
}
|
||||
|
||||
public static function has(string $key): bool {
|
||||
return array_key_exists($key, self::$config);
|
||||
}
|
||||
|
||||
public static function set(string $key, $value, bool $soft = false): void {
|
||||
self::$config[$key] = $value;
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ final class Template {
|
|||
echo self::renderRaw($file, $vars);
|
||||
}
|
||||
|
||||
/// DEPRECATED: Will be removed in the future, use the $vars param for render and renderRaw instead.
|
||||
public static function set($arrayOrKey, $value = null): void {
|
||||
if(is_string($arrayOrKey)) {
|
||||
self::$vars[$arrayOrKey] = $value;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
</style>
|
||||
{% endif %}
|
||||
</head>
|
||||
|
||||
<body class="main{% if site_background is defined %} {{ site_background.classNames('main--bg-%s')|join(' ') }}{% endif %}"
|
||||
style="{% if global_accent_colour is defined %}{{ global_accent_colour|html_colour('--accent-colour') }}{% endif %}" id="container">
|
||||
{% include '_layout/header.twig' %}
|
||||
|
@ -59,6 +58,22 @@
|
|||
<script type="text/javascript">
|
||||
window.addEventListener('DOMContentLoaded', function() { Misuzu(); });
|
||||
</script>
|
||||
{% if matomo_endpoint is defined and matomo_js is defined and matomo_site is defined %}
|
||||
<script type="text/javascript">
|
||||
var _paq = window._paq || [];
|
||||
_paq.push(['disableCookies']);
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
_paq.push(['setTrackerUrl', '{{ matomo_endpoint }}']);
|
||||
_paq.push(['setSiteId', '{{ matomo_site }}']);
|
||||
var g = document.createElement('script');
|
||||
g.type = 'text/javascript'; g.async = true;
|
||||
g.defer = true; g.src = '{{ matomo_js }}';
|
||||
document.head.appendChild(g);
|
||||
})();
|
||||
</script>
|
||||
{% endif %}
|
||||
<script src="/vendor/timeago/timeago.min.js" type="text/javascript"></script>
|
||||
<script src="/vendor/timeago/timeago.locales.min.js" type="text/javascript"></script>
|
||||
<script src="/vendor/highlightjs/highlight.pack.js" type="text/javascript"></script>
|
||||
|
|
Loading…
Add table
Reference in a new issue