1<?php
2/**
3 * popoutviewer Plugin
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     i-net software <tools@inetsoftware.de>
7 * @author     Gerry Weissbach <gweissbach@inetsoftware.de>
8 */
9
10// must be run within Dokuwiki
11if(!defined('DOKU_INC')) die();
12if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13
14class syntax_plugin_popupviewer_popupscript extends DokuWiki_Syntax_Plugin {
15
16    function getType() { return 'protected'; }
17    function getPType() { return 'normal'; }
18    function getSort() { return 98; }
19
20    function connectTo($mode) {
21        $this->Lexer->addEntryPattern('<popupscript>(?=.*?</popupscript>)', $mode, 'plugin_popupviewer_popupscript');
22    }
23
24    function postConnect() {
25        $this->Lexer->addExitPattern('</popupscript>', 'plugin_popupviewer_popupscript');
26    }
27
28    function handle($match, $state, $pos, Doku_Handler $handler) {
29        if ( $state == DOKU_LEXER_UNMATCHED ) {
30            return $match;
31        }
32
33        return false;
34    }
35
36    function render($mode, Doku_Renderer $renderer, $data) {
37
38        global $ID;
39
40        if ( $mode == "metadata" && $this->getConf('allowpopupscript')) {
41            p_set_metadata($ID, array( 'popupscript' => trim($data)));
42        }
43    }
44}
45// vim:ts=4:sw=4:et:enc=utf-8:
46