1<?php
2
3/**
4 * GrenSladaWritezor Save page.
5 *
6 * @license    GNU General Public License Version 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author     Stanford Ng <stng@theculprit.com>
8 */
9
10if(!defined('DOKU_INC')) die();
11
12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13require_once(DOKU_PLUGIN.'syntax.php');
14
15
16class syntax_plugin_grensladawritezor extends DokuWiki_Syntax_Plugin {
17
18    function syntax_plugin_grensladawritezor() {
19    }
20
21    function getInfo(){
22
23        return array(
24            'author' => 'Stanford Ng',
25            'email'  => 'stng@theculprit.com',
26            'date'   => '2007-03-24',
27            'name'   => 'GrenSladaWritezor',
28            'desc'   => 'Support awesome HTML edit in dokuwiki',
29            // 'url'    => 'TBD',
30            );
31    }
32
33    function getType() {
34        return 'formatting';
35    }
36
37    function getAllowedTypes() {
38        return array('formatting', 'substition', 'disabled');
39    }
40
41    function getSort() {
42        return 158;
43    }
44
45    function connectTo($mode) {
46        $this->Lexer->addEntryPattern('<EMBEDDED_HTML>',$mode,'plugin_grensladawritezor');
47    }
48
49    function postConnect() {
50        $this->Lexer->addExitPattern('</EMBEDDED_HTML>','plugin_grensladawritezor');
51    }
52
53    function handle($match, $state, $pos, &$handler){
54        switch ($state) {
55            case DOKU_LEXER_ENTER :      return array($state, '');
56            case DOKU_LEXER_UNMATCHED :  return array($state, $match);
57            case DOKU_LEXER_EXIT :       return array($state, '');
58        }
59        return array();
60    }
61
62    function render($mode, &$renderer, $data) {
63        if($mode == 'xhtml'){
64            list($state, $match) = $data;
65            switch ($state) {
66                case DOKU_LEXER_ENTER:
67                    list($before, $after) = $match;
68                    break;
69                case DOKU_LEXER_UNMATCHED:
70                    $text_to_render = html_entity_decode($match);
71                    $renderer->doc .= $text_to_render;
72                    break;
73                case DOKU_LEXER_EXIT:
74                    break;
75            }
76            return true;
77        }
78        return false;
79    }
80}
81
82?>
83