1<?php
2/**
3 * Bootstrap Wrapper Plugin: Well
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_well extends syntax_plugin_bootswrapper_bootstrap
11{
12
13    public $p_type         = 'normal';
14    public $pattern_start  = '<well.*?>(?=.*?</well>)';
15    public $pattern_end    = '</well>';
16    public $tag_name       = 'well';
17    public $tag_attributes = array(
18
19        'size' => array(
20            'type'     => 'string',
21            'values'   => array('lg', 'sm'),
22            'required' => false,
23            'default'  => null),
24
25    );
26
27    public function render($mode, Doku_Renderer $renderer, $data)
28    {
29
30        if (empty($data)) {
31            return false;
32        }
33
34        if ($mode !== 'xhtml') {
35            return false;
36        }
37
38        /** @var Doku_Renderer_xhtml $renderer */
39        list($state, $match, $pos, $attributes) = $data;
40
41        if ($state == DOKU_LEXER_ENTER) {
42            $size   = ($attributes['size']) ? 'well-' . $attributes['size'] : '';
43            $markup = '<div class="bs-wrap bs-wrap-well well ' . $size . '">';
44
45            $renderer->doc .= $markup;
46            return true;
47        }
48
49        if ($state == DOKU_LEXER_EXIT) {
50            $renderer->doc .= '</div>';
51            return true;
52        }
53
54        return true;
55    }
56}
57