Passed
Push — master ( ca15cf...1bf208 )
by Mark
02:07
created

action_plugin_openlayersmap   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 26
dl 0
loc 55
rs 10
c 3
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A popularity() 0 6 1
A register() 0 4 1
A insertButton() 0 18 1
A insertCSSSniffer() 0 2 1
1
<?php
2
/*
3
 * Copyright (c) 2008-2021 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
 * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
18
 */
19
20
/**
21
 * Plugin OL Maps: Allow Display of a OpenLayers Map in a wiki page.
22
 * Toolbar button.
23
 * @author Mark Prins
24
 */
25
class action_plugin_openlayersmap extends DokuWiki_Action_Plugin {
0 ignored issues
show
Bug introduced by
The type DokuWiki_Action_Plugin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
27
    /**
28
     * plugin should use this method to register its handlers with the DokuWiki's event controller
29
     *
30
     * @param    $controller DokuWiki's event controller object. Also available as global $EVENT_HANDLER
0 ignored issues
show
Documentation Bug introduced by
The doc comment DokuWiki's at position 0 could not be parsed: Unknown type name 'DokuWiki's' at position 0 in DokuWiki's.
Loading history...
31
     */
32
    public function register(Doku_Event_Handler $controller) {
0 ignored issues
show
Bug introduced by
The type Doku_Event_Handler was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton', array());
34
        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'insertCSSSniffer');
35
        $controller->register_hook('PLUGIN_POPULARITY_DATA_SETUP', 'AFTER', $this, 'popularity');
36
    }
37
38
    /**
39
     * Inserts the toolbar button.
40
     * @param Doku_Event $event the DokuWiki event
41
     */
42
    public function insertButton(Doku_Event $event, $param) {
0 ignored issues
show
Bug introduced by
The type Doku_Event was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
43
        $strOpen       = '<olmap id="olMapOne" width="550px" height="450px" lat="50.0" ';
44
        $strOpen       .= 'lon="5.1" zoom="12" controls="1" ';
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';
49
        $strOpen       .= '~~ want the map to start.\n\n';
50
        $strOpen       .= '~~ Below is an example of a POI, you can add as many as you want. ';
51
        $strOpen       .= '~~ More examples: https://dokuwiki.org/plugin:openlayersmap \n';
52
        $event->data[] = array(
53
            'type'   => 'format',
54
            'title'  => $this->getLang('openlayersmap'),
55
            'icon'   => '../../plugins/openlayersmap/toolbar/map.png',
56
            'open'   => $strOpen,
57
            'sample' => '50.0117,5.1287,-90,.8,marker-green.png,Pont de Barbouillons; Daverdisse \\\\ external link: 
58
                        [[https://test.com|test.com]] \\\\ internal link: [[::start]]\\\\ **DW Formatting** \n',
59
            'close'  => '</olmap>\n',
60
        );
61
    }
62
63
    /** add a snippet of javascript into the head to do a css operation we can check for later on.*/
64
    public function insertCSSSniffer(Doku_Event $event, $param) {
65
        $event->data["script"][] = array("_data" => "document.documentElement.className += ' olCSSsupported';");
66
    }
67
68
    /**
69
     * Add openlayersmap popularity data.
70
     *
71
     * @param Doku_Event $event
72
     *          the DokuWiki event
73
     */
74
    final public function popularity(Doku_Event $event): void {
75
        global $updateVersion;
76
        $plugin_info                                     = $this->getInfo();
77
        $event->data['openlayersmap']['version']         = $plugin_info['date'];
78
        $event->data['openlayersmap']['dwversion']       = $updateVersion;
79
        $event->data['openlayersmap']['combinedversion'] = $updateVersion . '_' . $plugin_info['date'];
80
    }
81
}
82