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