<?php
/**
 * HCalendar Action Plugin:   Register HCalendar to the toolbar
 *
 * @author     Jürgen A.Lamers <jaloma.ac@googlemail.com>
 */

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_hcalendar extends DokuWiki_Action_Plugin
{

    /**
     * return some info
     */
    function getInfo()
    {
        return array (
        'author'=>'Jürgen A.Lamers',
        'email'=>'jaloma.ac@googlemail.com',
        'date'=>@file_get_contents(DOKU_PLUGIN.'hcalendar/VERSION'),
        'name'=>'HCalendar (toolbar action plugin component)',
        'desc'=>'HCalendar toolbar action functions.',
        'url'=>'http://www.dokuwiki.org/plugin:hcalendar',
        );
    }

    function register( & $controller)
    {
        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
    }

    /**
     * Inserts a toolbar button
     */
    function insert_button( & $event, $param)
    {
        $event->data[] = array (
        'type'=>'format',
        'title'=>$this->getLang('hcalendar'),
        'icon'=>'../../plugins/hcalendar/toolbar/hcalendar.png',
        'open'=>'<hcal start_date=\'yyyy/mm/dd\' '.
        'start_time=\'hh:mm\' '.
        'end_date=\'yyyy/mm/dd\' '.
        'end_time=\'hh:mm\' '.
        'summary=\'off\' location=\'off\' '.
        'inline=\'off\''.
        '>',
        'close'=>'</hcal>',
        );
    }
} // class
