1<?php
2/**
3 * DokuWiki ApexCharts Plugin
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Karl Nickel <kazozaagir@gmail.com>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12class action_plugin_achart extends DokuWiki_Action_Plugin {
13
14    /**
15     * Registers a callback function for a given event
16     *
17     * @param Doku_Event_Handler $controller DokuWiki's event controller object
18     * @return void
19     */
20    public function register(Doku_Event_Handler $controller) {
21
22	   $controller->register_hook('DOKUWIKI_STARTED', 'AFTER',  $this, '_chartlang');
23    }
24
25    /**
26     * [Custom event handler which performs action]
27     *
28     * @param Doku_Event $event  event object by reference
29     * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
30     *                           handler was registered]
31     * @return void
32     */
33
34	function _chartlang(&$event, $param) {
35		global $JSINFO;global $conf;
36
37		$filename= dirname(__FILE__) . '/assets/locales/'.$conf['lang'].'.json';
38		if( file_exists( $filename ) == true ){$localization = $conf['lang'];} else {$localization = "en";}
39		$JSINFO['chartlang']  = $localization;
40		$JSINFO['chartlocale']= file_get_contents(dirname(__FILE__) . '/assets/locales/'.$localization.'.json');
41	}
42
43}
44