xref: /plugin/combo/action/toolbar.php (revision 5f891b7e09648e05e78f5882f3fdde1e9df9b0f1)
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    /**
20     * register the event handlers
21     *
22     * @author Nicolas GERARD
23     */
24    function register(Doku_Event_Handler $controller)
25    {
26        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array());
27    }
28
29    function handle_toolbar(&$event, $param)
30    {
31
32
33        $imageBase = '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/';
34        $unit = array(
35            'type' => 'format',
36            'title' => 'Insert an unit test',
37            'icon' => $imageBase . 'unit-doc-block.png',
38            'open' => '<unit name="default">\n<file lang path>\n</file>\n\t<code lang>',
39            'close' => '\n\t</code>\n\t<console>\n\t</console></unit>\n',
40            // 'key'    => $unitShortcutKey
41        );
42
43        /**
44         * This is called from the js.php with a get HTTP
45         * There is no knowledge of which page is modified
46         */
47
48        $frontmatter = <<<EOF
49---json
50{
51    "canonical":"unique:name",
52    "title":"A title for the search page result engine",
53     "description":"A description for the search page result engine"
54}
55---
56EOF;
57        // https://www.dokuwiki.org/devel:event:toolbar_define
58        $frontmatter = array(
59            'type' => 'insert',
60            'title' => 'Insert a frontmatter',
61            'icon' => $imageBase . 'table-of-contents.svg',
62            'insert' => $frontmatter,
63            'block' => true
64        );
65
66
67        $blockquote = array(
68            'type' => 'format',
69            'title' => 'blockquote',
70            'icon' => '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/blockquote-icon.png',
71            'open' => '<blockquote>',
72            'close' => '</blockquote>',
73
74        );
75
76        $event->data[] = array(
77            'type' => 'picker',
78            'title' => "Choose comboStrap component",
79            'icon' => '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/logo.svg',
80            'list' => array($frontmatter, $blockquote, $unit)
81        );
82
83        $event->data[] = array(
84            'type' => 'format',
85            'title' => 'webcode',
86            'icon' => '../../plugins/' . PluginUtility::PLUGIN_BASE_NAME . '/images/webcode.png',
87            'open' => '<webcode name="Default" frameborder="0">\n',
88            'close' => '\n</webcode>\n'
89            //'key' => $webCodeShortcutKey
90        );
91
92        return true;
93
94
95    }
96
97}
98
99