1<?php
2
3// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
4// phpcs:disable PSR1.Files.SideEffects
5/*
6* Copyright (c) 2022 Mark C. Prins <mprins@users.sf.net>
7*
8* Permission to use, copy, modify, and distribute this software for any
9* purpose with or without fee is hereby granted, provided that the above
10* copyright notice and this permission notice appear in all copies.
11*
12* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19*
20*/
21use dokuwiki\Extension\Plugin;
22use dokuwiki\Extension\EventHandler;
23use dokuwiki\Extension\Event;
24use Composer\InstalledVersions;
25
26require_once __DIR__ . '/vendor/autoload.php';
27
28/**
29 * DokuWiki Plugin geophp (Action Component).
30 *
31 * @author Mark Prins
32 */
33class action_plugin_geophp extends Plugin
34{
35    /**
36     * plugin should use this method to register its handlers with the DokuWiki's event controller
37     *
38     * @param    $controller DokuWiki's event controller object. Also available as global $EVENT_HANDLER
39     */
40    final public function register(EventHandler $controller): void
41    {
42        $controller->register_hook('PLUGIN_POPULARITY_DATA_SETUP', 'AFTER', $this, 'popularity');
43    }
44
45    /**
46     * Produce popularity data for this plugin.
47     *
48     * @param Doku_Event $event The DokuWiki event
49     */
50    final public function popularity(Event $event): void
51    {
52        $versionInfo = getVersionData();
53        $geoPHP = InstalledVersions::getPrettyVersion('funiq/geophp');
54        $plugin_info = $this->getInfo();
55        $event->data['geophp']['version'] = $plugin_info['date'];
56        $event->data['geophp']['geophp'] = $geoPHP;
57        $event->data['geophp']['dwversion'] = $versionInfo['date'];
58        $event->data['geophp']['combinedversion'] = $versionInfo['date'] . '_' . $plugin_info['date'] . '_' . $geoPHP;
59    }
60}
61