forked from fykosak/dokuwiki-plugin-cookielaw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
50 lines (42 loc) · 1.42 KB
/
action.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
<?php
use dokuwiki\Extension\ActionPlugin;
use dokuwiki\Extension\Event;
use dokuwiki\Extension\EventHandler;
if (!defined('DOKU_INC')) die();
/**
* DokuWiki Plugin cookielaw (Action Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Michal Koutny <[email protected]>
*/
class action_plugin_cookielaw extends ActionPlugin {
/**
* Registers a callback function for a given event
*
* @param EventHandler $controller DokuWiki's event controller object
* @return void
*/
public function register(EventHandler $controller): void {
$controller->register_hook('TPL_ACT_RENDER', 'AFTER', $this, 'handle_tpl_act_render');
}
/**
* [Custom event handler which performs action]
*
* @param Event $event event object by reference
* @return void
*/
public function handle_tpl_act_render(Event $event): void {
if ($event->data != 'show') {
return;
}
if (isset($_COOKIE['cookielaw'])) {
return;
}
$position = $this->getConf('position');
echo '<div class="cookielaw-banner cookielaw-' . $position . '">';
echo hsc($this->getLang('information'));
echo '<button>' . hsc($this->getLang('consent')) . '</button>';
echo '<a href="' . hsc($this->getLang('details_url')) . '" target="_blank">' . hsc($this->getLang('details')) . '</a>';
echo '</div>';
}
}