Issues (93)

action.php (6 issues)

1
<?php
2
3
use dokuwiki\Extension\ActionPlugin;
0 ignored issues
show
The type dokuwiki\Extension\ActionPlugin 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...
4
use dokuwiki\Extension\EventHandler;
0 ignored issues
show
The type dokuwiki\Extension\EventHandler 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...
5
use dokuwiki\Extension\Event;
0 ignored issues
show
The type dokuwiki\Extension\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...
This use statement conflicts with another class in this namespace, Event. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
6
7
/*
8
 * Copyright (c) 2008 Mark C. Prins <[email protected]>
9
 *
10
 * Permission to use, copy, modify, and distribute this software for any
11
 * purpose with or without fee is hereby granted, provided that the above
12
 * copyright notice and this permission notice appear in all copies.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21
 *
22
 * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
23
 */
24
/**
25
 * Action for Plugin OL Maps: Allow Display of a OpenLayers Map in a wiki page.
26
 * @author Mark Prins
27
 */
28
class action_plugin_openlayersmap extends ActionPlugin
29
{
30
    /**
31
     * Plugin uses this method to register its handlers with the DokuWiki's event controller.
32
     *
33
     * @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...
34
     */
35
    final public function register(EventHandler $controller): void
36
    {
37
        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton');
38
        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'insertCSSSniffer');
39
        $controller->register_hook('PLUGIN_POPULARITY_DATA_SETUP', 'AFTER', $this, 'popularity');
40
    }
41
42
    /**
43
     * Inserts the toolbar button.
44
     * @param Event $event the DokuWiki event
45
     */
46
    final public function insertButton(Event $event): void
47
    {
48
        $strOpen = '<olmap id="olMapOne" width="550px" height="450px" lat="50.0" ';
49
        $strOpen .= 'lon="5.1" zoom="12" controls="1" ';
50
        $strOpen .= 'baselyr="OpenStreetMap" gpxfile="" kmlfile="" geojsonfile="" summary="" >\n';
51
        $strOpen .= '~~ Plugin olmap help.\n';
52
        $strOpen .= '~~ Required in the above tag are values for: id (unique on this page), width, heigth.\n';
53
        $strOpen .= '~~ Also you will want to enter zoomlevel and lat, lon values that make sense for where you';
54
        $strOpen .= '~~ want the map to start.\n\n';
55
        $strOpen .= '~~ Below is an example of a POI, you can add as many as you want. ';
56
        $strOpen .= '~~ More examples: https://dokuwiki.org/plugin:openlayersmap \n';
57
        $event->data[] = ['type' => 'format', 'title' => $this->getLang('openlayersmap'), 'icon' => '../../plugins/openlayersmap/toolbar/map.png', 'open' => $strOpen, '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', 'close' => '</olmap>\n'];
59
    }
60
61
    /**
62
     * Add a snippet of javascript into the head to do a css operation we can check for later on.
63
     * @param Event $event the DokuWiki event
64
     */
65
    final public function insertCSSSniffer(Event $event): void
66
    {
67
        $event->data["script"][] = ["_data" => "document.documentElement.className += ' olCSSsupported';"];
68
    }
69
70
    /**
71
     * Add openlayersmap popularity data.
72
     *
73
     * @param Event $event the DokuWiki event
74
     */
75
    final public function popularity(Event $event): void
76
    {
77
        $versionInfo = getVersionData();
0 ignored issues
show
The function getVersionData was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

77
        $versionInfo = /** @scrutinizer ignore-call */ getVersionData();
Loading history...
78
        $plugin_info = $this->getInfo();
79
        $event->data['openlayersmap']['version'] = $plugin_info['date'];
80
        $event->data['openlayersmap']['dwversion'] = $versionInfo['date'];
81
        $event->data['openlayersmap']['combinedversion'] = $versionInfo['date'] . '_' . $plugin_info['date'];
82
    }
83
}
84