1<?php
2/**
3 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
4 * @author     Stephan Dekker <Stephan@SparklingSoftware.com.au>
5*/
6
7// must be run within DokuWiki
8if(!defined('DOKU_INC')) die();
9
10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once DOKU_PLUGIN.'syntax.php';
12
13    /**
14    * All DokuWiki plugins to extend the parser/rendering mechanism
15    * need to inherit from this class
16    */
17class syntax_plugin_rigrr extends DokuWiki_Syntax_Plugin {
18
19    function getInfo() {
20        return array('author' => 'Stephan Dekker',
21                        'email'  => 'Stephan@SparklingSoftware.com.au',
22                        'date'   => '2012-12-03',
23                        'name'   => 'rigrr',
24                        'desc'   => 'allows BPML to be rendered',
25                        'url'    => 'http://www.dokuwiki.org/plugin:rigrr');
26    }
27
28    function getType() { return 'substition'; }
29    function getSort() { return 32; }
30
31    function connectTo($mode) {  $this->Lexer->addEntryPattern('<rigrr.*?>(?=.*?</rigrr>)',$mode,'plugin_rigrr'); }
32    function postConnect() { $this->Lexer->addExitPattern('</rigrr>','plugin_rigrr'); }
33
34    function handle($match, $state, $pos, &$handler) {
35        return array($match, $state, $pos);
36    }
37
38    function render($mode, &$renderer, $data) {
39    // $data is what the function handle return'ed.
40        if($mode == 'xhtml'){
41            list($match,$state,$pos) = $data;
42            if ($state != DOKU_LEXER_UNMATCHED) return false;
43
44            $renderer->doc .= '<textarea id="rigrr_bpmn" style="visibility:hidden;">';
45            $renderer->doc .= trim($match);
46            $renderer->doc .= '</textarea>';
47            $renderer->doc .= '<div id="rigrr_canvas"></div>';
48
49            return true;
50        }
51        return false;
52    }
53}
54