1<?php
2/**
3 * DokuWiki Action Plugin OrgChart
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Anika Henke <anika@selfthinker.org>
7 */
8// must be run within Dokuwiki
9if(!defined('DOKU_INC')) die();
10
11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
12if(!defined('DOKU_LF')) define('DOKU_LF', "\n");
13
14require_once(DOKU_PLUGIN.'action.php');
15
16/**
17 * All DokuWiki plugins to interfere with the event system
18 * need to inherit from this class
19 */
20class action_plugin_orgchart extends DokuWiki_Action_Plugin {
21
22    // register hook
23    function register(Doku_Event_Handler $controller) {
24        $controller->register_hook('TPL_METAHEADER_OUTPUT','BEFORE', $this, '_addJavascript');
25    }
26
27    /**
28     * Add JavaScript for Google's Org Chart
29     *
30     * @param unknown_type $event
31     * @param unknown_type $param
32     */
33    function _addJavascript(&$event, $param) {
34        $event->data['script'][] = array(
35            'charset' => 'utf-8',
36            '_data'   => '',
37            'src'     => 'https://www.google.com/jsapi'
38        );
39        $event->data['script'][] = array(
40            'charset' => 'utf-8',
41            '_data'   => 'google.load("visualization", "1", {packages:["orgchart"]});'
42        );
43    }
44
45}
46
47// vim:ts=4:sw=4:
48