1<?php 2/** 3 * Bootstrap Wrapper Plugin: Panel Group (Accordion) 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_accordion extends syntax_plugin_bootswrapper_bootstrap 11{ 12 13 public $p_type = 'block'; 14 public $pattern_start = '<accordion.*?>(?=.*?</accordion>)'; 15 public $pattern_end = '</accordion>'; 16 public $tag_name = 'accordion'; 17 public $tag_attributes = array( 18 19 'id' => array( 20 'type' => 'string', 21 'values' => null, 22 'required' => true, 23 'default' => null), 24 25 'collapsed' => array( 26 'type' => 'boolean', 27 'values' => array(0, 1), 28 'required' => false, 29 'default' => null), 30 31 ); 32 33 public function render($mode, Doku_Renderer $renderer, $data) 34 { 35 36 if (empty($data)) { 37 return false; 38 } 39 40 if ($mode !== 'xhtml') { 41 return false; 42 } 43 44 /** @var Doku_Renderer_xhtml $renderer */ 45 list($state, $match, $pos, $pos, $attributes) = $data; 46 47 if ($state == DOKU_LEXER_ENTER) { 48 $html_attributes = $this->mergeCoreAttributes($attributes); 49 $html_attributes['class'][] = 'bs-wrap bs-wrap-accordion panel-group'; 50 51 if ($attributes['collapsed']) { 52 $html_attributes['class'][] = 'bs-wrap-accordion-collapsed'; 53 } 54 55 $markup_attributes = $this->buildAttributes($html_attributes); 56 $markup = "<div $markup_attributes>"; 57 58 $renderer->doc .= $markup; 59 return true; 60 } 61 62 if ($state == DOKU_LEXER_EXIT) { 63 $renderer->doc .= '</div>'; 64 return true; 65 } 66 67 return true; 68 } 69} 70