xref: /plugin/combo/action/toolbar.php (revision 2128d41957a347f460d708a4ede62030dec35ebe)
1<?php
2/**
3 * Action Component
4 * Add a button in the edit toolbar
5 *
6 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author     Nicolas GERARD
8 */
9
10use ComboStrap\PluginUtility;
11
12if (!defined('DOKU_INC')) die();
13require_once(__DIR__ . '/../class/PluginUtility.php');
14
15
16class action_plugin_combo_toolbar extends DokuWiki_Action_Plugin {
17
18    /**
19     * register the event handlers
20     *
21     * @author Nicolas GERARD
22     */
23    function register(Doku_Event_Handler $controller){
24        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array ());
25    }
26
27    function handle_toolbar(&$event, $param) {
28
29
30        $unit = array(
31            'type'   => 'format',
32            'title'  => 'Insert an unit test',
33            'icon'   => '../../plugins/'. PluginUtility::PLUGIN_BASE_NAME .'/images/unit-doc-block.png',
34            'open'   => '<unit name="default">\n<file lang path>\n</file>\n\t<code lang>',
35            'close'  => '\n\t</code>\n\tt<console>\n\t</console></unit>\n',
36            // 'key'    => $unitShortcutKey
37        );
38
39        /**
40         * This is called from the js.php with a get HTTP
41         * There is no knowledge of which page is modified
42         */
43
44        $frontmatter = <<<EOF
45---json
46{
47    "canonical":"unique:name",
48    "title":"A title for the search page result engine",
49     "description":"A description for the search page result engine"
50}
51---
52EOF;
53        // https://www.dokuwiki.org/devel:event:toolbar_define
54        $frontmatter = array(
55            'type' => 'insert',
56            'title' => 'Insert a frontmatter',
57            'icon' =>  '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/table-of-contents.svg',
58            'insert' => $frontmatter,
59            'block'  => true
60        );
61
62
63        $blockquote = array(
64            'type' => 'format',
65            'title' => 'blockquote',
66            'icon' => '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/blockquote-icon.png',
67            'open' => '<blockquote>',
68            'close' => '</blockquote>',
69
70        );
71
72        $event->data[] = array(
73            'type'   => 'picker',
74            'title'  => "Choose comboStrap component",
75            'icon'   => '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/logo.svg',
76            'list'   => array($frontmatter,$blockquote,$unit)
77        );
78
79        return true;
80
81
82    }
83
84}
85
86