1<?php
2/**
3 @file       clacks/action.php
4 @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
5 @author     Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
6 @version    2018-11-12
7**/
8// must be run within Dokuwiki
9if(!defined('DOKU_INC')) die();
10if(!defined('DW_LF')) define('DW_LF',"\n");
11
12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13define('THIS_PLUGIN', DOKU_PLUGIN.'noiewarning/');
14require_once(DOKU_PLUGIN.'action.php');
15require_once(DOKU_INC.'inc/confutils.php');
16require_once(DOKU_INC.'inc/infoutils.php'); // for notify facilities
17
18/**
19 * All DokuWiki plugins to extend the admin function
20 * need to inherit from this class
21 */
22class action_plugin_clacks extends DokuWiki_Action_Plugin {
23
24	var $oh;
25
26    function action_plugin_clacks () {
27        $this->oh = $this->getConf('overhead');
28        $arr = explode('\n', $this->oh);
29        $this->oh= $arr[0];
30        // load options from configuration
31    }
32
33    /***
34     * Register its handlers with the DokuWiki's event controller
35     */
36    function register(Doku_Event_Handler $controller) {
37        global $ACT;
38        global $conf;
39        if ($ACT != 'show') return;
40        $controller->register_hook(
41			'ACTION_HEADERS_SEND','BEFORE', $this, 'GNU', array()
42		);
43/*
44		if ($this->getConf('alsometa')!=='') {
45			$controller->register_hook(
46				'TPL_METAHEADER_OUTPUT','BEFORE', $this, 'GNU_Meta', array()
47			);
48		}
49*/
50    }
51
52
53    function GNU (Doku_Event $event, $param) {
54        @file_put_contents('/tmp/oh.txt', $this->oh);
55        $event->data[] = "X-Clacks-Overhead: GNU {$this->oh}";
56    // end function
57    }
58
59    function GNU_Meta (Doku_Event $event, $param) {
60        $pre = 'X-Clacks-Overhead';
61        $event->data['meta'][] = array( 'http-equiv' => 'X-Clacks-Overhead'
62			, 'content' => 'GNU '. $this->oh
63			);
64    // end function
65    }
66
67
68
69
70}
71