1 | <?php |
||
2 | /* |
||
3 | * Copyright (c) 2008-2016 Mark C. Prins <[email protected]> |
||
4 | * |
||
5 | * Permission to use, copy, modify, and distribute this software for any |
||
6 | * purpose with or without fee is hereby granted, provided that the above |
||
7 | * copyright notice and this permission notice appear in all copies. |
||
8 | * |
||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||
16 | */ |
||
17 | |||
18 | if (!defined('DOKU_INC')) die(); |
||
19 | if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); |
||
20 | require_once (DOKU_PLUGIN . 'action.php'); |
||
21 | /** |
||
22 | * Plugin OL Maps: Allow Display of a OpenLayers Map in a wiki page. |
||
23 | * Toolbar button. |
||
24 | * @author Mark Prins |
||
25 | */ |
||
26 | class action_plugin_openlayersmap extends DokuWiki_Action_Plugin { |
||
27 | |||
28 | /** |
||
29 | * plugin should use this method to register its handlers with the DokuWiki's event controller |
||
30 | * |
||
31 | * @param $controller DokuWiki's event controller object. Also available as global $EVENT_HANDLER |
||
32 | */ |
||
33 | function register(Doku_Event_Handler $controller) { |
||
0 ignored issues
–
show
|
|||
34 | $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ()); |
||
35 | $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'insertCSSSniffer'); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Inserts the toolbar button. |
||
40 | * @param Doku_Event $event the DokuWiki event |
||
41 | */ |
||
42 | function insert_button(Doku_Event $event, $param) { |
||
0 ignored issues
–
show
|
|||
43 | $strOpen ='<olmap id="olMapOne" width="550px" height="450px" lat="50.0" '; |
||
44 | $strOpen.='lon="5.1" zoom="12" statusbar="1" controls="1" poihoverstyle="0" '; |
||
45 | $strOpen.='baselyr="OpenStreetMap" gpxfile="" kmlfile="" geojsonfile="" summary="" >\n'; |
||
46 | $strOpen.='~~ Plugin olmap help.\n'; |
||
47 | $strOpen.='~~ Required in the above tag are values for: id (unique on this page), width, heigth.\n'; |
||
48 | $strOpen.='~~ Also you will want to enter zoomlevel and lat, lon values that make sense for where you want the map to start.\n\n'; |
||
49 | $strOpen.='~~ Below is an example of a POI, you can add as many as you want. '; |
||
50 | $strOpen.='~~ More examples: http://dokuwiki.org/plugin:openlayersmap \n'; |
||
51 | $event->data[] = array ( |
||
52 | 'type' => 'format', |
||
53 | 'title' => $this->getLang('openlayersmap'), |
||
54 | 'icon' => '../../plugins/openlayersmap/toolbar/map.png', |
||
55 | 'open' => $strOpen, |
||
56 | 'sample' => '50.0117,5.1287,-90,.8,marker-green.png,Pont de Barbouillons; Daverdisse \\\\ external link: [[http://test.com|test.com]] \\\\ internal link: [[::start]]\\\\ **DW Formatting** \n', |
||
57 | 'close' => '</olmap>\n', |
||
58 | ); |
||
59 | } |
||
60 | /** add a snippet of javascript into the head to do a css operation we can check for lateron.*/ |
||
61 | function insertCSSSniffer(Doku_Event $event, $param) { |
||
0 ignored issues
–
show
|
|||
62 | $event->data["script"][] = array ( |
||
63 | "type" => "text/javascript", |
||
64 | "_data" => "document.documentElement.className += ' olCSSsupported';", |
||
65 | ); |
||
66 | } |
||
67 | } |
||
68 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.