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 vertical-align text-color'); 38 } 39 40 public function getAllowedTypes() { return array('formatting', 'substition', 'disabled', 'container'); } 41 public function getPType() { return 'normal'; } 42 43 public function render_lexer_enter(Doku_Renderer $renderer, $data) { 44 $classes = $this->buildClass($data, array('overlay', 'horizontal')); 45 $styles = $this->buildStyle(array('height' => $data['height'], 'width' => $data['width']), TRUE); 46 47 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'card' . $classes . '"' . $styles . '>'; 48 49 if($data['horizontal']) $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'card-horizontal-image">'; 50 if($data['placeholder-text'] != '') { 51 $this->syntaxRender($renderer, 'placeholder', '', $this->arrayRemoveEmpties(array('text' => $data['placeholder-text'], 'color' => $data['placeholder-color'], 'text-color' => $data['placeholder-text-color']))); 52 } elseif($data['image'] != '') { 53 $renderer->doc .= '<img src="' . $data['image'] . '" class="' . $this->elemClass . ' ' . $this->classPrefix . 'card-image">'; 54 } 55 if($data['horizontal']) $renderer->doc .= '</div><div class="' . $this->elemClass . ' ' . $this->classPrefix . 'card-horizontal-body">'; 56 57 if($data['header'] != '') $this->syntaxRender($renderer, 'cardheader', $data['header']); 58 59 if($data['no-body'] == FALSE) $this->syntaxRender($renderer, 'cardbody', '', $this->arrayRemoveEmpties(array('vertical-align' => $data['vertical-align'], 'text-color' => $data['text-color'])), MIKIO_LEXER_ENTER); 60 61 if($data['title'] != '') $this->syntaxRender($renderer, 'cardtitle', $data['title']); 62 if($data['subtitle'] != '') $this->syntaxRender($renderer, 'cardsubtitle', $data['subtitle']); 63 } 64 65 66 public function render_lexer_exit(Doku_Renderer $renderer, $data) { 67 if($data['no-body'] == FALSE) $this->syntaxRender($renderer, 'cardbody', '', null, MIKIO_LEXER_EXIT); 68 69 if($data['footer'] != '') { 70 $this->syntaxRender($renderer, 'cardfooter', $data['footer'], $this->arrayRemoveEmpties(array('small' => $data['footer-small']))); 71 } 72 73 if($data['footer-placeholder-text'] != '') { 74 $this->syntaxRender($renderer, 'placeholder', '', $this->arrayRemoveEmpties(array('text' => $data['footer-placeholder-text'], 'color' => $data['footer-placeholder-color'], 'text-color' => $data['footer-placeholder-text-color']))); 75 } elseif($data['footer-image'] != '') { 76 $renderer->doc .= '<img src="' . $data['footer-image'] . '" class="' . $this->elemClass . ' ' . $this->classPrefix . 'card-image">'; 77 } 78 79 if($data['horizontal']) $renderer->doc .= '</div>'; 80 $renderer->doc .= '</div>'; 81 } 82} 83?>