1 <?php
2 /**
3  * Plugin Goole+1
4  *
5  * @author Enrico Croce & Simona Burzio (staff@eiroca.net)
6  * @copyright Copyright (C) 2013-2019 eIrOcA - Enrico Croce & Simona Burzio
7  * @license GPL >=3 (http://www.gnu.org/licenses/)
8  * @version 19.02
9  * @link http://www.eiroca.net/doku_gplusone
10  */
11 if (!defined('DOKU_INC')) die();
12 if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
13 if (!defined('DOKU_PLUGIN_GPLUSONE')) define('DOKU_PLUGIN_GPLUSONE', DOKU_PLUGIN . 'gplusone/');
14 require_once (DOKU_PLUGIN . 'syntax.php');
15 
16 class syntax_plugin_gplusone extends DokuWiki_Syntax_Plugin {
17 
18   function getType() {
19     return 'substition';
20   }
21 
22   function getPType() {
23     return 'normal';
24   }
25 
26   function getSort() {
27     return 999;
28   }
29 
30   function connectTo($mode) {
31     $this->Lexer->addSpecialPattern('~~GPLUSONE.*?~~', $mode, 'plugin_gplusone');
32   }
33 
34   function getConf($setting, $notset = false) {
35     $val = $this->localConf[$setting];
36     if ($val == '') {
37       $val = parent::getConf($setting, $notset);
38     }
39     return $val;
40   }
41 
42   function handle($match, $state, $pos, Doku_Handler $handler) {
43     $out = "";
44     $paramsArr = explode('~', $match);
45     $this->localConf = array ();
46     for ($i = 3; $i < count($paramsArr); $i++) {
47       $param = explode('=', $paramsArr[$i]);
48       $this->localConf[$param[0]] = $param[1];
49     }
50     $out = '<div class="g-plusone"';
51     if (!$this->configloaded) {
52       $this->loadConfig();
53     }
54     foreach ($this->conf as $param => $val) {
55       $val = $this->getConf($param);
56       if ($val != '') {
57         $out .= ' data-' . $param . '="' . $val . '"';
58       }
59     }
60     $out .= '></div>';
61     return $out;
62   }
63 
64   function render($mode, Doku_Renderer $renderer, $data) {
65     if ($mode == 'xhtml') {
66       $renderer->doc .= $data;
67       return true;
68     }
69     return false;
70   }
71 
72 }
73 ?>