<?php
/**
 * Opera Widget Plugin
 *
 * @license    GPLv3 (http://www.gnu.org/licenses/gpl.html)
 * @link       http://www.dokuwiki.org/plugin:jquery
 * @author     Markus Birth <markus@birth-online.de>
 */

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

    function getInfo() {
        return confToHash(dirname(__FILE__).'/INFO.txt');
    }

    function register(&$controller) {
        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, '_addwidget');
    }

    function _addwidget(&$event, $param) {
        global $conf;
        $title = $this->getConf('customtitle');;
        if (empty($title)) $title = $conf['title'];
        $title = rawurlencode($title);
        $skin  = rawurlencode($this->getConf('skin'));

        $event->data['link'][] = array(
            'rel'   => 'alternate',
            'type'  => 'application/x-opera-widgets',
            'title' => $conf['title'],
            'href'  => 'http://widgets.opera.com/widgetize/Feed%20Reader/Advanced/?serve&skin=' . $skin . '&widgetname=' . $title . '&url=' . rawurlencode(DOKU_BASE.'feed.php'),
        );
    }

}