xref: /plugin/mikioplugin/syntax/carousel.php (revision a8ac09a86a2c8d393b0b54e21a9508a8003cfc0a)
1<?php
2/**
3 * Mikio Syntax Plugin: Carousel
4 *
5 * @link        http://github.com/nomadjimbob/mikioplugin
6 * @license     GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author      James Collins <james.collins@outlook.com.au>
8 */
9if (!defined('DOKU_INC')) die();
10if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once(dirname(__FILE__).'/core.php');
12
13class syntax_plugin_mikioplugin_carousel extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'carousel';
15    public $hasEndTag           = true;
16    public $options             = array(
17        'transition'    => array('type'     => 'choice',
18                                 'data'     => array('slide', 'fade'),
19                                 'default'  => ''),
20        'indicators'    => array('type'     => 'boolean',   'default'   => 'true'),
21        'controls'      => array('type'     => 'boolean',   'default'   => 'true'),
22        'start'         => array('type'     => 'boolean',   'default'   => 'false'),
23    );
24
25    public function __construct() {
26        $this->addCommonOptions('height');
27    }
28
29
30    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
31        $classes = $this->buildClass($data, array('transition'));
32        $styles = $this->buildStyle(array('height' => $data['height']), TRUE);
33
34        $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel' . $classes . '" data-auto-start="' . ($data['start'] ? 'true' : 'false') . '"' . $styles . '>';
35        $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-inner">';
36    }
37
38
39    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
40        $renderer->doc .= '</div>';
41
42        if($data['controls'] === TRUE) {
43            $renderer->doc .= '<a href="#" class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-control ' . $this->classPrefix . 'carousel-control-prev" role="button"></a>';
44            $renderer->doc .= '<a href="#" class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-control ' . $this->classPrefix . 'carousel-control-next" role="button"></a>';
45        }
46
47        if($data['indicators'] === TRUE) {
48            $renderer->doc .= '<ul class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-indicators"></ul>';
49        }
50
51        $renderer->doc .= '</div>';
52    }
53}
54?>