1<?php 2/** 3 * Bootstrap Wrapper Plugin: Tooltip 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com> 7 * @copyright (C) 2015-2020, Giuseppe Di Terlizzi 8 */ 9 10class syntax_plugin_bootswrapper_tooltip extends syntax_plugin_bootswrapper_bootstrap 11{ 12 public $p_type = 'normal'; 13 public $pattern_start = '<tooltip.*?>(?=.*?</tooltip>)'; 14 public $pattern_end = '</tooltip>'; 15 public $tag_name = 'tooltip'; 16 public $tag_attributes = array( 17 18 'placement' => array( 19 'type' => 'string', 20 'values' => array('top', 'bottom', 'left', 'right', 'auto'), 21 'required' => true, 22 'default' => 'top'), 23 24 'title' => array( 25 'type' => 'string', 26 'values' => null, 27 'required' => true, 28 'default' => null), 29 30 'html' => array( 31 'type' => 'boolean', 32 'values' => array(0, 1), 33 'required' => false, 34 'default' => false), 35 36 ); 37 38 public function render($mode, Doku_Renderer $renderer, $data) 39 { 40 41 if (empty($data)) { 42 return false; 43 } 44 45 if ($mode !== 'xhtml') { 46 return false; 47 } 48 49 /** @var Doku_Renderer_xhtml $renderer */ 50 list($state, $match, $pos, $attributes) = $data; 51 52 if ($state == DOKU_LEXER_ENTER) { 53 $placement = $attributes['placement']; 54 $title = $attributes['title']; 55 $html = $attributes['html']; 56 57 if ($html) { 58 $title = hsc(p_render('xhtml', p_get_instructions($title), $info)); 59 } 60 61 $markup = '<span class="bs-wrap bs-wrap-tooltip" data-toggle="tooltip" data-html="' . $html . '" data-placement="' . $placement . '" title="' . $title . '" style="border-bottom:1px dotted">'; 62 63 $renderer->doc .= $markup; 64 return true; 65 } 66 67 if ($state == DOKU_LEXER_EXIT) { 68 $renderer->doc .= '</span>'; 69 return true; 70 } 71 72 return true; 73 } 74} 75