1<?php 2 3/** 4 * Mikio Syntax Plugin: Carousel 5 * 6 * @link http://github.com/nomadjimbob/mikioplugin 7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 8 * @author James Collins <james.collins@outlook.com.au> 9 */ 10if (!defined('DOKU_INC')) die(); 11if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 12require_once(dirname(__FILE__) . '/core.php'); 13 14class syntax_plugin_mikioplugin_carousel extends syntax_plugin_mikioplugin_core 15{ 16 public $tag = 'carousel'; 17 public $hasEndTag = true; 18 public $options = array( 19 'transition' => array( 20 'type' => 'choice', 21 'data' => array('slide', 'fade'), 22 'default' => '' 23 ), 24 'indicators' => array('type' => 'boolean', 'default' => 'true'), 25 'controls' => array('type' => 'boolean', 'default' => 'true'), 26 'start' => array('type' => 'boolean', 'default' => 'false'), 27 'cover' => array('type' => 'boolean', 'default' => 'false'), 28 'control-color' => array('type' => 'color', 'default' => '#fff'), 29 'control-outline-color' => array('type' => 'color', 'default' => ''), 30 'control-outline-width' => array('type' => 'multisize', 'default' => ''), 31 ); 32 33 public function __construct() 34 { 35 $this->addCommonOptions('height'); 36 } 37 38 39 public function render_lexer_enter(Doku_Renderer $renderer, $data) 40 { 41 $classes = $this->buildClass($data, array('transition')); 42 $styles = $this->buildStyle(array('height' => $data['height']), TRUE); 43 44 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel' . ($data['cover'] ? ' ' . $this->classPrefix . 'image-cover' : '') . $classes . '" data-auto-start="' . ($data['start'] ? 'true' : 'false') . '"' . $styles . '>'; 45 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-inner">'; 46 } 47 48 49 public function render_lexer_exit(Doku_Renderer $renderer, $data) 50 { 51 $renderer->doc .= '</div>'; 52 53 if ($data['controls'] === TRUE) { 54 $svg_styles = $this->buildStyle(array('fill' => $data['control-color'], 'stroke' => $data['control-outline-color'], 'stroke-width' => $data['control-outline-width']), TRUE); 55 56 $renderer->doc .= '<a href="#" class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-control ' . $this->classPrefix . 'carousel-control-prev" role="button"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 8 8"' . $svg_styles . '><path d="M5.25 0l-4 4 4 4 1.5-1.5L4.25 4l2.5-2.5L5.25 0z"/></svg></a>'; 57 $renderer->doc .= '<a href="#" class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-control ' . $this->classPrefix . 'carousel-control-next" role="button"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 8 8"' . $svg_styles . '><path d="M2.75 0l-1.5 1.5L3.75 4l-2.5 2.5L2.75 8l4-4-4-4z"/></svg></a>'; 58 } 59 60 if ($data['indicators'] === TRUE) { 61 $renderer->doc .= '<ul class="' . $this->elemClass . ' ' . $this->classPrefix . 'carousel-indicators"></ul>'; 62 } 63 64 $renderer->doc .= '</div>'; 65 } 66} 67