1<?php
2/**
3 * DokuWiki Plugin dw2markdown (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  i-net software <tools@inetsoftware.de>
7 */
8
9class action_plugin_dw2markdown extends DokuWiki_Action_Plugin
10{
11    /**
12     * Register the events
13     *
14     * @param Doku_Event_Handler $controller
15     */
16    public function register(Doku_Event_Handler $controller)
17    {
18        $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addSvgButton', array());
19    }
20
21
22    /**
23     * Add 'Export to Markdown' button to page tools, SVG based
24     *
25     * @param Doku_Event $event
26     */
27    public function addSvgButton(Doku_Event $event)
28    {
29        global $INFO;
30
31        if ($event->data['view'] != 'page' || !$this->getConf('showexportbutton')) {
32            return;
33        }
34
35        if (! $INFO['exists']) {
36            return;
37        }
38
39        array_splice($event->data['items'], -1, 0, [new \dokuwiki\plugin\dw2markdown\MenuItem()]);
40    }
41}
42