xref: /plugin/mikioplugin/syntax/carouselitem.php (revision 7935713e90ae66bca4380ea057ab7fd4f3e18daa)
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
30    public function render_lexer_special(Doku_Renderer $renderer, $data) {
31        $classes = $this->buildClass($data, array('active'), '');
32
33        $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-item' . $classes . '"' . ($data['delay'] != '' ? ' data-interval="' . $data['delay'] . '"' : '') . '>';
34
35
36        if($data['image'] != '') {
37            $renderer->doc .= '<img src="' . $data['image'] . '">';
38        } else {
39            if($data['placeholder-text'] != '') {
40                $this->syntaxRender($renderer, 'placeholder', '', array('text' => $data['placeholder-text'], 'color' => $data['placeholder-color'], 'text-color' => $data['placeholder-text-color']));
41            }
42        }
43
44        if($data['title'] != '' || $data['text'] != '') {
45            $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-caption">';
46
47            if($data['title'] != '') {
48                $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-caption-title">' . ($data['url'] != '' ? '<a href="' . $data['url'] . '">' : '') . $data['title'] . ($data['url'] != '' ? '</a>' : '') . '</div>';
49            }
50
51            if($data['text'] != '') {
52                $renderer->doc .= '<p>' . $data['text'] . '</p>';
53            }
54
55            $renderer->doc .= '</div>';
56        }
57
58        $renderer->doc .= '</div>';
59    }
60
61}
62?>