xref: /plugin/codebuttonmodbash/action.php (revision 7f2e915143a7c57ff33a752ff52cc2fff0a1af2d)
10bb6efa1Scasperklein<?php
251556cd7Sunimetal
351556cd7Sunimetaluse dokuwiki\Extension\ActionPlugin;
451556cd7Sunimetaluse dokuwiki\Extension\EventHandler;
551556cd7Sunimetaluse dokuwiki\Extension\Event;
651556cd7Sunimetal
70bb6efa1Scasperklein/**
80bb6efa1Scasperklein * Action Plugin: Inserts a button into the toolbar to add file tags
90bb6efa1Scasperklein *
10b92bccc8Sunimetal * @author Simon Jacob, Gina Haeussge
110bb6efa1Scasperklein */
120bb6efa1Scasperklein
1351556cd7Sunimetalclass action_plugin_codebuttonmodbash extends ActionPlugin {
140bb6efa1Scasperklein
150bb6efa1Scasperklein    /**
160bb6efa1Scasperklein     * Register the event handlers
1751556cd7Sunimetal     *
1851556cd7Sunimetal     * @param EventHandler $controller DokuWiki's event controller object
190bb6efa1Scasperklein     */
2051556cd7Sunimetal    public function register(EventHandler $controller) {
2151556cd7Sunimetal        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', []);
220bb6efa1Scasperklein    }
230bb6efa1Scasperklein
240bb6efa1Scasperklein    /**
250bb6efa1Scasperklein     * Inserts the toolbar button
2651556cd7Sunimetal     *
2751556cd7Sunimetal     * @param Event $event event object
2851556cd7Sunimetal     * @param mixed $param [the parameters passed as fifth argument to
2951556cd7Sunimetal     *                      register_hook() when this handler was registered,
3051556cd7Sunimetal     *                      here just an empty array..]
310bb6efa1Scasperklein     */
3251556cd7Sunimetal    public function insert_button(Event $event, $param) {
333a039d02Sunimetal
343a039d02Sunimetal        $codeStr = $this->getConf('codeStr');
350e61f690Sunimetal        $insert = $this->getLang('insert');
363a039d02Sunimetal
3751556cd7Sunimetal        $event->data[] = [
38f7853ca9Sunimetal            'type' => 'format',
39*7f2e9151Sunimetal            'title' => $insert.': <code '.$codeStr.'>...</code>',
4051556cd7Sunimetal            'icon' => '../../plugins/codebuttonmodbash/codebash.png',
41*7f2e9151Sunimetal            'open' => '<code '.$codeStr.'>\n',
42af31951cSGeorg Schmidt            'close' => '\n</code>',
4351556cd7Sunimetal        ];
440bb6efa1Scasperklein    }
450bb6efa1Scasperklein}
46