17148e535SAndreas Gohr<?php 27148e535SAndreas Gohr 3*5895dcbaSAndreas Gohruse dokuwiki\Extension\ActionPlugin; 4*5895dcbaSAndreas Gohruse dokuwiki\Extension\EventHandler; 5*5895dcbaSAndreas Gohruse dokuwiki\Extension\Event; 6*5895dcbaSAndreas Gohr 77148e535SAndreas Gohr/** 87148e535SAndreas Gohr * DokuWiki Plugin vshare (Action Component) 97148e535SAndreas Gohr * 107148e535SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 117148e535SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 127148e535SAndreas Gohr */ 13*5895dcbaSAndreas Gohrclass action_plugin_vshare extends ActionPlugin 147148e535SAndreas Gohr{ 157148e535SAndreas Gohr /** @inheritDoc */ 16*5895dcbaSAndreas Gohr public function register(EventHandler $controller) 177148e535SAndreas Gohr { 187148e535SAndreas Gohr $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'addSites'); 197148e535SAndreas Gohr } 207148e535SAndreas Gohr 217148e535SAndreas Gohr /** 227148e535SAndreas Gohr * Add the site regexes 237148e535SAndreas Gohr * 24*5895dcbaSAndreas Gohr * @param Event $event event object by reference 257148e535SAndreas Gohr * @param mixed $param optional parameter passed when event was registered 267148e535SAndreas Gohr * @return void 277148e535SAndreas Gohr */ 28*5895dcbaSAndreas Gohr public function addSites(Event $event, $param) 297148e535SAndreas Gohr { 307148e535SAndreas Gohr global $JSINFO; 317148e535SAndreas Gohr 327148e535SAndreas Gohr $sites = parse_ini_file(__DIR__ . '/sites.ini', true, INI_SCANNER_RAW); 337148e535SAndreas Gohr $js = []; 347148e535SAndreas Gohr 357148e535SAndreas Gohr foreach ($sites as $site => $data) { 367148e535SAndreas Gohr if (empty($data['rex'])) continue; 377148e535SAndreas Gohr $js[$site] = $data['rex']; 387148e535SAndreas Gohr } 397148e535SAndreas Gohr 407148e535SAndreas Gohr $JSINFO['plugins']['vshare'] = $js; 417148e535SAndreas Gohr } 427148e535SAndreas Gohr} 43