1<?php 2/** 3 * Mikio Syntax Plugin: Card 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_card extends syntax_plugin_mikioplugin_core { 14 public $tag = 'card'; 15 public $hasEndTag = true; 16 public $options = array( 17 'image' => array('type' => 'media', 'default' => ''), 18 'overlay' => array('type' => 'boolean', 'default' => 'false'), 19 'title' => array('type' => 'text', 'default' => ''), 20 'subtitle' => array('type' => 'text', 'default' => ''), 21 'no-body' => array('type' => 'boolean', 'default' => 'false'), 22 'header' => array('type' => 'text', 'default' => ''), 23 'footer' => array('type' => 'text', 'default' => ''), 24 'placeholder-text' => array('type' => 'text', 'default' => ''), 25 'placeholder-color' => array('type' => 'text', 'default' => ''), 26 'placeholder-text-color' => array('type' => 'text', 'default' => ''), 27 'footer-image' => array('type' => 'media', 'default' => ''), 28 'footer-placeholder-text' => array('type' => 'text', 'default' => ''), 29 'footer-placeholder-color' => array('type' => 'text', 'default' => ''), 30 'footer-placeholder-text-color' => array('type' => 'text', 'default' => ''), 31 'horizontal' => array('type' => 'boolean', 'default' => 'false'), 32 'footer-small' => array('type' => 'boolean', 'default' => 'false'), 33 ); 34 35 36 public function __construct() { 37 $this->addCommonOptions('type shadow width height text-align'); 38 } 39 40 public function render_lexer_enter(Doku_Renderer $renderer, $data) { 41 $classes = $this->buildClass($data, array('overlay', 'horizontal')); 42 $styles = $this->buildStyle(array('height' => $data['height'], 'width' => $data['width']), TRUE); 43 44 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'card' . $classes . '"' . $styles . '>'; 45 46 if($data['horizontal']) $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'card-horizontal-image">'; 47 if($data['placeholder-text'] != '') { 48 $this->syntaxRender($renderer, 'placeholder', '', $this->arrayRemoveEmpties(array('text' => $data['placeholder-text'], 'color' => $data['placeholder-color'], 'text-color' => $data['placeholder-text-color']))); 49 } elseif($data['image'] != '') { 50 $renderer->doc .= '<img src="' . $data['image'] . '" class="' . $this->elemClass . ' ' . $this->classPrefix . 'card-image">'; 51 } 52 if($data['horizontal']) $renderer->doc .= '</div><div class="' . $this->elemClass . ' ' . $this->classPrefix . 'card-horizontal-body">'; 53 54 if($data['header'] != '') $this->syntaxRender($renderer, 'cardheader', $data['header']); 55 56 if($data['no-body'] == FALSE) $this->syntaxRender($renderer, 'cardbody', '', null, MIKIO_LEXER_ENTER); 57 58 if($data['title'] != '') $this->syntaxRender($renderer, 'cardtitle', $data['title']); 59 if($data['subtitle'] != '') $this->syntaxRender($renderer, 'cardsubtitle', $data['subtitle']); 60 } 61 62 63 public function render_lexer_exit(Doku_Renderer $renderer, $data) { 64 if($data['no-body'] == FALSE) $this->syntaxRender($renderer, 'cardbody', '', null, MIKIO_LEXER_EXIT); 65 66 if($data['footer'] != '') { 67 $this->syntaxRender($renderer, 'cardfooter', $data['footer'], $this->arrayRemoveEmpties(array('small' => $data['footer-small']))); 68 } 69 70 if($data['footer-placeholder-text'] != '') { 71 $this->syntaxRender($renderer, 'placeholder', '', $this->arrayRemoveEmpties(array('text' => $data['footer-placeholder-text'], 'color' => $data['footer-placeholder-color'], 'text-color' => $data['footer-placeholder-text-color']))); 72 } elseif($data['footer-image'] != '') { 73 $renderer->doc .= '<img src="' . $data['footer-image'] . '" class="' . $this->elemClass . ' ' . $this->classPrefix . 'card-image">'; 74 } 75 76 if($data['horizontal']) $renderer->doc .= '</div>'; 77 $renderer->doc .= '</div>'; 78 } 79} 80?>