1<?php
2/**
3 * GeoNav Action Plugin
4 *
5 *
6 *
7 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
8 * @author     Tom Cafferty <tcafferty@glocalfocal.com>
9 */
10
11// must be run within Dokuwiki
12if(!defined('DOKU_INC')) define('DOKU_INC',(dirname(__FILE__).'/../../').'/');
13if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
14require_once DOKU_PLUGIN.'action.php';
15require_once (DOKU_INC.'inc/parserutils.php');
16
17class action_plugin_geonav extends DokuWiki_Action_Plugin {
18
19    /**
20     * Register its handlers with the DokuWiki's event controller
21     */
22    function register(&$controller) {
23        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'geonav_hookjs');
24    }
25
26    /**
27     * Hook js script into page headers.
28     *
29     * @author Tom Cafferty <tcafferty@glocalfocal.com>
30     */
31    function geonav_hookjs(&$event, $param) {
32        global $INFO;
33        global $ID;
34        global $conf;
35        $basePath = DOKU_BASE;
36        $basePath = str_replace("dokuwiki/", "", $basePath);
37        $sidebar_ID = "sidebar";
38       if (p_get_metadata($sidebar_ID, 'plugin geonav')) {
39            $event->data['script'][] = array(
40                            'type'    => 'text/javascript',
41                            'charset' => 'utf-8',
42                            '_data'   => '',
43                            'src'     => "http://www.google.com/jsapi");
44            $event->data['script'][] = array(
45                            'type'    => 'text/javascript',
46                            'charset' => 'utf-8',
47                            '_data'   => '',
48                            'src'     => $basePath ."lib/plugins/geonav/js/earth_a.js");
49            $event->data['script'][] = array(
50                            'type'    => 'text/javascript',
51                            'charset' => 'utf-8',
52                            '_data'   => '',
53                            'src'     => $basePath ."lib/plugins/geonav/js/getLocation.js");
54       }
55    }
56}