1<?php
2/**
3 * Redissue Action Plugin: Inserts a button into the toolbar
4 *
5 * @author Algorys
6 */
7
8if (!defined('DOKU_INC')) die();
9
10class action_plugin_redissue extends DokuWiki_Action_Plugin {
11
12    /**
13     * Register the eventhandlers
14     */
15    public function register(Doku_Event_Handler $controller) {
16        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
17    }
18
19    /**
20     * Inserts the toolbar button
21     */
22    public function insert_button(Doku_Event $event, $param) {
23        $syntax = array (
24            'Single Issue'   => array(
25                'icon' => '../../plugins/redissue/images/issue_single.png',
26                'open'   => '<redissue id="',
27                'close'  => '" />',
28                'sample' => 'ISSUE_ID'
29            ),
30            'Multiple Issue' => array(
31                'icon' => '../../plugins/redissue/images/issue_multiple.png',
32                'open'   => '<redissue project="PROJECT_ID" tracker="',
33                'close'  => '" />',
34                'sample' => 'TRACKER_ID'
35            ),
36        );
37
38        $redissue = array (
39            'type' => 'picker',
40            'title' => $this->getLang('redissue.button'),
41            'icon' => '../../plugins/redissue/images/redmine.png',
42            'list' => array(),
43        );
44
45        foreach ($syntax as $syntax_name => $syntax_data) {
46            $redissue['list'] [] = array(
47                'type' => 'format',
48                'title' => $syntax_name,
49                'icon' => $syntax_data['icon'],
50                'open' => $syntax_data['open'],
51                'close' => $syntax_data['close'],
52                'sample' => $syntax_data['sample'],
53            );
54        }
55
56        $event->data[] = $redissue;
57    } // insert_button
58}
59