<?php
/**
 * Action Plugin: Inserts a button into the toolbar to add file tags
 *
 * @author Heiko Barth
 */
 
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
require_once (DOKU_PLUGIN . 'action.php');
 
class action_plugin_codebutton extends DokuWiki_Action_Plugin {
 
    /**
     * Return some info
     */
    function getInfo() {
        return array (
            'author' => 'Heiko Barth',
            'date' => '2010-03-02',
            'name' => 'Toolbar Code Button',
            'desc' => 'Inserts a code button into the toolbar',
            'url' => 'http://www.heiko-barth.de/download.php?id=dw_codebutton',
        );
    }
 
    /**
     * Register the eventhandlers
     */
    function register(&$controller) {
        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
    }
 
    /**
     * Inserts the toolbar button
     */
    function insert_button(& $event, $param) {
        $event->data[] = array (
            'type' => 'format',
            'title' => $this->getLang('insertcode'),
            'icon' => '../../plugins/codebutton/pix/code.png',
            'open' => '<file>\n',
            'close' => '\n</file>',
        );
    }
 
}
