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
14require_once(DOKU_PLUGIN.'syntax.php');
15
16class syntax_plugin_popupviewer_popupscript extends DokuWiki_Syntax_Plugin {
17
18    function getType() { return 'protected'; }
19    function getPType() { return 'normal'; }
20    function getSort() { return 98; }
21
22    function connectTo($mode) {
23        $this->Lexer->addEntryPattern('<popupscript>(?=.*?</popupscript>)', $mode, 'plugin_popupviewer_popupscript');
24    }
25
26    function postConnect() {
27        $this->Lexer->addExitPattern('</popupscript>', 'plugin_popupviewer_popupscript');
28    }
29
30    function handle($match, $state, $pos, Doku_Handler $handler) {
31        if ( $state == DOKU_LEXER_UNMATCHED ) {
32            return $match;
33        }
34
35        return false;
36    }
37
38    function render($mode, Doku_Renderer $renderer, $data) {
39
40        global $ID;
41
42        if ( $mode == "metadata" && $this->getConf('allowpopupscript')) {
43            p_set_metadata($ID, array( 'popupscript' => trim($data)));
44        }
45    }
46}
47// vim:ts=4:sw=4:et:enc=utf-8:
48