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