1<?php
2/*
3 * Bootnote Action Plugin: Inserts a button into the toolbar
4 *
5 * @author Algorys
6*/
7
8if (!defined('DOKU_INC')) die();
9
10class action_plugin_bootnote extends DokuWiki_Action_Plugin {
11
12    function register(Doku_Event_Handler $controller) {
13        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
14    }
15
16    /*
17    * Inserts a toolbar button
18    */
19    function insert_button(Doku_Event $event, $param) {
20        $syntax = array (
21            'normal' => array(
22                'icon' => '../../plugins/bootnote/images/normal.png',
23                'open'   => '<bootnote>',
24                'close'  => '</bootnote>',
25                'sample' => 'MY_NOTE'
26            ),
27            'question' => array(
28                'icon' => '../../plugins/bootnote/images/question.png',
29                'open'   => '<bootnote question>',
30                'close'  => '</bootnote>',
31                'sample' => 'MY_NOTE'
32            ),
33            'learn' => array(
34                'icon' => '../../plugins/bootnote/images/learn.png',
35                'open'   => '<bootnote learn>',
36                'close'  => '</bootnote>',
37                'sample' => 'MY_NOTE'
38            ),
39            'web' => array(
40                'icon' => '../../plugins/bootnote/images/web.png',
41                'open'   => '<bootnote web>',
42                'close'  => '</bootnote>',
43                'sample' => 'MY_NOTE'
44            ),
45            'warning' => array(
46                'icon' => '../../plugins/bootnote/images/warning.png',
47                'open'   => '<bootnote warning>',
48                'close'  => '</bootnote>',
49                'sample' => 'MY_NOTE'
50            ),
51            'critical' => array(
52                'icon' => '../../plugins/bootnote/images/critical.png',
53                'open'   => '<bootnote critical>',
54                'close'  => '</bootnote>',
55                'sample' => 'MY_NOTE'
56            )
57        );
58
59        $bootnote = array(
60            'type' => 'picker',
61            'title' => 'Bootnote',
62            'icon' => '../../plugins/bootnote/images/note.png',
63            'list' => array(),
64        );
65
66        foreach ($syntax as $syntax_name => $syntax_data) {
67            $bootnote['list'] [] = array(
68                'type' => 'format',
69                'title' => $syntax_name,
70                'icon' => $syntax_data['icon'],
71                'open' => $syntax_data['open'],
72                'close' => $syntax_data['close'],
73                'sample' => $syntax_data['sample'],
74            );
75        }
76
77        $event->data[] = $bootnote;
78
79    }
80}
81