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