1<?php
2/**
3 * Mikio Syntax Plugin: Carousel Item
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_carouselitem extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'carousel-item';
15    public $hasEndTag           = false;
16    public $options             = array(
17        'active'                    => array('type' => 'boolean',   'default'   => 'false'),
18        'image'                     => array('type' => 'media',     'default'   => ''),
19        'title'                     => array('type' => 'text',      'default'   => ''),
20        'text'                      => array('type' => 'text',      'default'   => ''),
21        'url'                       => array('type' => 'url',       'default'   => ''),
22        'background-color'         => array('type' => 'color',     'default'   => ''),
23        'placeholder-text'          => array('type' => 'text',      'default'   => ''),
24        'placeholder-text-color'   => array('type' => 'color',     'default'   => ''),
25        'placeholder-color'        => array('type' => 'color',     'default'   => ''),
26        'delay'                     => array('type' => 'float',    'default'   =>'4.5'),
27    );
28
29    public function __construct() {
30        $this->options['placeholder-color']['default'] = $this->callMikioOptionDefault('placeholder', 'color');
31        $this->options['placeholder-text-color']['default'] = $this->callMikioOptionDefault('placeholder', 'text-color');
32    }
33
34
35    public function render_lexer_special(Doku_Renderer $renderer, $data) {
36        $classes = $this->buildClass($data, array('active'), '');
37
38        $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-item' . $classes . '"' . ($data['delay'] != '' ? ' data-interval="' . $data['delay'] . '"' : '') . '>';
39
40
41        if($data['image'] != '') {
42            $renderer->doc .= '<img src="' . $data['image'] . '">';
43        } else {
44            if($data['placeholder-text'] != '') {
45                $this->syntaxRender($renderer, 'placeholder', '', array('text' => $data['placeholder-text'], 'color' => $data['placeholder-color'], 'text-color' => $data['placeholder-text-color']));
46            }
47        }
48
49        if($data['title'] != '' || $data['text'] != '') {
50            $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-caption">';
51
52            if($data['title'] != '') {
53                $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-caption-title">' . ($data['url'] != '' ? '<a href="' . $data['url'] . '">' : '') . $data['title'] . ($data['url'] != '' ? '</a>' : '') . '</div>';
54            }
55
56            if($data['text'] != '') {
57                $renderer->doc .= '<p>' . $data['text'] . '</p>';
58            }
59
60            $renderer->doc .= '</div>';
61        }
62
63        $renderer->doc .= '</div>';
64    }
65
66}
67?>