1<?php
2/**
3 * DokuWiki Plugin socialshareprivacy (Syntax Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Frank Schiebel <frank@linuxmuster.net>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) die();
11
12if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
15
16require_once DOKU_PLUGIN.'syntax.php';
17
18class syntax_plugin_socialshareprivacy extends DokuWiki_Syntax_Plugin {
19    public function getType() {
20        return 'substition';
21    }
22
23    public function getPType() {
24        return 'block';
25    }
26
27    public function getSort() {
28        return 222;
29    }
30
31
32    public function connectTo($mode) {
33        $this->Lexer->addSpecialPattern('\{\{socialshareprivacy\}\}',$mode,'plugin_socialshareprivacy');
34        $this->Lexer->addSpecialPattern('\{\{socialshareprivacy>.+?\}\}',$mode,'plugin_socialshareprivacy');
35    }
36
37    public function handle($match, $state, $pos, Doku_Handler $handler){
38
39        $match = substr($match, 2, -2);
40        $pos = strrpos($match, ">");
41        if ( $pos === false ) {
42            $type = "socialshareprivacy";
43            $params = array();
44            return array($type, $params);
45        } else {
46            list($type, $options) = split('>', $match, 2);
47        }
48
49        // load default config options
50        //$flags = $this->getConf('defaults').'&'.$flags;
51
52        $options = split('&', $options);
53
54        foreach($options as $option) {
55            list($name, $value) = split('=', $option);
56            $params[trim($name)] = trim($value);
57        }
58
59    return array($type, $params);
60
61    }
62
63    public function render($mode, Doku_Renderer $renderer, $data) {
64        if($mode != 'xhtml') return false;
65
66        $renderer->doc .= '<div id="socialshareprivacy"></div>'. DOKU_LF;
67        return true;
68    }
69}
70
71// vim:ts=4:sw=4:et:
72