-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextformatterMatomoWire.module
57 lines (49 loc) · 2.18 KB
/
TextformatterMatomoWire.module
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
<?php namespace ProcessWire;
/**
* Textformatter MatomoWire
* This module adds the textformatter for MatomoWire Opt-Out iFrame
*
*
* @author blaueQuelle
*
* ProcessWire 3.x
* Copyright (C) 2011 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
* http://www.processwire.com
* http://www.ryancramer.com
*
*/
class TextformatterMatomoWire extends Textformatter implements Module
{
public static function getModuleInfo()
{
return [
'title' => 'MatomoWire Textformatter',
'summary' => "MatomoWire Textformatter to render matomo opt-out iframe via shortcode [[matomowire-opt-out]]",
'author' => 'blaueQuelle',
'href' => "https://github.com/blaueQuelle/matomowire",
'version' => 1,
'requires' => [
"PHP>=7.2",
"ProcessWire>=3.0.110"
],
];
}
public function formatValue(Page $page, Field $field, &$str)
{
$matomoWire = $this->modules->get("MatomoWire");
if ($matomoWire->integrate_privacywire == true && $matomoWire->opt_out_type == "privacywire" && $this->wire('modules')->isInstalled('PrivacyWire') && $this->wire('modules')->get('PrivacyWire')) {
$privacyWire = $this->modules->get("PrivacyWire");
// Multi Language Support
$lang = ($this->wire('languages') && !$this->wire('user')->language->isDefault()) ? '__' . $this->wire('user')->language->id : '';
$content = "<button class='button privacywire-show-options'>{$privacyWire->get("textformatter_choose_label$lang|textformatter_choose_label")}</button>";
} else {
$matomo_url = rtrim($this->wire('sanitizer')->url($matomoWire->matomo_url), '/') . '/';
$content = "<div class='matomowire-iframe'><iframe loading='lazy' style='border: 0; height: 200px; width: 600px;' src='" . $matomo_url . "index.php?module=CoreAdminHome&action=optOut&language=de&fontFamily=sans-serif'></iframe></div>"; // TODO: Adjust iFrame Params
}
$tag_search = $this->open_tag . $this->tag_name . $this->close_tag;
$tag_replace = $content;
$str = str_replace($tag_search, $tag_replace, $str);
}
}