1<?php
2/**
3 * DokuWiki Plugin cookielaw (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Michal Koutny <michal@fykos.cz>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12class action_plugin_cookielaw extends DokuWiki_Action_Plugin {
13
14    /**
15     * Registers a callback function for a given event
16     *
17     * @param Doku_Event_Handler $controller DokuWiki's event controller object
18     * @return void
19     */
20    public function register(Doku_Event_Handler $controller) {
21
22       $controller->register_hook('TPL_ACT_RENDER', 'AFTER', $this, 'handle_tpl_act_render');
23
24    }
25
26    /**
27     * [Custom event handler which performs action]
28     *
29     * @param Doku_Event $event  event object by reference
30     * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
31     *                           handler was registered]
32     * @return void
33     */
34
35    public function handle_tpl_act_render(Doku_Event &$event, $param) {
36        if ($event->data != 'show') {
37            return;
38        }
39
40        if (isset($_COOKIE['cookielaw'])) {
41            return;
42        }
43
44        $position = $this->getConf('position');
45
46        echo '<div class="cookielaw-banner cookielaw-' . $position . '">';
47        echo hsc($this->getLang('information'));
48        echo '<button>' . hsc($this->getLang('consent')) . '</button>';
49        echo '<a href="' . hsc($this->getLang('details_url')) . '" target="_blank">' . hsc($this->getLang('details')) . '</a>';
50        echo '</div>';
51    }
52
53}
54
55// vim:ts=4:sw=4:et:
56