1<?php
2/**
3 * Action Plugin: Inserts a button into the toolbar to add file tags
4 *
5 * @author F.Schonack
6 */
7
8if (!defined('DOKU_INC')) die();
9if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
10require_once (DOKU_PLUGIN . 'action.php');
11
12class action_plugin_codebutton2 extends DokuWiki_Action_Plugin {
13
14
15
16    /**
17     * Register the eventhandlers
18     */
19    function register(&$controller) {
20	if (file_exists(DOKU_PLUGIN . "codebutton2/config.ini")) {
21        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array ());
22		}
23    }
24
25
26
27	function parse_ini()
28	{
29		$ini_array = parse_ini_file(DOKU_PLUGIN."codebutton2/config.ini");
30		$list_array = array();
31		foreach ($ini_array as $key => $value)
32		{
33			$list_array[] =  array(
34                    'type' => 'format',
35                    'title' => $key,
36                    'icon' => '../../plugins/codebutton2/genpng.php?text='.$key,
37                    'open' => '<code '.$value.'>\n',
38                    'close' => '\n</code>'
39                );
40		}
41		return $list_array;
42	}
43
44    /**
45     * Inserts the toolbar button
46     */
47
48
49    function handle_toolbar(& $event, $param) {
50		$list_array = $this->parse_ini();
51        $event->data[] = array (
52            'type' => 'picker',
53            'title' => $this->getLang('insertcode'),
54            'icon' => '../../plugins/codebutton2/genpng.php?text=Code%20',
55            'list' => $list_array  ,
56
57        );
58    }
59
60}
61