1<?php
2
3use dokuwiki\Extension\ActionPlugin;
4use dokuwiki\Extension\EventHandler;
5use dokuwiki\Extension\Event;
6
7/**
8 * DokuWiki Plugin vshare (Action Component)
9 *
10 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
11 * @author  Andreas Gohr <andi@splitbrain.org>
12 */
13class action_plugin_vshare extends ActionPlugin
14{
15    /** @inheritDoc */
16    public function register(EventHandler $controller)
17    {
18        $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'addSites');
19    }
20
21    /**
22     * Add the site regexes
23     *
24     * @param Event $event event object by reference
25     * @param mixed $param optional parameter passed when event was registered
26     * @return void
27     */
28    public function addSites(Event $event, $param)
29    {
30        global $JSINFO;
31
32        $sites = parse_ini_file(__DIR__ . '/sites.ini', true, INI_SCANNER_RAW);
33        $js = [];
34
35        foreach ($sites as $site => $data) {
36            if (empty($data['rex'])) continue;
37            $js[$site] = $data['rex'];
38        }
39
40        $JSINFO['plugins']['vshare'] = $js;
41    }
42}
43