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