1<?php
2/**
3 * DokuWiki plugin for Piwik
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Heikki Hokkanen <hoxu@users.sf.net>
7 */
8
9if(!defined('DOKU_INC')) die();
10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once DOKU_PLUGIN.'action.php';
12require_once DOKU_PLUGIN.'piwik/code.php';
13
14class action_plugin_piwik extends DokuWiki_Action_Plugin {
15	function register(&$controller) {
16		$controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, '_hook_header');
17	}
18
19	function _hook_header(&$event, $param) {
20		$data = piwik_code_new();
21		$event->data['script'][] = array(
22			'type' => 'text/javascript',
23			'charset' => 'utf-8',
24			'_data' => $data,
25		);
26	}
27}
28