1<?php 2/** 3 * Mikio Syntax Plugin: Small 4 * 5 * Syntax: <SMALL></SMALL> 6 * 7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 8 * @author James Collins <james.collins@outlook.com.au> 9 */ 10 11if (!defined('DOKU_INC')) die(); 12if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13require_once(dirname(__FILE__).'/core.php'); 14 15class syntax_plugin_mikioplugin_tabgroup extends syntax_plugin_mikioplugin_core { 16 public $tag = 'tabgroup'; 17 18 19 public function render_lexer_enter(Doku_Renderer $renderer, $data) { 20 $classes = $this->buildClassString($data); 21 22 $renderer->doc .= '<ul class="nav nav-tabs ' . $classes . '">'; 23 } 24 25 26 public function render_lexer_exit(Doku_Renderer $renderer, $data) { 27 // $renderer->doc .= '</div>'; 28 } 29 30 31 public function render_lexer_unmatched(Doku_Renderer $renderer, $data) { 32 $items = []; 33 $bar = ''; 34 $content = ''; 35 $first = true; 36 37 if(preg_match_all('/<(?:TAB|tab)(.*?)>(.*?)<\/(?:TAB|tab)>/s', $data, $match)) { 38 if(count($match) >= 2 && count($match[1]) == count($match[2])) { 39 for($i = 0; $i < count($match[1]); $i++) { 40 if(preg_match('/title=("\w[\w\s]*(?=")|\w+|"[\w\s]*")/is', $match[1][$i], $titleMatch)) { 41 if(count($titleMatch) >= 1) { 42 $title = str_replace("\"", "", $titleMatch[1]); 43 $items[] = array('title' => $title, 'id' => 'tab_' . rand(0, 32767), 'content' => $this->render_text($match[2][$i])); 44 } 45 } 46 } 47 } 48 } 49 50 foreach($items as $item) { 51 $bar .= '<li class="nav-item"><a class="nav-item nav-link' . ($first ? ' active' : '') . '" data-toggle="tab" href="#' . $item['id'] . '">' . $item['title'] . '</a></li>'; 52 $content .= '<div id="' . $item['id'] . '" class="tab-pane ' . ($first ? ' show active' : '') . '"><p>' . $item['content'] . '</p></div>'; 53 54 $first = false; 55 } 56 57 $renderer->doc .= $bar . '</ul><div class="container-fluid"><div class="tab-content">' . $content . '</div></div>'; 58 } 59} 60?> 61