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 getAllowedTypes() { return array(); } 20 21 public function render_lexer_enter(Doku_Renderer $renderer, $data) { 22 $classes = $this->buildClassString($data); 23 24 $renderer->doc .= '<ul class="nav nav-tabs ' . $classes . '">'; 25 } 26 27 28 public function render_lexer_exit(Doku_Renderer $renderer, $data) { 29 // $renderer->doc .= '</div>'; 30 } 31 32 33 public function render_lexer_unmatched(Doku_Renderer $renderer, $data) { 34 $items = []; 35 $bar = ''; 36 $content = ''; 37 $first = true; 38 39 if(preg_match_all('/<(?:TAB|tab)(.*?)>(.*?)<\/(?:TAB|tab)>/s', $data, $match)) { 40 if(count($match) >= 2 && count($match[1]) == count($match[2])) { 41 for($i = 0; $i < count($match[1]); $i++) { 42 if(preg_match('/title=("\w[\w\s]*(?=")|\w+|"[\w\s]*")/is', $match[1][$i], $titleMatch)) { 43 if(count($titleMatch) >= 1) { 44 $title = str_replace("\"", "", $titleMatch[1]); 45 $items[] = array('title' => $title, 'id' => 'tab_' . rand(0, 32767), 'content' => $this->render_text($match[2][$i])); 46 } 47 } 48 } 49 } 50 } 51 52 foreach($items as $item) { 53 $bar .= '<li class="nav-item"><a class="nav-item nav-link' . ($first ? ' active' : '') . '" data-toggle="tab" href="#' . $item['id'] . '">' . $item['title'] . '</a></li>'; 54 $content .= '<div id="' . $item['id'] . '" class="tab-pane ' . ($first ? ' show active' : '') . '"><p>' . $item['content'] . '</p></div>'; 55 56 $first = false; 57 } 58 59 $renderer->doc .= $bar . '</ul><div class="container-fluid"><div class="tab-content">' . $content . '</div></div>'; 60 } 61} 62?> 63