1<?php 2/** 3 * Mikio Syntax Plugin: Card 4 * 5 * Syntax: <CARD [width=] [height=] [image=] [image-overlay=] [footer-image=] [title=] [header=] [footer=] [subtitle=] [listgroup] [nobody] [placeholder-text=] [placeholder-colour=] [placeholder-text-colour=] [footer-placeholder-text=] [footer-placeholder-colour=] [footer-placeholder-text-colour=]></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', 'overlay', 'title', 'subtitle', 'listgroup', 'nobody', 'header', 'footer', 'placeholder-text', 'placeholder-colour', 'placeholder-text-colour', 'footer-image', 'footer-placeholder-text', 'footer-placeholder-colour', 'footer-placeholder-text-colour'); 18 19 20 public function render_lexer_enter(Doku_Renderer $renderer, $data) { 21 $styles = []; 22 $body = true; 23 $overlay = false; 24 $classes = $this->buildClassString($data); 25 26 $this->setAttr($styles, 'width', $data); 27 $this->setAttr($styles, 'height', $data); 28 29 if(array_key_exists('overlay', $data) && $data['overlay'] != false) $overlay = true; 30 31 $renderer->doc .= '<div class="card ' . $classes . '"' . $this->listAttr('style', $styles) . '>'; 32 if((array_key_exists('placeholder-text', $data) && $data['placeholder-text'] != '') || (array_key_exists('placeholder-colour', $data) && $data['placeholder-colour'] != '') || (array_key_exists('placeholder-text-colour', $data) && $data['placeholder-text-colour'] != '')) { 33 $placeholderData = array('classes' => ($overlay ? 'card-img' : 'card-img-top')); 34 if(array_key_exists('placeholder-text', $data) && $data['placeholder-text'] != '') $placeholderData['text'] = $data['placeholder-text']; 35 if(array_key_exists('placeholder-colour', $data) && $data['placeholder-colour'] != '') $placeholderData['colour'] = $data['placeholder-colour']; 36 if(array_key_exists('placeholder-text-colour', $data) && $data['placeholder-text-colour'] != '') $placeholderData['text-colour'] = $data['placeholder-text-colour']; 37 38 $this->syntaxRender($renderer, 'syntax_plugin_mikioplugin_placeholder', '', $placeholderData); 39 40 } else { 41 if(array_key_exists('image', $data) && $data['image'] != '') $renderer->doc .= '<img src="' . $this->getMediaFile($data['image']) . '" class="card-img-top">'; 42 } 43 44 if((array_key_exists('listgroup', $data) && $data['listgroup'] == true) || (array_key_exists('nobody', $data) && $data['nobody'] == true)) $body = false; 45 46 if(array_key_exists('header', $data) && $data['header'] != '') $this->syntaxRender($renderer, 'syntax_plugin_mikioplugin_cardheader', $data['header']); 47 48 if($body) { 49 if($overlay) { 50 $renderer->doc .= '<div class="card-img-overlay">'; 51 } else { 52 $renderer->doc .= '<div class="card-body">'; 53 } 54 } 55 56 if(array_key_exists('title', $data) && $data['title'] != '') $this->syntaxRender($renderer, 'syntax_plugin_mikioplugin_cardtitle', $data['title']); 57 if(array_key_exists('subtitle', $data) && $data['subtitle'] != '') $this->syntaxRender($renderer, 'syntax_plugin_mikioplugin_cardsubtitle', $data['subtitle']); 58 } 59 60 61 public function render_lexer_exit(Doku_Renderer $renderer, $data) { 62 if((!array_key_exists('listgroup', $this->values) || $this->values['listgroup'] == false) && (!array_key_exists('nobody', $this->values) || $this->values['nobody'] == false)) { 63 $renderer->doc .= '</div>'; 64 } 65 66 if(array_key_exists('footer', $this->values) && $this->values['footer'] != '') $this->syntaxRender($renderer, 'syntax_plugin_mikioplugin_cardfooter', $this->values['footer']); 67 68 if((array_key_exists('footer-placeholder-text', $this->values) && $this->values['footer-placeholder-text'] != '') || (array_key_exists('footer-placeholder-colour', $this->values) && $this->values['footer-placeholder-colour'] != '') || (array_key_exists('footer-placeholder-text-colour', $this->values) && $this->values['footer-placeholder-text-colour'] != '')) { 69 $placeholderData = array('classes' => 'card-img-top'); 70 if(array_key_exists('footer-placeholder-text', $this->values) && $this->values['footer-placeholder-text'] != '') $placeholderData['text'] = $this->values['footer-placeholder-text']; 71 if(array_key_exists('footer-placeholder-colour', $this->values) && $this->values['footer-placeholder-colour'] != '') $placeholderData['colour'] = $this->values['footer-placeholder-colour']; 72 if(array_key_exists('footer-placeholder-text-colour', $this->values) && $this->values['footer-placeholder-text-colour'] != '') $placeholderData['text-colour'] = $this->values['footer-placeholder-text-colour']; 73 74 $this->syntaxRender($renderer, 'syntax_plugin_mikioplugin_placeholder', '', $placeholderData); 75 76 } else { 77 if(array_key_exists('footer-image', $this->values) && $this->values['footer-image'] != '') $renderer->doc .= '<img src="' . $this->getMediaFile($this->values['footer-image']) . '" class="card-img-top">'; 78 } 79 80 $renderer->doc .= '</div>'; 81 } 82} 83?>