1<?php 2/** 3 * Mikio Syntax Plugin: Card 4 * 5 * Syntax: <CARD [width=] [height=] [image=] [title=] [header=] [subtitle=] [listgroup] [nobody]></CARD> 6 * 7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 8 * @author James Collins <james.collins@outlook.com.au> 9 */ 10 11if (!defined('DOKU_INC')) die(); 12if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13require_once(dirname(__FILE__).'/core.php'); 14 15class syntax_plugin_mikioplugin_card extends syntax_plugin_mikioplugin_core { 16 public $tag = 'card'; 17 public $options = array('width', 'height', 'image', 'title', 'subtitle', 'listgroup', 'nobody', 'header'); 18 19 20 public function render_lexer_enter(Doku_Renderer $renderer, $data) { 21 $styles = []; 22 $body = true; 23 24 $this->setAttr($styles, 'width', $data); 25 $this->setAttr($styles, 'height', $data); 26 27 $renderer->doc .= '<div class="card"' . $this->listAttr('style', $styles) . '>'; 28 if(array_key_exists('image', $data) && $data['image'] != '') $renderer->doc .= '<img src="' . $this->getMediaFile($data['image']) . '" class="card-img-top">'; 29 30 if((array_key_exists('listgroup', $data) && $data['listgroup'] == true) || (array_key_exists('nobody', $data) && $data['nobody'] == true)) $body = false; 31 32 if(array_key_exists('header', $data) && $data['header'] != '') $this->syntaxRender($renderer, 'syntax_plugin_mikioplugin_cardheader', $data['header']); 33 34 if($body) { 35 $renderer->doc .= '<div class="card-body">'; 36 } 37 38 if(array_key_exists('title', $data) && $data['title'] != '') $this->syntaxRender($renderer, 'syntax_plugin_mikioplugin_cardtitle', $data['title']); 39 if(array_key_exists('subtitle', $data) && $data['subtitle'] != '') $this->syntaxRender($renderer, 'syntax_plugin_mikioplugin_cardsubtitle', $data['subtitle']); 40 } 41 42 43 public function render_lexer_exit(Doku_Renderer $renderer, $data) { 44 if((!array_key_exists('listgroup', $this->values) || $this->values['listgroup'] == false) && (!array_key_exists('nobody', $this->values) || $this->values['nobody'] == false)) { 45 $renderer->doc .= '</div>'; 46 } 47 48 $renderer->doc .= '</div>'; 49 } 50} 51?>